lewtun HF Staff commited on
Commit
0dd39c8
·
verified ·
1 Parent(s): 47c5b1b

Publish the gold_gamed config's card section and the script that built it

Browse files
Files changed (2) hide show
  1. README.md +50 -0
  2. scripts/create_gold_gamed.py +312 -0
README.md CHANGED
@@ -84,6 +84,7 @@ tags:
84
  | subset | description | num_samples |
85
  | --- | --- | ---: |
86
  | `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 |
 
87
 
88
  1000 single-turn everyday chat prompts with reference replies, for AlpacaEval-style pairwise
89
  win rates. Built to compare the rule-based chatbot from the run4 agent swarm
@@ -125,6 +126,44 @@ instructions so that results compare across them.
125
 
126
  Note that SmolLM and SmolLM2 Instruct models were trained on the source conversations.
127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  ## Reproducing
129
 
130
  [`scripts/create_dataset.py`](scripts/create_dataset.py) builds the `gold` config and pushes it with this card and itself:
@@ -134,3 +173,14 @@ hf download HuggingFaceSwarms/SmolTalkBench scripts/create_dataset.py --repo-typ
134
  uv run scripts/create_dataset.py --n 1000 --seed 0 \
135
  --source_revision 5feaf2fd3ffca7c237fc38d1861bc30365d48ffa --repo HuggingFaceSwarms/SmolTalkBench --push
136
  ```
 
 
 
 
 
 
 
 
 
 
 
 
84
  | subset | description | num_samples |
85
  | --- | --- | ---: |
86
  | `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 |
87
+ | `gold_gamed` | Gamed baselines for the length-controlled win rate: `meta-llama/Llama-3.1-70B-Instruct` told to answer in a few words, in one sentence, concisely or in detail, judged against `gold` | 4000 |
88
 
89
  1000 single-turn everyday chat prompts with reference replies, for AlpacaEval-style pairwise
90
  win rates. Built to compare the rule-based chatbot from the run4 agent swarm
 
126
 
127
  Note that SmolLM and SmolLM2 Instruct models were trained on the source conversations.
128
 
129
+ ## The `gold_gamed` config
130
+
131
+ The gamed baselines of AlpacaEval's `length_controlled_v1` GLM (its `df_gamed.csv`), for the
132
+ `gold` references: their model, [`meta-llama/Llama-3.1-70B-Instruct`](https://huggingface.co/meta-llama/Llama-3.1-70B-Instruct),
133
+ answers each instruction once per variant under a system prompt that asks for a length, and
134
+ each reply is judged against the gold reference. Fitted alongside a model's judgements, without
135
+ an intercept and at a total weight of 0.2 per instruction, they set how much length alone moves
136
+ the judge. The length-controlled win rate then can't put all of a model's losses down to length.
137
+
138
+ | variant | system prompt | median words | win rate vs `gold` (%) |
139
+ |---|---|---:|---:|
140
+ | `terse` | You are a helpful assistant. Answer in as few words as possible. | 7 | 9.8 |
141
+ | `brief` | You are a helpful assistant. Answer in one short sentence. | 20 | 46.3 |
142
+ | `concise` | You are a helpful assistant. Be as concise as possible while still providing all the necessary information to answer the question. | 104 | 96.4 |
143
+ | `verbose` | You are a helpful assistant. Always answer with as much detail as possible. | 456 | 98.3 |
144
+
145
+ The `gold` references have a median of 24 words. The concise and
146
+ verbose prompts are AlpacaEval's; `terse` and `brief` cover replies as short as the
147
+ references and shorter. Each reply
148
+ is the model's answer to the instruction as a single user turn, sampled with its
149
+ `generation_config` (vLLM 0.32.0, seed 0, at most 4096 tokens).
150
+
151
+ - **The judge** is `hf-inference-providers/deepseek-ai/DeepSeek-V4.1-Flash:fireworks-ai`, with the eval's settings: AlpacaEval 2.0's weighted annotator
152
+ prompt, the reply and the reference swapped as AlpacaEval does, one token at temperature 1,
153
+ and the preference read from its top-5 logprobs. The preferences only calibrate evals by the
154
+ same judge.
155
+
156
+ | column | description |
157
+ |---|---|
158
+ | `id`, `instruction` | the `gold` row |
159
+ | `variant`, `system_prompt` | which gamed baseline, and its system prompt |
160
+ | `output` | the reply |
161
+ | `generator`, `finish_reason` | the model, and why its reply ended (`length` when truncated) |
162
+ | `output_length`, `reference_length` | the reply's and the `gold` reference's length in characters |
163
+ | `switched` | whether the reply was shown to the judge first |
164
+ | `preference` | 1 when the reference wins, 2 when the reply does, NaN when the judge named neither |
165
+ | `judge`, `judge_top_logprobs` | the judge, and the top-5 logprobs of its one token (JSON) |
166
+
167
  ## Reproducing
168
 
169
  [`scripts/create_dataset.py`](scripts/create_dataset.py) builds the `gold` config and pushes it with this card and itself:
 
173
  uv run scripts/create_dataset.py --n 1000 --seed 0 \
174
  --source_revision 5feaf2fd3ffca7c237fc38d1861bc30365d48ffa --repo HuggingFaceSwarms/SmolTalkBench --push
175
  ```
