Publish open router-curriculum reproducibility package
Browse files- README.md +55 -0
- REPRODUCIBILITY_MANIFEST.json +67 -0
- build_fable_router_curriculum.py +227 -0
- fable-router-curriculum.v2.json +197 -0
README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- code
|
| 5 |
+
- tool-use
|
| 6 |
+
- reasoning
|
| 7 |
+
- preference-data
|
| 8 |
+
- expert-routing
|
| 9 |
+
- reproducibility
|
| 10 |
+
- autonoma
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# Autonoma Fable router curriculum — reproducibility package
|
| 14 |
+
|
| 15 |
+
This public repository documents and reproduces the router-only curriculum for an experimental LFM2.5-2.6B Fable hybrid. It intentionally does **not** redistribute records derived from a source whose license is unknown.
|
| 16 |
+
|
| 17 |
+
## Included
|
| 18 |
+
|
| 19 |
+
- `fable-router-curriculum.v2.json`: immutable training/data policy.
|
| 20 |
+
- `build_fable_router_curriculum.py`: deterministic local builder.
|
| 21 |
+
- `REPRODUCIBILITY_MANIFEST.json`: pinned sources, input/output hashes, row counts, exclusions, and build command.
|
| 22 |
+
|
| 23 |
+
Given independently authorized access to the two public sources, these files reproduce the exact materialized artifacts by SHA-256. They also expose the split, deduplication, overflow, anti-loop, duplicate-tool, benefit-gated routing, and anti-collapse decisions for review.
|
| 24 |
+
|
| 25 |
+
## Materialized result
|
| 26 |
+
|
| 27 |
+
The internally verified build produced:
|
| 28 |
+
|
| 29 |
+
| File | Rows | SHA-256 |
|
| 30 |
+
|---|---:|---|
|
| 31 |
+
| `sft-train.jsonl` | 6,084 | `10a72911887aa642339b78c11ed12f3540ada2076a81dc13fc99566bf522bd13` |
|
| 32 |
+
| `sft-validation.jsonl` | 341 | `b2925d1699a83ea48649905a6e922e311f34e355bdbf22b0b573692358643e66` |
|
| 33 |
+
| `sft-test.jsonl` | 330 | `7ddd0e5865ba54c12d1aca9ca8b87fa078742d2a115ab56137125757ac343421` |
|
| 34 |
+
| `preference-train.jsonl` | 4,099 | `9924541e4a5b40710e14a370119d7571e71bb2f881433b6bd5807cc1c76dc8a4` |
|
| 35 |
+
|
| 36 |
+
The split unit is normalized prompt hash for reasoning data and immutable source trajectory SHA-256 for agent/coding data. No identity crosses a split. Frozen evaluation prompts and answers are excluded from the builder.
|
| 37 |
+
|
| 38 |
+
## Source policy
|
| 39 |
+
|
| 40 |
+
- [`greghavens/fable-5-coding-and-debugging-traces`](https://huggingface.co/datasets/greghavens/fable-5-coding-and-debugging-traces) at `c63e82adec30798edcbd6e1dcb0014d2b15de236` declares CC-BY-4.0.
|
| 41 |
+
- [`HelioAI/Claude-Fable-5-5500x`](https://huggingface.co/datasets/HelioAI/Claude-Fable-5-5500x) at `440267fbdb1b00a40216e7233dbce25530a0ed09` declares `license: unknown` and explicitly tells users to verify compliance before redistribution or derivative training.
|
| 42 |
+
|
| 43 |
+
Public availability is not itself a redistribution license. Accordingly, this public package contains references and reproducibility code, not copied Fable reasoning records. The materialized artifacts remain in a private companion repository pending a compatible license or a rebuild without that source.
|
| 44 |
+
|
| 45 |
+
## Reproduction
|
| 46 |
+
|
| 47 |
+
Place the pinned source files at the paths declared in the builder, provide the pinned Fable tokenizer, then run:
|
| 48 |
+
|
| 49 |
+
```bash
|
| 50 |
+
python scripts/bench/build_fable_router_curriculum.py
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
The builder rejects malformed or overlong examples, deduplicates reasoning prompts, samples cumulative agent prefixes by immutable trajectory, creates train-only anti-loop preference pairs, and writes a provenance-bound `result.json`. Final training must retokenize with the actual chat template and reject overflow above 2,048 tokens rather than truncate it.
|
| 54 |
+
|
| 55 |
+
Publication of this package does not authorize training, routing, deployment, or promotion in Autonoma.
|
REPRODUCIBILITY_MANIFEST.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "AutonomaFableRouterCurriculumReproducibility.v1",
|
| 3 |
+
"status": "public_reproducibility_package_nonrouting",
|
| 4 |
+
"nonRouting": true,
|
| 5 |
+
"trainingAuthorized": false,
|
| 6 |
+
"contract": {
|
| 7 |
+
"path": "fable-router-curriculum.v2.json",
|
| 8 |
+
"sha256": "0a0acbb0ab144b6c454f60ddbb047b00b781070992526fd5783a7d655ca514f0"
|
| 9 |
+
},
|
| 10 |
+
"sources": [
|
| 11 |
+
{
|
| 12 |
+
"repo": "HelioAI/Claude-Fable-5-5500x",
|
| 13 |
+
"revision": "440267fbdb1b00a40216e7233dbce25530a0ed09",
|
| 14 |
+
"file": "Fable-5-Distill-5500x.jsonl",
|
| 15 |
+
"sha256": "a9440e7d3c28b3fd3a41d75b7c0bc3c470bf1652a9b045c30fd4aaf74f9477e8",
|
| 16 |
+
"declaredLicense": "unknown",
|
| 17 |
+
"redistributedHere": false
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"repo": "greghavens/fable-5-coding-and-debugging-traces",
|
| 21 |
+
"revision": "c63e82adec30798edcbd6e1dcb0014d2b15de236",
|
| 22 |
+
"manifestSha256": "0ccc75412c9d3934d09e2fc8fd9b0c0d9fb2ef911ef10a7902afba60218156e2",
|
| 23 |
+
"declaredLicense": "cc-by-4.0",
|
| 24 |
+
"redistributedHere": false
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"repo": "ermiaazarkhalili/LFM2.5-2.6B-SFT-Fable5",
|
| 28 |
+
"revision": "72d68fc",
|
| 29 |
+
"file": "tokenizer.json",
|
| 30 |
+
"sha256": "695be7802a0e4b8a81048f0ff5ebb7fc811a0ba5a6be63dbb24deb5a81096f41",
|
| 31 |
+
"purpose": "admission token counts"
|
| 32 |
+
}
|
| 33 |
+
],
|
| 34 |
+
"outputs": [
|
| 35 |
+
{
|
| 36 |
+
"path": "sft-train.jsonl",
|
| 37 |
+
"rows": 6084,
|
| 38 |
+
"bytes": 24082936,
|
| 39 |
+
"sha256": "10a72911887aa642339b78c11ed12f3540ada2076a81dc13fc99566bf522bd13"
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"path": "sft-validation.jsonl",
|
| 43 |
+
"rows": 341,
|
| 44 |
+
"bytes": 1303115,
|
| 45 |
+
"sha256": "b2925d1699a83ea48649905a6e922e311f34e355bdbf22b0b573692358643e66"
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"path": "sft-test.jsonl",
|
| 49 |
+
"rows": 330,
|
| 50 |
+
"bytes": 1300315,
|
| 51 |
+
"sha256": "7ddd0e5865ba54c12d1aca9ca8b87fa078742d2a115ab56137125757ac343421"
|
| 52 |
+
},
|
| 53 |
+
{
|
| 54 |
+
"path": "preference-train.jsonl",
|
| 55 |
+
"rows": 4099,
|
| 56 |
+
"bytes": 17933901,
|
| 57 |
+
"sha256": "9924541e4a5b40710e14a370119d7571e71bb2f881433b6bd5807cc1c76dc8a4"
|
| 58 |
+
}
|
| 59 |
+
],
|
| 60 |
+
"excluded": {
|
| 61 |
+
"interaction_pattern_overflow": 759,
|
| 62 |
+
"reasoning_empty_or_overflow": 2082,
|
| 63 |
+
"verified_expert_overflow": 140
|
| 64 |
+
},
|
| 65 |
+
"splitIsolationVerified": true,
|
| 66 |
+
"frozenEvaluationRead": false
|
| 67 |
+
}
|
build_fable_router_curriculum.py
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Build deterministic, provenance-bound router training records without sealed-eval leakage."""
|
| 3 |
+
|
| 4 |
+
from __future__ import annotations
|
| 5 |
+
|
| 6 |
+
import argparse
|
| 7 |
+
from collections import defaultdict
|
| 8 |
+
from datetime import datetime, timezone
|
| 9 |
+
import hashlib
|
| 10 |
+
import json
|
| 11 |
+
from pathlib import Path
|
| 12 |
+
from typing import Any
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
ROOT = Path(__file__).resolve().parents[2]
|
| 16 |
+
REASONING = ROOT / "downloads/datasets/_acquisition/fable-reasoning-440267f/Fable-5-Distill-5500x.jsonl"
|
| 17 |
+
CODING = ROOT / "downloads/datasets/_acquisition/fable-agent-coding-c63e82a/data"
|
| 18 |
+
TOKENIZER = ROOT / "downloads/models/_acquisition/lfm25-fable5-72d68fc/tokenizer.json"
|
| 19 |
+
CONTRACT = ROOT / "config/benching/fable-router-curriculum.v2.json"
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def sha256(path: Path) -> str:
|
| 23 |
+
digest = hashlib.sha256()
|
| 24 |
+
with path.open("rb") as handle:
|
| 25 |
+
for block in iter(lambda: handle.read(1024 * 1024), b""):
|
| 26 |
+
digest.update(block)
|
| 27 |
+
return digest.hexdigest()
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def identity(text: str) -> str:
|
| 31 |
+
return hashlib.sha256(text.strip().encode("utf-8")).hexdigest()
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def stable_split(value: str) -> str:
|
| 35 |
+
bucket = int(hashlib.sha256(value.encode("utf-8")).hexdigest()[:8], 16) % 1000
|
| 36 |
+
return "train" if bucket < 900 else "validation" if bucket < 950 else "test"
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def flattened_message_text(messages: list[dict[str, Any]]) -> str:
|
| 40 |
+
chunks: list[str] = []
|
| 41 |
+
for message in messages:
|
| 42 |
+
chunks.extend([str(message.get("role") or ""), str(message.get("reasoning_content") or ""),
|
| 43 |
+
str(message.get("content") or "")])
|
| 44 |
+
for call in message.get("tool_calls") or []:
|
| 45 |
+
function = call.get("function") or {}
|
| 46 |
+
chunks.extend([str(function.get("name") or ""), str(function.get("arguments") or "")])
|
| 47 |
+
return "\n".join(chunks)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def token_count(tokenizer: Any, text: str) -> int:
|
| 51 |
+
return len(tokenizer.encode(text).ids)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def choose_shortest(rows: list[dict[str, str]], tokenizer: Any, maximum: int) -> tuple[dict[str, str] | None, int]:
|
| 55 |
+
candidates = []
|
| 56 |
+
for row in rows:
|
| 57 |
+
if not all((row.get(key) or "").strip() for key in ("prompt", "reasoning", "answer")):
|
| 58 |
+
continue
|
| 59 |
+
count = token_count(tokenizer, "\n".join([row["prompt"], row["reasoning"], row["answer"]]))
|
| 60 |
+
if count <= maximum:
|
| 61 |
+
candidates.append((count, len(row["reasoning"]) + len(row["answer"]), row))
|
| 62 |
+
if not candidates:
|
| 63 |
+
return None, 0
|
| 64 |
+
count, _, selected = min(candidates, key=lambda item: (item[0], item[1], identity(item[2]["answer"])))
|
| 65 |
+
return selected, count
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def target_message(row: dict[str, Any]) -> dict[str, Any]:
|
| 69 |
+
messages = row.get("messages") or []
|
| 70 |
+
if not messages or messages[-1].get("role") != "assistant":
|
| 71 |
+
raise ValueError("cumulative prefix does not end in an assistant target")
|
| 72 |
+
return messages[-1]
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def has_tool_target(row: dict[str, Any]) -> bool:
|
| 76 |
+
return bool(target_message(row).get("tool_calls"))
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
def select_historical_prefixes(rows: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
| 80 |
+
ordered = sorted(rows, key=lambda row: (int(row["assistant_step"]), int(row["target_message_index"])))
|
| 81 |
+
selected = []
|
| 82 |
+
first_tool = next((row for row in ordered if has_tool_target(row)), None)
|
| 83 |
+
if first_tool is not None:
|
| 84 |
+
selected.append(first_tool)
|
| 85 |
+
if not selected or selected[-1] is not ordered[-1]:
|
| 86 |
+
selected.append(ordered[-1])
|
| 87 |
+
return selected
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
def rejected_target(target: dict[str, Any]) -> tuple[str, dict[str, Any]] | None:
|
| 91 |
+
calls = target.get("tool_calls") or []
|
| 92 |
+
if calls:
|
| 93 |
+
rejected = dict(target)
|
| 94 |
+
rejected["tool_calls"] = calls + calls
|
| 95 |
+
return "duplicate_tool_call", rejected
|
| 96 |
+
content = str(target.get("content") or "").strip()
|
| 97 |
+
reasoning = str(target.get("reasoning_content") or "").strip()
|
| 98 |
+
if not content and not reasoning:
|
| 99 |
+
return None
|
| 100 |
+
rejected = dict(target)
|
| 101 |
+
if content:
|
| 102 |
+
rejected["content"] = content + "\n\n" + content
|
| 103 |
+
else:
|
| 104 |
+
rejected["reasoning_content"] = reasoning + "\n\n" + reasoning
|
| 105 |
+
return "repeated_completion", rejected
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
def write_jsonl(path: Path, rows: list[dict[str, Any]]) -> None:
|
| 109 |
+
with path.open("w", encoding="utf-8", newline="\n") as handle:
|
| 110 |
+
for row in rows:
|
| 111 |
+
handle.write(json.dumps(row, ensure_ascii=False, separators=(",", ":")) + "\n")
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
def main() -> int:
|
| 115 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 116 |
+
parser.add_argument("--output-root", type=Path)
|
| 117 |
+
parser.add_argument("--maximum-tokens-before-template", type=int, default=1900)
|
| 118 |
+
args = parser.parse_args()
|
| 119 |
+
if not 256 <= args.maximum_tokens_before_template <= 2048:
|
| 120 |
+
raise SystemExit("maximum token count must be between 256 and 2048")
|
| 121 |
+
from tokenizers import Tokenizer
|
| 122 |
+
try:
|
| 123 |
+
import polars as pl
|
| 124 |
+
except ImportError as exc:
|
| 125 |
+
raise SystemExit("polars is required") from exc
|
| 126 |
+
|
| 127 |
+
tokenizer = Tokenizer.from_file(str(TOKENIZER))
|
| 128 |
+
stamp = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ")
|
| 129 |
+
output = (args.output_root or ROOT / "downloads/audits" / f"fable-router-curriculum-data-{stamp}").resolve()
|
| 130 |
+
output.mkdir(parents=True, exist_ok=False)
|
| 131 |
+
sft: dict[str, list[dict[str, Any]]] = defaultdict(list)
|
| 132 |
+
preferences: list[dict[str, Any]] = []
|
| 133 |
+
excluded = defaultdict(int)
|
| 134 |
+
|
| 135 |
+
reasoning_groups: dict[str, list[dict[str, str]]] = defaultdict(list)
|
| 136 |
+
with REASONING.open("r", encoding="utf-8") as handle:
|
| 137 |
+
for line in handle:
|
| 138 |
+
row = json.loads(line)
|
| 139 |
+
reasoning_groups[identity(row.get("prompt") or "")].append(row)
|
| 140 |
+
for prompt_id, rows in sorted(reasoning_groups.items()):
|
| 141 |
+
chosen, tokens = choose_shortest(rows, tokenizer, args.maximum_tokens_before_template)
|
| 142 |
+
if chosen is None:
|
| 143 |
+
excluded["reasoning_empty_or_overflow"] += 1
|
| 144 |
+
continue
|
| 145 |
+
split = stable_split(prompt_id)
|
| 146 |
+
sft[split].append({
|
| 147 |
+
"schema": "AutonomaFableRouterRecord.v2", "id": f"reasoning:{prompt_id}", "split": split,
|
| 148 |
+
"lane": "host_preservation", "routerEligibility": "preserve", "lossPolicyKey": "host_preservation",
|
| 149 |
+
"messages": [{"role": "user", "content": chosen["prompt"]},
|
| 150 |
+
{"role": "assistant", "reasoning_content": chosen["reasoning"], "content": chosen["answer"]}],
|
| 151 |
+
"tokensBeforeTemplate": tokens,
|
| 152 |
+
"source": {"repo": "HelioAI/Claude-Fable-5-5500x", "revision": "440267fbdb1b00a40216e7233dbce25530a0ed09",
|
| 153 |
+
"promptSha256": prompt_id, "duplicateCandidates": len(rows)}
|
| 154 |
+
})
|
| 155 |
+
|
| 156 |
+
frames = [pl.read_parquet(path) for path in sorted(CODING.glob("*.parquet"))]
|
| 157 |
+
grouped: dict[str, list[dict[str, Any]]] = defaultdict(list)
|
| 158 |
+
for row in pl.concat(frames, how="vertical_relaxed").to_dicts():
|
| 159 |
+
grouped[str(row["source_trajectory_sha256"])].append(row)
|
| 160 |
+
for trajectory_id, rows in sorted(grouped.items()):
|
| 161 |
+
attested = [row for row in rows if row.get("model_attested") and str(row.get("verifier") or "").strip()]
|
| 162 |
+
chosen_rows = sorted(attested, key=lambda row: int(row["assistant_step"])) if attested else select_historical_prefixes(rows)
|
| 163 |
+
lane = "verified_expert" if attested else "interaction_pattern"
|
| 164 |
+
eligibility = "expert" if attested else "conditional"
|
| 165 |
+
for row in chosen_rows:
|
| 166 |
+
messages = row.get("messages") or []
|
| 167 |
+
tokens = token_count(tokenizer, flattened_message_text(messages))
|
| 168 |
+
if tokens > args.maximum_tokens_before_template:
|
| 169 |
+
excluded[f"{lane}_overflow"] += 1
|
| 170 |
+
continue
|
| 171 |
+
split = stable_split(trajectory_id)
|
| 172 |
+
record_id = f"agent:{trajectory_id}:{int(row['assistant_step'])}"
|
| 173 |
+
sft[split].append({
|
| 174 |
+
"schema": "AutonomaFableRouterRecord.v2", "id": record_id, "split": split,
|
| 175 |
+
"lane": lane, "routerEligibility": eligibility, "lossPolicyKey": lane, "messages": messages,
|
| 176 |
+
"tokensBeforeTemplate": tokens,
|
| 177 |
+
"target": {"assistantStep": int(row["assistant_step"]), "toolCall": has_tool_target(row),
|
| 178 |
+
"terminal": not has_tool_target(row)},
|
| 179 |
+
"source": {"repo": "greghavens/fable-5-coding-and-debugging-traces",
|
| 180 |
+
"revision": "c63e82adec30798edcbd6e1dcb0014d2b15de236",
|
| 181 |
+
"trajectorySha256": trajectory_id, "task": row.get("task"), "verifier": row.get("verifier"),
|
| 182 |
+
"modelAttested": bool(row.get("model_attested")), "derivation": row.get("derivation")}
|
| 183 |
+
})
|
| 184 |
+
if split == "train":
|
| 185 |
+
negative = rejected_target(target_message(row))
|
| 186 |
+
if negative:
|
| 187 |
+
kind, rejected = negative
|
| 188 |
+
preferences.append({
|
| 189 |
+
"schema": "AutonomaFableRouterPreference.v2", "id": record_id + ":" + kind,
|
| 190 |
+
"split": "train", "lane": "loop_negative", "routerEligibility": eligibility,
|
| 191 |
+
"lossPolicyKey": "loop_negative", "context": messages[:-1], "chosen": messages[-1],
|
| 192 |
+
"rejected": rejected, "negativeType": kind, "sourceRecordId": record_id
|
| 193 |
+
})
|
| 194 |
+
|
| 195 |
+
files = []
|
| 196 |
+
for split in ("train", "validation", "test"):
|
| 197 |
+
rows = sorted(sft[split], key=lambda row: row["id"])
|
| 198 |
+
path = output / f"sft-{split}.jsonl"
|
| 199 |
+
write_jsonl(path, rows)
|
| 200 |
+
files.append({"path": path.name, "rows": len(rows), "bytes": path.stat().st_size, "sha256": sha256(path),
|
| 201 |
+
"lanes": {lane: sum(row["lane"] == lane for row in rows) for lane in sorted({r["lane"] for r in rows})}})
|
| 202 |
+
preference_path = output / "preference-train.jsonl"
|
| 203 |
+
write_jsonl(preference_path, sorted(preferences, key=lambda row: row["id"]))
|
| 204 |
+
files.append({"path": preference_path.name, "rows": len(preferences), "bytes": preference_path.stat().st_size,
|
| 205 |
+
"sha256": sha256(preference_path),
|
| 206 |
+
"negativeTypes": {kind: sum(row["negativeType"] == kind for row in preferences)
|
| 207 |
+
for kind in sorted({r["negativeType"] for r in preferences})}})
|
| 208 |
+
result = {
|
| 209 |
+
"schema": "AutonomaFableRouterCurriculumBuild.v2", "status": "curriculum_built_nonrouting",
|
| 210 |
+
"nonRouting": True, "trainingAuthorized": False, "createdAt": datetime.now(timezone.utc).isoformat(),
|
| 211 |
+
"contract": {"path": str(CONTRACT), "sha256": sha256(CONTRACT)},
|
| 212 |
+
"sources": [{"path": str(REASONING), "sha256": sha256(REASONING)},
|
| 213 |
+
{"path": str(TOKENIZER), "sha256": sha256(TOKENIZER)},
|
| 214 |
+
{"path": str(CODING.parent / "dataset-manifest.json"),
|
| 215 |
+
"sha256": sha256(CODING.parent / "dataset-manifest.json")}],
|
| 216 |
+
"maximumTokensBeforeTemplate": args.maximum_tokens_before_template,
|
| 217 |
+
"finalTrainerRetokenizationRequired": True, "files": files, "excluded": dict(sorted(excluded.items())),
|
| 218 |
+
"frozenEvaluationRead": False
|
| 219 |
+
}
|
| 220 |
+
result_path = output / "result.json"
|
| 221 |
+
result_path.write_text(json.dumps(result, indent=2) + "\n", encoding="utf-8")
|
| 222 |
+
print(result_path)
|
| 223 |
+
return 0
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
if __name__ == "__main__":
|
| 227 |
+
raise SystemExit(main())
|
fable-router-curriculum.v2.json
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "AutonomaFableRouterCurriculum.v2",
|
| 3 |
+
"status": "data_contract_frozen_training_not_authorized_nonrouting",
|
| 4 |
+
"nonRouting": true,
|
| 5 |
+
"trainingAuthorized": false,
|
| 6 |
+
"goalOrder": [
|
| 7 |
+
"capability",
|
| 8 |
+
"succinctness_and_termination",
|
| 9 |
+
"expert_efficiency",
|
| 10 |
+
"throughput"
|
| 11 |
+
],
|
| 12 |
+
"immutableSources": {
|
| 13 |
+
"host": {
|
| 14 |
+
"repo": "ermiaazarkhalili/LFM2.5-2.6B-SFT-Fable5",
|
| 15 |
+
"revision": "72d68fc"
|
| 16 |
+
},
|
| 17 |
+
"reasoning": {
|
| 18 |
+
"repo": "HelioAI/Claude-Fable-5-5500x",
|
| 19 |
+
"revision": "440267fbdb1b00a40216e7233dbce25530a0ed09"
|
| 20 |
+
},
|
| 21 |
+
"agentCoding": {
|
| 22 |
+
"repo": "greghavens/fable-5-coding-and-debugging-traces",
|
| 23 |
+
"revision": "c63e82adec30798edcbd6e1dcb0014d2b15de236"
|
| 24 |
+
},
|
| 25 |
+
"selectedBanks": {
|
| 26 |
+
"path": "config/benching/fable-donor-selected-banks.v1.json",
|
| 27 |
+
"sha256": "158689cca0679423925cfe3c2eefbd6a248045ed01d2f7dad4d74e05e3ad0d81"
|
| 28 |
+
}
|
| 29 |
+
},
|
| 30 |
+
"dataPolicy": {
|
| 31 |
+
"splitIdentity": {
|
| 32 |
+
"reasoning": "sha256(trimmed prompt)",
|
| 33 |
+
"agentCoding": "source_trajectory_sha256"
|
| 34 |
+
},
|
| 35 |
+
"splitBuckets": {
|
| 36 |
+
"train": "0..899",
|
| 37 |
+
"validation": "900..949",
|
| 38 |
+
"test": "950..999"
|
| 39 |
+
},
|
| 40 |
+
"reasoningDeduplication": "retain the shortest admitted non-empty completion per normalized prompt",
|
| 41 |
+
"historicalTrajectorySampling": "at most the first tool-producing prefix plus the final prefix",
|
| 42 |
+
"attestedTrajectorySampling": "retain all verifier-attested assistant decisions",
|
| 43 |
+
"maximumTokensBeforeTemplate": 1900,
|
| 44 |
+
"finalTemplateMaximumTokens": 2048,
|
| 45 |
+
"finalTrainerMustRetokenizeAndRejectOverflow": true,
|
| 46 |
+
"frozenEvaluationIsolation": "never read sealed/frozen evaluation prompts or answers while building or training"
|
| 47 |
+
},
|
| 48 |
+
"lanes": {
|
| 49 |
+
"host_preservation": {
|
| 50 |
+
"routerEligibility": "preserve",
|
| 51 |
+
"sftWeight": 1.0,
|
| 52 |
+
"baseFableKlWeight": 1.0,
|
| 53 |
+
"expertActivityTarget": "zero unless routed loss beats frozen host by the benefit margin"
|
| 54 |
+
},
|
| 55 |
+
"verified_expert": {
|
| 56 |
+
"routerEligibility": "expert",
|
| 57 |
+
"sftWeight": 1.0,
|
| 58 |
+
"baseFableKlWeight": 0.25,
|
| 59 |
+
"requires": "model_attested=true and non-empty verifier"
|
| 60 |
+
},
|
| 61 |
+
"interaction_pattern": {
|
| 62 |
+
"routerEligibility": "conditional",
|
| 63 |
+
"sftWeight": 0.1,
|
| 64 |
+
"baseFableKlWeight": 0.5,
|
| 65 |
+
"purpose": "tool topology and recovery only; not correctness supervision"
|
| 66 |
+
},
|
| 67 |
+
"loop_negative": {
|
| 68 |
+
"routerEligibility": "inherit_positive",
|
| 69 |
+
"preferenceWeight": 0.5,
|
| 70 |
+
"purpose": "reject repeated completions and duplicate identical tool calls"
|
| 71 |
+
}
|
| 72 |
+
},
|
| 73 |
+
"routingObjective": {
|
| 74 |
+
"counterfactual": "compare frozen-host token NLL with independently explored routed token NLL; never rely only on the router's current choice",
|
| 75 |
+
"offClass": "host-only is an explicit route target when no sampled expert helps",
|
| 76 |
+
"exploration": {
|
| 77 |
+
"expertScaleDuringDiscovery": "initialize at 0.005 and cap at 0.025 so incorrect trials cannot materially override the host",
|
| 78 |
+
"oracleProbeScales": [
|
| 79 |
+
0.025,
|
| 80 |
+
0.05,
|
| 81 |
+
0.1
|
| 82 |
+
],
|
| 83 |
+
"probeIsolation": "counterfactual probe branches are detached from the served/main output; only the low-scale chosen branch can affect host logits during discovery",
|
| 84 |
+
"candidateExpertsPerEligibleToken": 4,
|
| 85 |
+
"sampling": "stratified without replacement across steps and layers, independent of router logits; half uniform coverage and half frozen-profile-prior sampling",
|
| 86 |
+
"coverageBeforePruning": "every selected expert must receive counterfactual trials on validation-eligible token classes",
|
| 87 |
+
"forcedExplorationProbability": {
|
| 88 |
+
"initial": 0.25,
|
| 89 |
+
"final": 0.05,
|
| 90 |
+
"annealSteps": 300
|
| 91 |
+
},
|
| 92 |
+
"eligibleTokenEntropyBonus": {
|
| 93 |
+
"initial": 0.01,
|
| 94 |
+
"final": 0.0,
|
| 95 |
+
"annealSteps": 300
|
| 96 |
+
},
|
| 97 |
+
"minimumEligibleRouteMass": {
|
| 98 |
+
"initial": 0.15,
|
| 99 |
+
"final": 0.0,
|
| 100 |
+
"annealSteps": 300,
|
| 101 |
+
"scope": "expert-eligible tokens only; never host-preservation tokens"
|
| 102 |
+
},
|
| 103 |
+
"positiveDiscoveryReplay": "retain positive-benefit token/expert pairs in a bounded balanced replay buffer"
|
| 104 |
+
},
|
| 105 |
+
"routerSupervision": {
|
| 106 |
+
"target": "best sampled positive-benefit expert, with host-only off as a competing class",
|
| 107 |
+
"loss": "benefit-weighted ranking/classification plus end-to-end token NLL",
|
| 108 |
+
"negativeExperts": "sampled wrong experts teach relative ranking without requiring their high-impact activation",
|
| 109 |
+
"allOffProtection": "ranking targets and the temporary eligible-token route floor provide gradients even when current router logits prefer off"
|
| 110 |
+
},
|
| 111 |
+
"benefitMarginNats": 0.02,
|
| 112 |
+
"benefitMarginSchedule": "0.0 during discovery, anneal to 0.02 nats over steps 100..300",
|
| 113 |
+
"routeActivation": "after discovery, reward only when routed NLL improves beyond the annealed margin",
|
| 114 |
+
"routeCost": {
|
| 115 |
+
"expertScaleL1": 0.015,
|
| 116 |
+
"activeExpertPenalty": 0.005,
|
| 117 |
+
"targetActiveExpertsPerEligibleToken": "1..2",
|
| 118 |
+
"schedule": "zero for the first 100 discovery steps, then linearly anneal to full weight by step 300"
|
| 119 |
+
},
|
| 120 |
+
"conditionalLoadBalance": {
|
| 121 |
+
"weight": 0.01,
|
| 122 |
+
"applyOnlyTo": "expert-eligible tokens that pass the benefit gate",
|
| 123 |
+
"neverApplyTo": [
|
| 124 |
+
"host_preservation tokens",
|
| 125 |
+
"tokens where the host-only path is equal or better"
|
| 126 |
+
]
|
| 127 |
+
},
|
| 128 |
+
"antiDeadExpert": {
|
| 129 |
+
"measurement": "usage and marginal NLL improvement per layer, expert, lane, and donor bank",
|
| 130 |
+
"minimumUse": "no global quota; require coverage only among positive-benefit eligible tokens",
|
| 131 |
+
"pruneRule": "remove experts only after completed stratified exploration finds no validation-set marginal benefit; router non-use alone is not evidence",
|
| 132 |
+
"collapseGate": "reject checkpoints that choose off for all eligible tokens while the oracle replay buffer contains positive-benefit routes"
|
| 133 |
+
}
|
| 134 |
+
},
|
| 135 |
+
"behaviorObjective": {
|
| 136 |
+
"stopBoundaryLoss": 0.25,
|
| 137 |
+
"loopUnlikelihood": 0.5,
|
| 138 |
+
"duplicateToolCallPenalty": 0.75,
|
| 139 |
+
"maximumRepeatedNgramRateRegression": 0.0,
|
| 140 |
+
"maximumMedianAnswerLengthRegression": 0.05,
|
| 141 |
+
"maximumToolCallsAcrossFrozenSuite": 24,
|
| 142 |
+
"reject": [
|
| 143 |
+
"verbatim answer repetition",
|
| 144 |
+
"duplicate identical tool calls without an intervening result",
|
| 145 |
+
"continued reasoning after a valid terminal answer",
|
| 146 |
+
"expert activation without measured token-level benefit"
|
| 147 |
+
]
|
| 148 |
+
},
|
| 149 |
+
"curriculum": [
|
| 150 |
+
{
|
| 151 |
+
"stage": "A-host-anchor",
|
| 152 |
+
"steps": 200,
|
| 153 |
+
"mixture": {
|
| 154 |
+
"host_preservation": 0.75,
|
| 155 |
+
"verified_expert": 0.2,
|
| 156 |
+
"interaction_pattern": 0.05
|
| 157 |
+
},
|
| 158 |
+
"routerScaleMaximum": 0.025
|
| 159 |
+
},
|
| 160 |
+
{
|
| 161 |
+
"stage": "B-benefit-gated-routing",
|
| 162 |
+
"steps": 600,
|
| 163 |
+
"mixture": {
|
| 164 |
+
"host_preservation": 0.3,
|
| 165 |
+
"verified_expert": 0.6,
|
| 166 |
+
"interaction_pattern": 0.1
|
| 167 |
+
},
|
| 168 |
+
"routerScaleMaximum": 0.1
|
| 169 |
+
},
|
| 170 |
+
{
|
| 171 |
+
"stage": "C-succinct-calibration",
|
| 172 |
+
"steps": 200,
|
| 173 |
+
"mixture": {
|
| 174 |
+
"host_preservation": 0.55,
|
| 175 |
+
"verified_expert": 0.35,
|
| 176 |
+
"interaction_pattern": 0.1
|
| 177 |
+
},
|
| 178 |
+
"loopNegativeRatio": 0.25,
|
| 179 |
+
"routerScaleMaximum": 0.1
|
| 180 |
+
}
|
| 181 |
+
],
|
| 182 |
+
"checkpointSelection": {
|
| 183 |
+
"order": [
|
| 184 |
+
"verified coding and tool correctness",
|
| 185 |
+
"host capability non-regression",
|
| 186 |
+
"succinctness and clean termination",
|
| 187 |
+
"expert-use efficiency",
|
| 188 |
+
"decode throughput"
|
| 189 |
+
],
|
| 190 |
+
"rejectOn": [
|
| 191 |
+
"any sealed correctness regression beyond the predeclared tolerance",
|
| 192 |
+
"loop or duplicate-tool regression",
|
| 193 |
+
"median verbosity regression above 5%",
|
| 194 |
+
"expert traffic without positive marginal validation benefit"
|
| 195 |
+
]
|
| 196 |
+
}
|
| 197 |
+
}
|