Publish the card and the script that built this dataset
Browse filesFiles changed (2)
- README.md+17-12
- scripts/create_dataset.pyAdded+178
32 unmodified lines3334353637383 unmodified lines424344454647485 unmodified lines545556575859606162636465666768697071727374757677787910 unmodified lines9091929332 unmodified linesdata_files:- split: testpath: gold/test-*language:- enlicense: apache-2.03 unmodified lines- evaluation- alpaca-eval---# SmolTalkBench1000 single-turn everyday chat prompts with reference replies, for AlpacaEval-style pairwisewin rates. Built to compare the rule-based chatbot from the run4 agent swarm5 unmodified linesds = load_dataset("HuggingFaceSwarms/SmolTalkBench", "gold", split="test")```## Configs| config | reference replies (`output`) ||---|---|| `gold` (default) | the source conversations' replies, by `meta-llama/Meta-Llama-3.1-70B-Instruct` |Variants with other reference models go in their own configs, keeping the same `id`s andinstructions so that results compare across them.## Construction- Source: the `everyday-conversations` subset of [`HuggingFaceTB/smoltalk`](https://huggingface.co/datasets/HuggingFaceTB/smoltalk)at revision `5feaf2fd3ffc`, train and test splits. Each conversation was written whole by[`meta-llama/Meta-Llama-3.1-70B-Instruct`](https://huggingface.co/meta-llama/Meta-Llama-3.1-70B-Instruct).- Every source conversation opens with a bare greeting ("Hi", "Hello", ...) answered by"Hello! How can I help you today?". The greeting is dropped: `instruction` is the seconduser turn and `output` the assistant's reply to it.- Prompts are deduplicated (case and whitespace insensitive), leaving 2198 rows.- 1000 rows are sampled with seed 0, in proportion to each parent topic (`topic` withoutits last level), so every subcategory keeps its share.## Columns10 unmodified linesNote that SmolLM and SmolLM2 Instruct models were trained on the source conversations.Built by `experiments/run4/eval/build_smoltalkbench.py` in the flock repository.32 unmodified lines333435363738393 unmodified lines4344454647484950515 unmodified lines575859606162636465666768697071727374757610 unmodified lines87888990919293949596979832 unmodified linesdata_files:- split: testpath: gold/test-*default: truelanguage:- enlicense: apache-2.03 unmodified lines- evaluation- alpaca-eval---| subset | description | num_samples || --- | --- | ---: || `gold` (default) | Single-turn everyday chat prompts from smoltalk's `everyday-conversations`, sampled in proportion to their parent topic, with the source conversations' replies by `meta-llama/Meta-Llama-3.1-70B-Instruct` as references | 1000 |1000 single-turn everyday chat prompts with reference replies, for AlpacaEval-style pairwisewin rates. Built to compare the rule-based chatbot from the run4 agent swarm5 unmodified linesds = load_dataset("HuggingFaceSwarms/SmolTalkBench", "gold", split="test")```Variants with other reference models go in their own configs, keeping the same `id`s andinstructions so that results compare across them.## Construction- Source: the `everyday-conversations` subset of [`HuggingFaceTB/smoltalk`](https://huggingface.co/datasets/HuggingFaceTB/smoltalk)at revision `5feaf2fd3ffc`, train and test splits. Each conversation waswritten whole by [`meta-llama/Meta-Llama-3.1-70B-Instruct`](https://huggingface.co/meta-llama/Meta-Llama-3.1-70B-Instruct).- Every source conversation opens with a bare greeting ("Hi", "Hello", ...) answered by"Hello! How can I help you today?". The greeting is dropped: `instruction` is the seconduser turn and `output` the assistant's reply to it.- Prompts are deduplicated (case and whitespace insensitive), leaving 2198 rows.- 1000 rows are sampled with seed 0, in proportion to each parent topic (`topic`without its last level), so every subcategory keeps its share.## Columns10 unmodified linesNote that SmolLM and SmolLM2 Instruct models were trained on the source conversations.## Reproducing[`scripts/create_dataset.py`](scripts/create_dataset.py) builds the `gold` config and pushes it with this card and itself:```shhf download HuggingFaceSwarms/SmolTalkBench scripts/create_dataset.py --repo-type dataset --local-dir .uv run scripts/create_dataset.py --n 1000 --seed 0 \--source_revision 5feaf2fd3ffca7c237fc38d1861bc30365d48ffa --repo HuggingFaceSwarms/SmolTalkBench --push```
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178# /// script# requires-python = ">=3.11"# dependencies = ["datasets>=3.0", "huggingface_hub>=0.30"]# ///"""Build SmolTalkBench: single-turn chat prompts with reference replies, AlpacaEval style.
uv run scripts/create_dataset.py # build and print stats uv run scripts/create_dataset.py --push # also push the data, card and this script
This builds the `gold` config, whose references come from the source conversations. Variantswith other reference models go in their own configs, keeping the same ids and instructions.
Source: the everyday-conversations subset of HuggingFaceTB/smoltalk (train + test), writtenwhole by Llama-3.1-70B-Instruct. Every conversation opens with a bare greeting and the same"How can I help you today?", so the prompt is the second user turn and the reference is theassistant's reply to it. Prompts are deduplicated, then sampled in proportion to their parenttopic (full_topic without its leaf), largest remainders rounding the allocation to exactly N.Columns follow AlpacaEval's reference outputs (instruction, output, generator, dataset)."""
import argparseimport randomfrom collections import Counter, defaultdictfrom pathlib import Path
from datasets import Dataset, load_datasetfrom huggingface_hub import CommitOperationAdd, DatasetCard, HfApi
SOURCE = "HuggingFaceTB/smoltalk"SUBSET = "everyday-conversations"SOURCE_REVISION = "5feaf2fd3ffca7c237fc38d1861bc30365d48ffa"GENERATOR = "meta-llama/Meta-Llama-3.1-70B-Instruct"REPO = "HuggingFaceSwarms/SmolTalkBench"CONFIG = "gold"SCRIPT = "scripts/create_dataset.py"META = {"license": "apache-2.0", "language": ["en"], "pretty_name": "SmolTalkBench", "tags": ["chatbot", "evaluation", "alpaca-eval"]}
def candidates(source_revision): """One row per distinct second user turn, first occurrence kept (train, then test).""" ds = load_dataset(SOURCE, SUBSET, revision=source_revision) rows, seen = [], set() for split in ("train", "test"): for index, record in enumerate(ds[split]): msgs = record["messages"] assert [m["role"] for m in msgs[:4]] == ["user", "assistant", "user", "assistant"] prompt = msgs[2]["content"].strip() key = " ".join(prompt.casefold().split()) if key in seen: continue seen.add(key) topic = record["full_topic"] rows.append({"id": f"{split}-{index:04d}", "instruction": prompt, "output": msgs[3]["content"].strip(), "generator": GENERATOR, "dataset": f"{SOURCE}/{SUBSET}", "topic": topic, "category": topic.split("/")[0], # Capitalised three-level topics are everyday requests; lowercase # two-level ones are grade-school science and general knowledge. "group": "everyday" if topic.count("/") == 2 else "school", "source_split": split, "source_index": index}) return rows
def stratified(rows, n, seed): """Proportional allocation over parent topics, rounded by largest remainder.""" strata = defaultdict(list) for row in rows: strata[row["topic"].rsplit("/", 1)[0]].append(row) names = sorted(strata) quotas = {s: n * len(strata[s]) / len(rows) for s in names} alloc = {s: int(q) for s, q in quotas.items()} for s in sorted(names, key=lambda s: (alloc[s] - quotas[s], s))[:n - sum(alloc.values())]: alloc[s] += 1 rng = random.Random(seed) picked = [row for s in names for row in rng.sample(strata[s], alloc[s])] return sorted(picked, key=lambda row: (row["source_split"] != "train", row["source_index"]))
def card(args, total): public = " --public" if args.public else "" return f"""| subset | description | num_samples || --- | --- | ---: || `{CONFIG}` (default) | Single-turn everyday chat prompts from smoltalk's `{SUBSET}`, sampled in proportion to their parent topic, with the source conversations' replies by `{GENERATOR}` as references | {args.n} |
{args.n} single-turn everyday chat prompts with reference replies, for AlpacaEval-style pairwisewin rates. Built to compare the rule-based chatbot from the run4 agent swarm(`cmpatino/chatbot-swarm`) at different commits, and small LMs, against one fixed reference.
```pythonfrom datasets import load_dataset
ds = load_dataset("{args.repo}", "{CONFIG}", split="test")```
Variants with other reference models go in their own configs, keeping the same `id`s andinstructions so that results compare across them.
## Construction
- Source: the `{SUBSET}` subset of [`{SOURCE}`](https://huggingface.co/datasets/{SOURCE}) at revision `{args.source_revision[:12]}`, train and test splits. Each conversation was written whole by [`{GENERATOR}`](https://huggingface.co/{GENERATOR}).- Every source conversation opens with a bare greeting ("Hi", "Hello", ...) answered by "Hello! How can I help you today?". The greeting is dropped: `instruction` is the second user turn and `output` the assistant's reply to it.- Prompts are deduplicated (case and whitespace insensitive), leaving {total} rows.- {args.n} rows are sampled with seed {args.seed}, in proportion to each parent topic (`topic` without its last level), so every subcategory keeps its share.
## Columns
| column | description ||---|---|| `id` | `<source split>-<source index>` || `instruction` | the prompt (second user turn) || `output` | reference reply by `generator` || `generator`, `dataset` | reference model and source, as in AlpacaEval's reference outputs || `topic` | the source `full_topic` || `category` | first level of `topic` || `group` | `everyday` (three-level topics) or `school` (two-level grade-school knowledge topics) || `source_split`, `source_index` | the row in the source subset |
Note that SmolLM and SmolLM2 Instruct models were trained on the source conversations.
## Reproducing
[`{SCRIPT}`]({SCRIPT}) builds the `{CONFIG}` config and pushes it with this card and itself:
```shhf download {args.repo} {SCRIPT} --repo-type dataset --local-dir .uv run {SCRIPT} --n {args.n} --seed {args.seed} \\ --source_revision {args.source_revision} --repo {args.repo} --push{public}```"""
def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--n", type=int, default=1000) parser.add_argument("--seed", type=int, default=0) parser.add_argument("--source_revision", default=SOURCE_REVISION, help=f"commit of {SOURCE}") parser.add_argument("--repo", default=REPO) parser.add_argument("--push", action="store_true") parser.add_argument("--public", action="store_true", help="push as a public dataset") args = parser.parse_args() rows = candidates(args.source_revision) picked = stratified(rows, args.n, args.seed) assert len(picked) == args.n and len({r["id"] for r in picked}) == args.n print(f"{len(rows)} distinct prompts -> {len(picked)} sampled") print("groups:", dict(Counter(r["group"] for r in picked))) print("categories:", dict(Counter(r["category"] for r in picked).most_common())) if not args.push: return Dataset.from_list(picked).push_to_hub(args.repo, config_name=CONFIG, split="test", private=not args.public) # push_to_hub wrote the card's dataset_info and configs; keep them, add ours. pushed = DatasetCard.load(args.repo, repo_type="dataset") for key, value in META.items(): pushed.data[key] = value # push_to_hub(set_default=True) drops or trips over the flag when re-pushing the default # config (datasets 5.1), so make gold the default here. for entry in pushed.data["configs"]: if entry["config_name"] == CONFIG: entry["default"] = True pushed.text = card(args, len(rows)) api = HfApi() api.create_commit(args.repo, repo_type="dataset", operations=[ CommitOperationAdd("README.md", str(pushed).encode()), CommitOperationAdd(SCRIPT, Path(__file__).read_bytes()), ], commit_message="Publish the card and the script that built this dataset") print(f"pushed https://huggingface.co/datasets/{args.repo} @ " f"{api.dataset_info(args.repo).sha}")
if __name__ == "__main__": main()README.md+17-12
scripts/create_dataset.pyAdded+178