File size: 6,446 Bytes
92210b9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | #!/usr/bin/env python3
"""Rebuild the v6.1 benchmark and audit files using only the standard library."""
import hashlib
import json
import unicodedata
from collections import Counter
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
SOURCE_SHA256 = "5308a7c86264b258a98be729b322dcab4aa978086460efaccf9e88cf80aac246"
VERSION = "6.1"
def digest(data):
return hashlib.sha256(data).hexdigest()
def normalise(text):
return unicodedata.normalize("NFC", text).strip()
def write_jsonl(path, rows):
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(
"".join(json.dumps(row, ensure_ascii=False, separators=(",", ":")) + "\n" for row in rows),
encoding="utf-8",
)
def build():
source = ROOT / "source/v6.jsonl"
raw = source.read_bytes()
if digest(raw) != SOURCE_SHA256:
raise ValueError("Source differs from the frozen v6 dataset; create a new release instead.")
groups = {}
audit = []
original = []
changed_rows = 0
for line_number, line in enumerate(raw.decode("utf-8").splitlines(), 1):
if not line.strip():
continue
row = json.loads(line)
if set(row) != {"question", "answer", "decision", "reason", "scores"}:
raise ValueError(f"Unexpected source fields on line {line_number}")
if not all(isinstance(row[key], str) and row[key].strip()
for key in ("question", "answer", "decision", "reason")):
raise ValueError(f"Invalid text fields on line {line_number}")
if row["decision"] not in {"keep", "rewrite"}:
raise ValueError(f"Unexpected decision on line {line_number}")
if set(row["scores"]) != {"difficulty", "obscurity", "quality"}:
raise ValueError(f"Unexpected scores on line {line_number}")
if not all(type(value) is int and 1 <= value <= 5 for value in row["scores"].values()):
raise ValueError(f"Invalid scores on line {line_number}")
original.append(row)
question, answer = normalise(row["question"]), normalise(row["answer"])
changed_rows += (question != row["question"] or answer != row["answer"])
if question not in groups:
groups[question] = {
"id": "aussieqa-" + digest(question.encode("utf-8"))[:20],
"question": question,
"answers": [],
}
item = groups[question]
if answer not in item["answers"]:
item["answers"].append(answer)
audit.append({
"id": item["id"],
"source_version": "6",
"source_line": line_number,
"answer_index": item["answers"].index(answer),
"curation_decision": row["decision"],
"curation_reason": row["reason"],
"curation_scores": row["scores"],
})
rows = list(groups.values())
assert len(original) == 1000
assert len(rows) == 984
assert len({row["id"] for row in rows}) == len(rows), "ID collision"
assert sum(len(row["answers"]) for row in rows) == 998
# Every source answer and all curation fields must remain recoverable.
by_id = {row["id"]: row for row in rows}
for source_row, record in zip(original, audit):
item = by_id[record["id"]]
assert item["question"] == normalise(source_row["question"])
assert item["answers"][record["answer_index"]] == normalise(source_row["answer"])
assert record["curation_scores"] == source_row["scores"]
assert record["curation_decision"] == source_row["decision"]
assert record["curation_reason"] == source_row["reason"]
write_jsonl(ROOT / "data/v6.1/test.jsonl", rows)
write_jsonl(ROOT / "metadata/v6.1/curation.jsonl", audit)
question_counts = Counter(row["question"] for row in original)
manifest = {
"dataset": "Aussie-1k",
"repository": "scx-admin/aussie-1k",
"version": VERSION,
"release_date": "2026-10-13",
"source_version": "6",
"source_file_modified_date": "2025-11-18",
"language": "en-AU",
"split": "test",
"source_records": len(original),
"test_records": len(rows),
"reference_answers": sum(len(row["answers"]) for row in rows),
"answer_count_distribution": dict(sorted(Counter(len(row["answers"]) for row in rows).items())),
"source_repeated_question_groups": sum(n > 1 for n in question_counts.values()),
"merged_question_occurrences": len(original) - len(rows),
"deduplicated_question_answer_occurrences": len(original) - sum(len(row["answers"]) for row in rows),
"normalised_text_rows": changed_rows,
"source_curation_decisions": dict(sorted(Counter(row["decision"] for row in original).items())),
"source_curation_score_distributions": {
key: {str(score): sum(row["scores"][key] == score for row in original) for score in range(1, 6)}
for key in ("difficulty", "obscurity", "quality")
},
"id_algorithm": "aussieqa- + first 20 hexadecimal characters of SHA-256 of NFC-normalised, stripped UTF-8 question",
"ordering": "First occurrence of each normalised question in v6; answers in first occurrence order",
"transformations": [
"Validate source SHA-256 and record schema",
"Normalise question and answer text to Unicode NFC and strip outer whitespace (zero changes in this source)",
"Group identical normalised questions; retain every distinct normalised answer",
"Assign question-content IDs and expose only id, question, answers in the test split",
"Move original curation metadata and source line mapping into a separate audit file",
],
"files": {},
}
for relative in ("source/v6.jsonl", "data/v6.1/test.jsonl", "metadata/v6.1/curation.jsonl"):
contents = (ROOT / relative).read_bytes()
manifest["files"][relative] = {"sha256": digest(contents), "bytes": len(contents)}
target = ROOT / "metadata/v6.1/manifest.json"
target.write_text(json.dumps(manifest, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
print(json.dumps({"version": VERSION, "source_rows": len(original), "test_rows": len(rows),
"reference_answers": manifest["reference_answers"], "normalised_text_rows": changed_rows}))
if __name__ == "__main__":
build()
|