176
+
177
+ [`scripts/create_gold_gamed.py`](scripts/create_gold_gamed.py) builds the `gold_gamed` config on a Hugging Face Job, and adds it to this
178
+ card and pushes itself. Run it after `create_dataset.py`, which rewrites the card:
179
+
180
+ ```sh
181
+ hf download HuggingFaceSwarms/SmolTalkBench scripts/create_gold_gamed.py --repo-type dataset --local-dir .
182
+ hf jobs uv run --image vllm/vllm-openai:v0.32.0 --flavor h200x2 --secrets HF_TOKEN \
183
+ --timeout 4h scripts/create_gold_gamed.py \
184
+ --gold_revision dbda1eaf1e9839f51e7ef073783dacd226d7ebfb --generator_revision 1605565b47bb9346c5515c34102e054115b4f98b \
185
+ --repo HuggingFaceSwarms/SmolTalkBench --push
186
+ ```
scripts/create_gold_gamed.py ADDED
@@ -0,0 +1,312 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = ["vllm==0.32.0", "inspect-ai==0.3.286", "openai", "datasets>=3.0",
4
+ # "huggingface_hub>=0.30"]
5
+ # ///
6
+ """Build SmolTalkBench's `gold_gamed` config: the gold references' model told to answer in a
7
+ few words, in one sentence, concisely or in detail, each reply judged against the gold
8
+ reference. These are the gamed baselines that calibrate the length-controlled win rate, as
9
+ AlpacaEval's `df_gamed.csv` does for its `length_controlled_v1` GLM.
10
+
11
+ uv run scripts/create_gold_gamed.py --limit 20 # smoke test, needs a GPU
12
+ hf jobs uv run --image vllm/vllm-openai:v0.32.0 --flavor h200x2 --secrets HF_TOKEN \
13
+ scripts/create_gold_gamed.py --push
14
+
15
+ The model answers each gold instruction once per variant, as a single user turn under the
16
+ variant's system prompt: AlpacaEval's concise and verbose prompts, which come out longer than
17
+ the references, and two prompts for replies as short as them and shorter. It samples with its
18
+ generation_config, through vLLM.
19
+ The judge and its settings are the eval's (flock's experiments/run4/eval/smoltalk_bench.py):
20
+ AlpacaEval 2.0's weighted annotator prompt, the reference and the reply swapped as AlpacaEval
21
+ does, and the preference read from the top-5 logprobs of the judge's one token. Run it after
22
+ create_dataset.py, which rewrites the card. vLLM's image has the CUDA toolkit that its
23
+ two-GPU all-reduce compiles kernels with.
24
+ """
25
+
26
+ import argparse
27
+ import asyncio
28
+ import json
29
+ import math
30
+ import random
31
+ import statistics
32
+ from pathlib import Path
33
+
34
+ from datasets import Dataset, load_dataset
35
+ from huggingface_hub import CommitOperationAdd, DatasetCard, HfApi
36
+
37
+ REPO = "HuggingFaceSwarms/SmolTalkBench"
38
+ GOLD = "gold"
39
+ GOLD_REVISION = "dbda1eaf1e9839f51e7ef073783dacd226d7ebfb"
40
+ CONFIG = "gold_gamed"
41
+ SCRIPT = "scripts/create_gold_gamed.py"
42
+ GENERATOR = "meta-llama/Llama-3.1-70B-Instruct"
43
+ GENERATOR_REVISION = "1605565b47bb9346c5515c34102e054115b4f98b"
44
+ JUDGE = "hf-inference-providers/deepseek-ai/DeepSeek-V4.1-Flash:fireworks-ai"
45
+ # AlpacaEval's concise and verbose prompts (models_configs/gpt4_1106_preview_*), and two for
46
+ # the short end
47
+ VARIANTS = {
48
+ "terse": "You are a helpful assistant. Answer in as few words as possible.",
49
+ "brief": "You are a helpful assistant. Answer in one short sentence.",
50
+ "concise": "You are a helpful assistant. Be as concise as possible while still providing all "
51
+ "the necessary information to answer the question.",
52
+ "verbose": "You are a helpful assistant. Always answer with as much detail as possible.",
53
+ }
54
+ MAX_TOKENS = 4096 # AlpacaEval's, for its gamed baselines
55
+ SEED = 0
56
+
57
+ # AlpacaEval's weighted_alpaca_eval_gpt4_turbo annotator, ported from tatsu-lab/alpaca_eval
58
+ # (Apache-2.0) as in flock's experiments/run4/eval/judge.py
59
+ JUDGE_SYSTEM = (
60
+ "You are a highly efficient assistant, who evaluates and selects the best large language "
61
+ "model (LLMs) based on the quality of their responses to a given instruction. This process "
62
+ "will be used to create a leaderboard reflecting the most accurate and human-preferred answers."
63
+ )
64
+ JUDGE_USER = '''I require a leaderboard for various large language models. I'll provide you with prompts given to these models and their corresponding outputs. Your task is to assess these responses, and select the model that produces the best output from a human perspective.
65
+
66
+ ## Instruction
67
+
68
+ {
69
+ "instruction": """{instruction}""",
70
+ }
71
+
72
+ ## Model Outputs
73
+
74
+ Here are the unordered outputs from the models. Each output is associated with a specific model, identified by a unique model identifier.
75
+
76
+ {
77
+ {
78
+ "model_identifier": "m",
79
+ "output": """{output_1}"""
80
+ },
81
+ {
82
+ "model_identifier": "M",
83
+ "output": """{output_2}"""
84
+ }
85
+ }
86
+
87
+ ## Task
88
+
89
+ Evaluate the models based on the quality and relevance of their outputs, and select the model that generated the best output. Answer by providing the model identifier of the best model. We will use your output as the name of the best model, so make sure your output only contains one of the following model identifiers and nothing else (no quotes, no spaces, no new lines, ...): m or M.
90
+
91
+ ## Best Model Identifier'''
92
+ JUDGE_SEED = 0
93
+
94
+
95
+ def is_switched(instruction: str) -> bool:
96
+ """Whether the reply goes first, as AlpacaEval's RandomSwitchTwoColumnsProcessor."""
97
+ return random.Random(f"is_switched_outputs{instruction}{JUDGE_SEED}").choices([False, True])[0]
98
+
99
+
100
+ def judge_user(instruction: str, output_1: str, output_2: str) -> str:
101
+ """The judge's user message, placeholders filled in template order."""
102
+ user = JUDGE_USER
103
+ for key, value in (("instruction", instruction), ("output_1", output_1),
104
+ ("output_2", output_2)):
105
+ user = user.replace("{" + key + "}", value, 1)
106
+ return user
107
+
108
+
109
+ def preference(top_logprobs: dict[str, float]) -> float:
110
+ """1 when output_1 ("m") is certainly better, 2 when output_2 ("M") is, NaN when neither
111
+ token is listed."""
112
+ if "m" not in top_logprobs and "M" not in top_logprobs:
113
+ return math.nan
114
+ p_m = math.exp(top_logprobs.get("m", -math.inf))
115
+ p_big_m = math.exp(top_logprobs.get("M", -math.inf))
116
+ return 2 - p_m / (p_m + p_big_m)
117
+
118
+
119
+ def generate(rows: list[dict], args) -> list[dict]:
120
+ """One reply per gold row and variant, from the generator under the variant's prompt."""
121
+ import torch
122
+ from vllm import LLM
123
+
124
+ llm = LLM(model=args.generator, revision=args.generator_revision, seed=SEED,
125
+ tensor_parallel_size=torch.cuda.device_count(), max_model_len=8192)
126
+ params = llm.get_default_sampling_params() # the model's generation_config
127
+ params.max_tokens, params.seed = MAX_TOKENS, SEED
128
+ items = [{"id": row["id"], "instruction": row["instruction"], "variant": variant,
129
+ "system_prompt": prompt, "reference": row["output"]}
130
+ for variant, prompt in VARIANTS.items() for row in rows]
131
+ outputs = llm.chat([[{"role": "system", "content": item["system_prompt"]},
132
+ {"role": "user", "content": item["instruction"]}] for item in items],
133
+ params)
134
+ for item, output in zip(items, outputs, strict=True):
135
+ reply = output.outputs[0]
136
+ item["output"], item["finish_reason"] = reply.text, reply.finish_reason
137
+ print(f"sampling: temperature {params.temperature}, top_p {params.top_p}, "
138
+ f"top_k {params.top_k}, max_tokens {params.max_tokens}")
139
+ return items
140
+
141
+
142
+ async def judge(items: list[dict], judge_model: str, max_connections: int) -> None:
143
+ """Adds the judge's preference for each reply over its reference, as the eval's scorer."""
144
+ from inspect_ai.model import ChatMessageSystem, ChatMessageUser, GenerateConfig, get_model
145
+
146
+ # The eval's JUDGE_CONFIG, with its retries
147
+ config = GenerateConfig(max_tokens=1, temperature=1.0, logprobs=True, top_logprobs=5,
148
+ extra_body={"chat_template_kwargs": {"thinking": False}},
149
+ max_connections=max_connections, max_retries=10, timeout=600)
150
+ grader = get_model(judge_model, config=config)
151
+
152
+ async def one(item):
153
+ switched = is_switched(item["instruction"])
154
+ output_1, output_2 = ((item["output"], item["reference"]) if switched
155
+ else (item["reference"], item["output"]))
156
+ result = await grader.generate([
157
+ ChatMessageSystem(content=JUDGE_SYSTEM),
158
+ ChatMessageUser(content=judge_user(item["instruction"], output_1, output_2))])
159
+ logprobs = result.choices[0].logprobs if result.choices else None
160
+ top = {t.token: t.logprob for t in logprobs.content[0].top_logprobs} \
161
+ if logprobs and logprobs.content else {}
162
+ pref = preference(top)
163
+ item.update(switched=switched, preference=3 - pref if switched else pref,
164
+ judge=str(grader), judge_top_logprobs=json.dumps(top))
165
+
166
+ await asyncio.gather(*(one(item) for item in items))
167
+
168
+
169
+ def stats(rows: list[dict]) -> dict[str, dict]:
170
+ """Per variant: median words, win rate against the gold reference, unjudged and
171
+ truncated replies."""
172
+ out = {}
173
+ for variant in VARIANTS:
174
+ sub = [r for r in rows if r["variant"] == variant]
175
+ wins = [r["preference"] - 1 for r in sub if not math.isnan(r["preference"])]
176
+ out[variant] = {"n": len(sub),
177
+ "median_words": statistics.median(len(r["output"].split()) for r in sub),
178
+ "win_rate": 100 * statistics.fmean(wins) if wins else math.nan,
179
+ "unjudged": len(sub) - len(wins),
180
+ "truncated": sum(r["finish_reason"] == "length" for r in sub)}
181
+ out["gold"] = {"median_words": statistics.median(
182
+ len(r["reference"].split()) for r in rows if r["variant"] == next(iter(VARIANTS)))}
183
+ return out
184
+
185
+
186
+ def section(args, summary: dict) -> str:
187
+ rows = "\n".join(
188
+ f"| `{v}` | {VARIANTS[v]} | {s['median_words']:g} | {s['win_rate']:.1f} |"
189
+ for v, s in summary.items() if v in VARIANTS)
190
+ return f"""## The `{CONFIG}` config
191
+
192
+ The gamed baselines of AlpacaEval's `length_controlled_v1` GLM (its `df_gamed.csv`), for the
193
+ `gold` references: their model, [`{args.generator}`](https://huggingface.co/{args.generator}),
194
+ answers each instruction once per variant under a system prompt that asks for a length, and
195
+ each reply is judged against the gold reference. Fitted alongside a model's judgements, without
196
+ an intercept and at a total weight of 0.2 per instruction, they set how much length alone moves
197
+ the judge. The length-controlled win rate then can't put all of a model's losses down to length.
198
+
199
+ | variant | system prompt | median words | win rate vs `gold` (%) |
200
+ |---|---|---:|---:|
201
+ {rows}
202
+
203
+ The `gold` references have a median of {summary['gold']['median_words']:g} words. The concise and
204
+ verbose prompts are AlpacaEval's; `terse` and `brief` cover replies as short as the
205
+ references and shorter. Each reply
206
+ is the model's answer to the instruction as a single user turn, sampled with its
207
+ `generation_config` (vLLM 0.32.0, seed {SEED}, at most {MAX_TOKENS} tokens).
208
+
209
+ - **The judge** is `{args.judge}`, with the eval's settings: AlpacaEval 2.0's weighted annotator
210
+ prompt, the reply and the reference swapped as AlpacaEval does, one token at temperature 1,
211
+ and the preference read from its top-5 logprobs. The preferences only calibrate evals by the
212
+ same judge.
213
+
214
+ | column | description |
215
+ |---|---|
216
+ | `id`, `instruction` | the `gold` row |
217
+ | `variant`, `system_prompt` | which gamed baseline, and its system prompt |
218
+ | `output` | the reply |
219
+ | `generator`, `finish_reason` | the model, and why its reply ended (`length` when truncated) |
220
+ | `output_length`, `reference_length` | the reply's and the `gold` reference's length in characters |
221
+ | `switched` | whether the reply was shown to the judge first |
222
+ | `preference` | 1 when the reference wins, 2 when the reply does, NaN when the judge named neither |
223
+ | `judge`, `judge_top_logprobs` | the judge, and the top-5 logprobs of its one token (JSON) |
224
+
225
+ """
226
+
227
+
228
+ def reproducing(args) -> str:
229
+ return f"""
230
+ [`{SCRIPT}`]({SCRIPT}) builds the `{CONFIG}` config on a Hugging Face Job, and adds it to this
231
+ card and pushes itself. Run it after `create_dataset.py`, which rewrites the card:
232
+
233
+ ```sh
234
+ hf download {args.repo} {SCRIPT} --repo-type dataset --local-dir .
235
+ hf jobs uv run --image vllm/vllm-openai:v0.32.0 --flavor h200x2 --secrets HF_TOKEN \\
236
+ --timeout 4h {SCRIPT} \\
237
+ --gold_revision {args.gold_revision} --generator_revision {args.generator_revision} \\
238
+ --repo {args.repo} --push
239
+ ```
240
+ """
241
+
242
+
243
+ def with_config(text: str, args, summary: dict, n: int) -> str:
244
+ """The card with this config's row in the summary table, its section before Reproducing and
245
+ its command at the end, replacing any earlier ones."""
246
+ row = (f"| `{CONFIG}` | Gamed baselines for the length-controlled win rate: "
247
+ f"`{args.generator}` told to answer in a few words, in one sentence, concisely or in "
248
+ f"detail, judged against "
249
+ f"`gold` | {n} |")
250
+ lines = [line for line in text.split("\n") if not line.startswith(f"| `{CONFIG}` |")]
251
+ last_row = lines.index("| subset | description | num_samples |") + 1
252
+ while lines[last_row + 1].startswith("| `"):
253
+ last_row += 1
254
+ text = "\n".join(lines[:last_row + 1] + [row] + lines[last_row + 1:])
255
+ head, sep, tail = text.partition("## Reproducing")
256
+ assert sep, "the card has no Reproducing section"
257
+ start = head.find(f"## The `{CONFIG}` config")
258
+ head = head[:start] if start >= 0 else head
259
+ tail = tail.split(f"\n[`{SCRIPT}`]")[0].rstrip("\n") + "\n"
260
+ return head + section(args, summary) + sep + tail + reproducing(args)
261
+
262
+
263
+ def main():
264
+ parser = argparse.ArgumentParser(description=__doc__,
265
+ formatter_class=argparse.RawDescriptionHelpFormatter)
266
+ parser.add_argument("--gold_revision", default=GOLD_REVISION,
267
+ help=f"commit of {REPO} to take the gold config from")
268
+ parser.add_argument("--generator", default=GENERATOR)
269
+ parser.add_argument("--generator_revision", default=GENERATOR_REVISION)
270
+ parser.add_argument("--judge", default=JUDGE, help="Inspect model string of the judge")
271
+ parser.add_argument("--max_connections", type=int, default=50,
272
+ help="concurrent requests to the judge")
273
+ parser.add_argument("--limit", type=int, help="only the first N gold rows (smoke test)")
274
+ parser.add_argument("--repo", default=REPO)
275
+ parser.add_argument("--push", action="store_true")
276
+ args = parser.parse_args()
277
+ if args.push and args.limit:
278
+ parser.error("--push builds the whole config, without --limit")
279
+ gold = load_dataset(args.repo, GOLD, split="test", revision=args.gold_revision)
280
+ rows = gold.to_list()[:args.limit]
281
+ items = generate(rows, args)
282
+ asyncio.run(judge(items, args.judge, args.max_connections))
283
+ for item in items:
284
+ item.update(generator=args.generator, output_length=len(item["output"]),
285
+ reference_length=len(item["reference"]))
286
+ summary = stats(items)
287
+ print(json.dumps(summary, indent=2))
288
+ if not args.push:
289
+ return
290
+ columns = ["id", "instruction", "variant", "system_prompt", "output", "generator",
291
+ "finish_reason", "output_length", "reference_length", "switched", "preference",
292
+ "judge", "judge_top_logprobs"]
293
+ Dataset.from_list([{c: item[c] for c in columns} for item in items]).push_to_hub(
294
+ args.repo, config_name=CONFIG, split="test")
295
+ pushed = DatasetCard.load(args.repo, repo_type="dataset")
296
+ # push_to_hub can drop the default flag from gold; keep gold the default config
297
+ for entry in pushed.data["configs"]:
298
+ entry.pop("default", None)
299
+ if entry["config_name"] == GOLD:
300
+ entry["default"] = True
301
+ pushed.text = with_config(pushed.text, args, summary, len(items))
302
+ api = HfApi()
303
+ api.create_commit(args.repo, repo_type="dataset", operations=[
304
+ CommitOperationAdd("README.md", str(pushed).encode()),
305
+ CommitOperationAdd(SCRIPT, Path(__file__).read_bytes()),
306
+ ], commit_message=f"Publish the {CONFIG} config's card section and the script that built it")
307
+ print(f"pushed https://huggingface.co/datasets/{args.repo} @ "
308
+ f"{api.dataset_info(args.repo).sha}")
309
+
310
+
311
+ if __name__ == "__main__":
312
+ main()