Update chatcode/data.py
Browse files- chatcode/data.py +16 -1
chatcode/data.py
CHANGED
|
@@ -8,6 +8,7 @@ import random
|
|
| 8 |
import re
|
| 9 |
|
| 10 |
from .runtime import CONFIG
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
def normalize_messages(row):
|
|
@@ -111,6 +112,19 @@ def prepare(args):
|
|
| 111 |
raise RuntimeError(f"Not enough usable data for {source['config']}: {dict(counts)}")
|
| 112 |
stats[source["config"]] = {"selected": dict(counts), "skipped": dict(skipped)}
|
| 113 |
print(source["config"], dict(counts), flush=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
output.mkdir(parents=True, exist_ok=True)
|
| 115 |
hashes = {}
|
| 116 |
for split, rows in result.items():
|
|
@@ -119,8 +133,9 @@ def prepare(args):
|
|
| 119 |
(output / f"{split}.jsonl").write_bytes(content.encode("utf-8"))
|
| 120 |
hashes[split] = hashlib.sha256(content.encode()).hexdigest()
|
| 121 |
manifest = {"config": CONFIG, "counts": {k: len(v) for k, v in result.items()},
|
|
|
|
| 122 |
"sources": stats, "sha256": hashes,
|
| 123 |
-
"split_policy": "
|
| 124 |
"limitations": ["Synthetic data may contain mistakes.",
|
| 125 |
"Exact prompt deduplication is not semantic or repository-level decontamination.",
|
| 126 |
"The pretrained base may already have seen these data.",
|
|
|
|
| 8 |
import re
|
| 9 |
|
| 10 |
from .runtime import CONFIG
|
| 11 |
+
from .articles import behavior_examples
|
| 12 |
|
| 13 |
|
| 14 |
def normalize_messages(row):
|
|
|
|
| 112 |
raise RuntimeError(f"Not enough usable data for {source['config']}: {dict(counts)}")
|
| 113 |
stats[source["config"]] = {"selected": dict(counts), "skipped": dict(skipped)}
|
| 114 |
print(source["config"], dict(counts), flush=True)
|
| 115 |
+
behavior_path = Path(__file__).with_name("article_examples.json")
|
| 116 |
+
for split, rows in behavior_examples().items():
|
| 117 |
+
for row in rows:
|
| 118 |
+
encode_example(tokenizer, row["messages"], CONFIG["max_sequence_length"])
|
| 119 |
+
key = prompt_key(row["messages"])
|
| 120 |
+
if key in seen:
|
| 121 |
+
raise ValueError("Article behavior prompt duplicates a selected Hub prompt.")
|
| 122 |
+
seen.add(key)
|
| 123 |
+
row.update({"id": hashlib.sha256(json.dumps(row["messages"], sort_keys=True).encode()).hexdigest(),
|
| 124 |
+
"prompt_hash": key})
|
| 125 |
+
result[split].append(row)
|
| 126 |
+
stats["authored-article-behavior"] = {"selected": {k: len(v) for k, v in behavior_examples().items()},
|
| 127 |
+
"license": "GPL-3.0-only", "fictional": True}
|
| 128 |
output.mkdir(parents=True, exist_ok=True)
|
| 129 |
hashes = {}
|
| 130 |
for split, rows in result.items():
|
|
|
|
| 133 |
(output / f"{split}.jsonl").write_bytes(content.encode("utf-8"))
|
| 134 |
hashes[split] = hashlib.sha256(content.encode()).hexdigest()
|
| 135 |
manifest = {"config": CONFIG, "counts": {k: len(v) for k, v in result.items()},
|
| 136 |
+
"article_examples_sha256": hashlib.sha256(behavior_path.read_bytes()).hexdigest(),
|
| 137 |
"sources": stats, "sha256": hashes,
|
| 138 |
+
"split_policy": "Hub: hash of normalized first user question. Article behavior: source-packet groups. Official source test splits unused.",
|
| 139 |
"limitations": ["Synthetic data may contain mistakes.",
|
| 140 |
"Exact prompt deduplication is not semantic or repository-level decontamination.",
|
| 141 |
"The pretrained base may already have seen these data.",
|