prabodbc commited on
Commit
d7f4f7c
·
verified ·
1 Parent(s): 38dfd77

Trim the card; the builder writes the JSONL prompts only

Browse files
README.md CHANGED
@@ -17,20 +17,15 @@ configs:
17
 
18
  # Quant fidelity eval (public sources)
19
 
20
- This dataset holds prompts for measuring how closely a quantized model reproduces its full-precision original. All 240
21
- prompts come from seven public datasets.
22
 
23
- The measurement is per-token KL divergence between the original model and the quantized one. It is computed on two
24
- kinds of text:
 
25
 
26
- - **`on_policy`** (140 prompts): the original model continues each prompt greedily, here for 512 tokens. Each quant is
27
- then scored on that same text.
28
- - **`forced`** (100 prompts): the dataset's own assistant turn is fed to both models (teacher forcing), here up to 768
29
- tokens. The turns include reasoning, code edits and tool calls.
30
-
31
- Prompts are stored as chat messages and are rendered with the evaluated model's own chat template when the reference
32
- is frozen. A prompt with `forced_turn: true` ends in the assistant turn to force; every other prompt ends where the
33
- assistant should reply.
34
 
35
  ## Sources
36
 
@@ -44,60 +39,17 @@ assistant should reply.
44
  | openhands | [SWE-Gym/OpenHands-SFT-Trajectories](https://huggingface.co/datasets/SWE-Gym/OpenHands-SFT-Trajectories), `train.success.oss` | MIT | 20 | 20 |
45
  | glaive_fc | [glaiveai/glaive-function-calling-v2](https://huggingface.co/datasets/glaiveai/glaive-function-calling-v2) | Apache-2.0 | 20 | 15 |
46
 
47
- The prompt text belongs to these datasets and is used here for evaluation only. Their licences and attribution terms
48
- apply.
49
-
50
- ## Selection
51
-
52
- Selection is deterministic, so anyone can rebuild the set with `build_public.py`.
53
-
54
- - **Pinned revisions.** Each dataset is read at the revision recorded in `public_manifest.json`.
55
- - **Order.** Rows are read in a seeded streaming shuffle (seed 0, buffer 5000). OpenHands is read in file order.
56
- - **Quotas.** Rows fill the on-policy quota first, then the forced quota. Each row is used at most once.
57
- - **Cut point.** The turn to cut at, or to force, is `sha256(source, row id, set) mod (number of eligible turns)`.
58
- - **Eligible turns.** At most 24,000 characters of context may come before the cut. A forced turn must be at least
59
- 800 characters for chat sources, 400 for the agent trajectories and 150 for function calling.
60
- - **Format conversions.**
61
- - SWE-agent: `ai` turns become assistant messages.
62
- - Glaive: `FUNCTION RESPONSE` turns become user messages prefixed "Function response:".
63
-
64
- `public_manifest.json` lists, for every prompt, the dataset, revision, split, row id and turn index.
65
-
66
- ## Files
67
-
68
- | File | Contents |
69
- | --- | --- |
70
- | `public_on_prompts.jsonl`, `public_off_prompts.jsonl` | One prompt per line: `id`, `category`, `messages` and, for forced prompts, `forced_turn` |
71
- | `public_on_prompts.json`, `public_off_prompts.json` | The same prompts in the prompt-file format the autoadd v2 reference freezer reads |
72
- | `public_manifest.json` | How each prompt was selected |
73
- | `build_public.py` | The builder |
74
 
75
  ## Usage
76
 
77
- 1. **Freeze the references.** Freeze the original model's outputs once, for example with autoadd v2:
78
-
79
- ```
80
- autoadd_ref.py --hf-model <bf16 checkpoint> --out-dir <dir> \
81
- --set public_on=public_on_prompts.json:512:floor=0 \
82
- --set public_off=public_off_prompts.json:768:floor=0
83
- ```
84
-
85
- 2. **Score each quant.** Score with autoquant v2:
86
-
87
- ```
88
- python -m autoquant.eval.measure measure --engine gguf --model <quant.gguf> \
89
- --goldens <dir>/reference_public_on.json --logprob-dir <dir>/ref_logprobs_public_on \
90
- --off-goldens <dir>/reference_public_off.json --off-logprob-dir <dir>/ref_logprobs_public_off --out result.json
91
- ```
92
-
93
- 3. **Compare.** Report the pooled mean, p50, p99 and max KL. Bootstrap over prompts, not tokens: tokens within one
94
- prompt are strongly correlated.
95
 
96
- ## Caveats
97
 
98
- - **Frozen references are not included.** References depend on the model and the hardware, and their log-prob rows are
99
- tens of GB. Freeze your own.
100
- - **The base model may have seen these datasets in training.** That does not affect a comparison between quants of the
101
- same model, because KL measures only how faithfully each quant reproduces the original.
102
- - **UltraChat KL is unusually high** for every quant we have measured, about 10× the other sources. It is still being
103
- investigated, so report results both with and without it.
 
17
 
18
  # Quant fidelity eval (public sources)
19
 
20
+ 240 prompts from seven public datasets for measuring how closely a quantized model reproduces its original, as
21
+ per-token KL divergence.
22
 
23
+ - **`on_policy`** (140): the original model continues each prompt greedily for 512 tokens; each quant is scored on
24
+ that text.
25
+ - **`forced`** (100): the prompt's final assistant turn (`forced_turn: true`) is fed to both models, up to 768 tokens.
26
 
27
+ Each line holds `id`, `category`, `messages` and `forced_turn`. Render the messages with the evaluated model's chat
28
+ template.
 
 
 
 
 
 
29
 
30
  ## Sources
31
 
 
39
  | openhands | [SWE-Gym/OpenHands-SFT-Trajectories](https://huggingface.co/datasets/SWE-Gym/OpenHands-SFT-Trajectories), `train.success.oss` | MIT | 20 | 20 |
40
  | glaive_fc | [glaiveai/glaive-function-calling-v2](https://huggingface.co/datasets/glaiveai/glaive-function-calling-v2) | Apache-2.0 | 20 | 15 |
41
 
42
+ The prompt text belongs to these datasets; their licences and attribution terms apply.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
  ## Usage
45
 
46
+ 1. Freeze the original model's log-probabilities at every continuation position (greedy for `on_policy`, the given
47
+ turn for `forced`).
48
+ 2. Run each quant on the same tokens and compute KL(original ‖ quant) per token.
49
+ 3. Report the pooled mean, p50, p99 and max, and bootstrap over prompts rather than tokens.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
+ ## Rebuilding
52
 
53
+ `python build_public.py <out dir>` (needs `datasets` and `huggingface_hub`) rebuilds the set exactly: pinned
54
+ revisions, a seeded shuffle and hash-chosen cut points. `public_manifest.json` records the source row and turn of every
55
+ prompt.
 
 
 
build_public.py CHANGED
@@ -1,5 +1,12 @@
1
- """Public goldens prompt sets for quant fidelity (no internal data). Deterministic: pinned revisions, seeded
2
- streaming shuffle, hash-chosen cut points. Writes autoadd-format prompt files + a publishable manifest."""
 
 
 
 
 
 
 
3
  import hashlib, json, re, sys
4
  from datasets import load_dataset
5
  OUT = sys.argv[1]; SEED = 0; MAX_PREFIX = 24000
@@ -45,7 +52,7 @@ def norm_glaive(r):
45
  elif tag == "ASSISTANT:": msgs.append({"role": "assistant", "content": body})
46
  else: msgs.append({"role": "user", "content": "Function response: " + body})
47
  return hashlib.sha256((r["system"] + r["chat"]).encode()).hexdigest()[:16], msgs
48
- SOURCES = [ # name, repo, revision, split, normaliser, greedy quota, forced quota, min forced chars, shuffle
49
  ("ultrachat", "HuggingFaceH4/ultrachat_200k", "8049631c40", "test_sft", norm_ultrachat, 20, 15, 800, True),
50
  ("openhermes", "teknium/OpenHermes-2.5", "b820378210", "train", norm_hermes, 20, 15, 800, True),
51
  ("tulu3", "allenai/tulu-3-sft-mixture", "b14afda60f", "train", norm_tulu, 25, 15, 800, True),
@@ -81,11 +88,12 @@ for name, repo, rev, split, norm, qg, qf, minf, shuf in SOURCES:
81
  off.append({"id": f"{name}-{nf:02d}", "category": name, "messages": msgs[:k + 1], "forced_turn": True})
82
  manifest.append({"set": "public_off", "id": f"{name}-{nf:02d}", "dataset": repo, "revision": full_rev, "split": split, "row_id": rid, "forced_message": k}); nf += 1
83
  print(f"{name}: greedy {ng}/{qg} forced {nf}/{qf} (rows read {seen})", flush=True)
84
- for fname, ents, what in (("public_on_prompts.json", on, "greedy BF16 continuation, 512 tokens"),
85
- ("public_off_prompts.json", off, "forced dataset assistant turn, up to 768 tokens")):
86
- json.dump({"comment": f"public quant-fidelity set: {what}. Sources and selection in public_manifest.json.",
87
- "key_tokenizer": True, "prompts": ents}, open(f"{OUT}/{fname}", "w"), ensure_ascii=False, indent=1, sort_keys=True)
88
  json.dump({"seed": SEED, "max_prefix_chars": MAX_PREFIX, "selection": "seeded streaming shuffle (buffer 5000) except OpenHands; "
89
- "rows in order fill the greedy quota first, then forced; cut point = sha256(source, row id, set) mod candidates; Tulu WildChat rows excluded",
 
90
  "prompts": manifest}, open(f"{OUT}/public_manifest.json", "w"), indent=1)
91
  print("on", len(on), "off", len(off))
 
1
+ """Builds the quant-fidelity prompt sets from public datasets.
2
+
3
+ usage: python build_public.py <out dir>
4
+
5
+ Selection is deterministic: each dataset is read at a pinned revision in a seeded streaming shuffle, rows fill the
6
+ on-policy quota and then the forced quota, and the turn to cut at is chosen by hash. Writes public_on_prompts.jsonl,
7
+ public_off_prompts.jsonl and public_manifest.json.
8
+ """
9
+
10
  import hashlib, json, re, sys
11
  from datasets import load_dataset
12
  OUT = sys.argv[1]; SEED = 0; MAX_PREFIX = 24000
 
52
  elif tag == "ASSISTANT:": msgs.append({"role": "assistant", "content": body})
53
  else: msgs.append({"role": "user", "content": "Function response: " + body})
54
  return hashlib.sha256((r["system"] + r["chat"]).encode()).hexdigest()[:16], msgs
55
+ SOURCES = [ # name, repo, revision, split, normaliser, on-policy quota, forced quota, min forced chars, shuffle
56
  ("ultrachat", "HuggingFaceH4/ultrachat_200k", "8049631c40", "test_sft", norm_ultrachat, 20, 15, 800, True),
57
  ("openhermes", "teknium/OpenHermes-2.5", "b820378210", "train", norm_hermes, 20, 15, 800, True),
58
  ("tulu3", "allenai/tulu-3-sft-mixture", "b14afda60f", "train", norm_tulu, 25, 15, 800, True),
 
88
  off.append({"id": f"{name}-{nf:02d}", "category": name, "messages": msgs[:k + 1], "forced_turn": True})
89
  manifest.append({"set": "public_off", "id": f"{name}-{nf:02d}", "dataset": repo, "revision": full_rev, "split": split, "row_id": rid, "forced_message": k}); nf += 1
90
  print(f"{name}: greedy {ng}/{qg} forced {nf}/{qf} (rows read {seen})", flush=True)
91
+ for fname, prompts in (("public_on_prompts.jsonl", on), ("public_off_prompts.jsonl", off)):
92
+ with open(f"{OUT}/{fname}", "w") as handle:
93
+ for prompt in prompts:
94
+ handle.write(json.dumps({**prompt, "forced_turn": prompt.get("forced_turn", False)}, ensure_ascii=False) + "\n")
95
  json.dump({"seed": SEED, "max_prefix_chars": MAX_PREFIX, "selection": "seeded streaming shuffle (buffer 5000) except OpenHands; "
96
+ "rows in order fill the on-policy quota first, then forced; cut point = sha256(source, row id, set) mod candidates; "
97
+ "Tulu WildChat rows excluded",
98
  "prompts": manifest}, open(f"{OUT}/public_manifest.json", "w"), indent=1)
99
  print("on", len(on), "off", len(off))
public_manifest.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "seed": 0,
3
  "max_prefix_chars": 24000,
4
- "selection": "seeded streaming shuffle (buffer 5000) except OpenHands; rows in order fill the greedy quota first, then forced; cut point = sha256(source, row id, set) mod candidates; Tulu WildChat rows excluded",
5
  "prompts": [
6
  {
7
  "set": "public_on",
 
1
  {
2
  "seed": 0,
3
  "max_prefix_chars": 24000,
4
+ "selection": "seeded streaming shuffle (buffer 5000) except OpenHands; rows in order fill the on-policy quota first, then forced; cut point = sha256(source, row id, set) mod candidates; Tulu WildChat rows excluded",
5
  "prompts": [
6
  {
7
  "set": "public_on",
public_off_prompts.json DELETED
The diff for this file is too large to render. See raw diff
 
public_on_prompts.json DELETED
The diff for this file is too large to render. See raw diff