Telasap-0.8B-v1.0 / src /macjev /eval /sources.py
pynterest83's picture
Telasap-0.8B v1.0 (exp10yc): router model + /v1/systemone server
72c7148 verified
Raw History Blame Contribute Delete
9.58 kB
"""Pinned public sources for every sealed evaluation suite.
Revisions are the dataset heads that were current when Laya produced its published numbers
(T4 notebook and CPU sweep ran 2026-09-19; every head below predates that, except
typed-decisions which changed on 2026-09-22 and is pinned to the round-1 revision). Licences
are read from each dataset card via ``macjev.download.fetch`` and cross-checked against the
values recorded here; a mismatch raises so a silently relicensed card is noticed.
All of these rows are evaluation-only (records are built with split="test").
"""
from __future__ import annotations
import gzip
import io
import json
from dataclasses import dataclass, field
from pathlib import Path
from ..download import fetch
@dataclass(frozen=True)
class Source:
repo: str
revision: str
card_license: str | None # what the dataset card says (json-dumped when it is a list)
license: str # value written into records (split="test" only)
note: str = ""
files: tuple = field(default_factory=tuple)
SOURCES: dict[str, Source] = {
"typed": Source("LocalLLaMA/typed-decisions", "ea9306458d6e9563628369a3d1e72e362fb381d2", "apache-2.0",
"apache-2.0", "round-1 pin; repo changed on 2026-09-22", ("all/test-00000-of-00001.parquet",)),
"massive_intent": Source("mteb/amazon_massive_intent", "940fd47a81eaa7f2cc7b129674d945d618ac38c2", "apache-2.0",
"cc-by-4.0", "MASSIVE is CC-BY-4.0 upstream; mteb card says apache-2.0"),
"massive_scenario": Source("mteb/amazon_massive_scenario", "58871793b91addb7c5f7afff26ccf08737fb6697", "apache-2.0",
"cc-by-4.0", "MASSIVE is CC-BY-4.0 upstream; mteb card says apache-2.0"),
"xnli": Source("facebook/xnli", "b8dd5d7af51114dbda02c0e3f6133f332186418e", None,
"cc-by-nc-4.0", "card has no licence field; XNLI is distributed CC-BY-NC-4.0 -> eval only"),
"sst5": Source("SetFit/sst5", "e51bdcd8cd3a30da231967c1a249ba59361279a3", None,
"unclear:sst5 card has no licence", "", ("test.jsonl",)),
"emotion": Source("dair-ai/emotion", "cab853a1dbdf4c42c2b3ef2173804746df8825fe", '["other"]',
"unclear:dair-ai/emotion card 'other'", "", ("split/test-00000-of-00001.parquet",)),
"prompt_injections": Source("deepset/prompt-injections", "4f61ecb038e9c3fb77e21034b22511b523772cdd", "apache-2.0",
"apache-2.0", "eval only by plan",
("data/test-00000-of-00001-701d16158af87368.parquet",)),
"ag_news": Source("fancyzhx/ag_news", "eb185aade064a813bc0b7f42de02595523103ca4", '["unknown"]',
"unclear:ag_news card 'unknown'", "", ("data/test-00000-of-00001.parquet",)),
"boolq": Source("google/boolq", "35b264d03638db9f4ce671b711558bf7ff0f80d5", '["cc-by-sa-3.0"]',
"cc-by-sa-3.0", "", ("data/validation-00000-of-00001.parquet",)),
"banking77": Source("mteb/banking77", "18072d2685ea682290f7b8924d94c62acc19c0b2", "mit", "mit", "",
("data/test-00000-of-00001.parquet",)),
"toxic_chat": Source("lmsys/toxic-chat", "29df8e4dba60e1f4af4b4075c0705c5b313548a8", "cc-by-nc-4.0",
"cc-by-nc-4.0", "NC -> eval only", ("data/0124/toxic-chat_annotation_test.csv",)),
"ms_marco": Source("microsoft/ms_marco", "a47ee7aae8d7d466ba15f9f0bfac3b3681087b3a", None,
"research-only:ms-marco terms (non-commercial research)", "card has no licence field",
("v1.1/validation-00000-of-00001.parquet",)),
"enron_spam": Source("SetFit/enron_spam", "1916f66c89d52221ae33eb57d44498b4f3a5df22", None,
"unclear:enron_spam card has no licence", "", ("test.jsonl",)),
"phishing": Source("zefang-liu/phishing-email-dataset", "34085a032c123ca237f314a01a67909cdea35e34", "lgpl-3.0",
"unclear:lgpl-3.0 (software licence on a dataset)", "", ("Phishing_Email.csv",)),
"support_tickets": Source("Tobi-Bueck/customer-support-tickets", "ddf1c81a5475992c4fa6752bf1e8b4e31f07bbeb",
"cc-by-nc-4.0", "cc-by-nc-4.0", "NC -> eval only (note: listed as a training source)",
("aa_dataset-tickets-multi-lang-5-2-50-version.csv",
"dataset-tickets-german_normalized_50_5_2.csv",
"dataset-tickets-multi-lang-4-20k.csv")),
"gsm8k": Source("openai/gsm8k", "740312add88f781978c0658806c59bc2815b9866", '["mit"]', "mit", "",
("main/test-00000-of-00001.parquet",)),
"mbpp": Source("google-research-datasets/mbpp", "4bb6404fdc6cacfda99d4ac4205087b89d32030c", '["cc-by-4.0"]',
"cc-by-4.0", "", ("full/test-00000-of-00001.parquet",)),
}
MASSIVE51 = ["af", "am", "ar", "az", "bn", "cy", "da", "de", "el", "en", "es", "fa", "fi", "fr", "he", "hi", "hu",
"hy", "id", "is", "it", "ja", "jv", "ka", "km", "kn", "ko", "lv", "ml", "mn", "ms", "my", "nb", "nl",
"pl", "pt", "ro", "ru", "sl", "sq", "sv", "sw", "ta", "te", "th", "tl", "tr", "ur", "vi", "zh-CN",
"zh-TW"]
_FETCHED: dict[str, dict] = {} # repo/file -> {revision, license, path, sha256}
def _file_for(key: str, language: str | None) -> str:
if key == "massive_intent" or key == "massive_scenario":
return f"test/{language}.json.gz"
if key == "xnli":
return f"{language}/test-00000-of-00001.parquet"
src = SOURCES[key]
if len(src.files) != 1:
raise ValueError(f"{key} has several files; pass one explicitly")
return src.files[0]
def decode_json_rows(text: str) -> list[dict]:
try:
value = json.loads(text)
except json.JSONDecodeError:
value = [json.loads(line) for line in io.StringIO(text) if line.strip()]
if isinstance(value, dict) and isinstance(value.get("data"), list):
value = value["data"]
if not isinstance(value, list) or any(not isinstance(row, dict) for row in value):
raise ValueError("unexpected JSON dataset layout")
return value
def read_rows(path: str | Path) -> list[dict]:
"""Rows in file order, the way ``datasets`` would present them."""
path = Path(path)
name = path.name
if name.endswith(".parquet"):
import pyarrow.parquet as pq
return pq.read_table(path).to_pylist()
if name.endswith(".csv"):
import pandas as pd
# datasets' csv builder is pandas.read_csv with default options; NaN becomes None.
df = pd.read_csv(path)
return [{k: (None if (isinstance(v, float) and v != v) else v) for k, v in row.items()}
for row in df.to_dict(orient="records")]
text = gzip.open(path, "rt", encoding="utf-8").read() if name.endswith(".gz") else path.read_text()
return decode_json_rows(text)
_ROWS_CACHE: dict[str, list[dict]] = {}
def _local_verified(src: Source, rel: str) -> dict | None:
"""Reuse a file ``fetch`` already downloaded at the pinned revision, re-verifying its sha256."""
from ..download import _sha256
from ..paths import DOWNLOADS
folder = DOWNLOADS / src.repo.replace("/", "--")
try:
manifest = json.loads((folder / "manifest.json").read_text())
except (OSError, ValueError):
return None
entry = manifest.get("files", {}).get(rel)
path = folder / src.revision / rel
if manifest.get("revision") != src.revision or not entry or not path.exists() or "license" not in manifest:
return None
if _sha256(path) != entry["sha256"]:
raise RuntimeError(f"hash drift for {src.repo}/{rel}")
return {"revision": src.revision, "license": manifest.get("license"), "files": {rel: str(path)}}
def load(key: str, language: str | None = None, file: str | None = None) -> list[dict]:
"""Fetch (pinned, hashed) and read one source file. Only called by sealed suite loaders."""
src = SOURCES[key]
rel = file or _file_for(key, language)
cache_key = f"{src.repo}@{src.revision}/{rel}"
if cache_key in _ROWS_CACHE:
return [dict(r) for r in _ROWS_CACHE[cache_key]]
got = _local_verified(src, rel) or fetch(src.repo, [rel], revision=src.revision)
if got["revision"] != src.revision:
raise RuntimeError(f"{src.repo}: revision drift {got['revision']} != {src.revision}")
card = got.get("license")
card = None if card in (None, "null", "") else card
if card != (src.card_license or None):
raise RuntimeError(f"{src.repo}: dataset card licence {card!r} differs from recorded {src.card_license!r}")
path = got["files"][rel]
from ..download import _sha256
_FETCHED[f"{src.repo}/{rel}"] = {"revision": src.revision, "card_license": card, "license": src.license,
"path": path, "sha256": _sha256(Path(path))}
rows = read_rows(path)
_ROWS_CACHE[cache_key] = rows
return [dict(r) for r in rows]
def fetched_files() -> dict:
return dict(_FETCHED)
def reset_fetch_log() -> None:
_FETCHED.clear()
def csv_rows_datasets_style(paths: list[str]) -> list[dict]:
"""Concatenate CSV files in sorted path order (datasets' default 'train' split inference)."""
rows: list[dict] = []
for p in sorted(paths, key=lambda x: Path(x).name):
rows.extend(read_rows(p))
return rows
__all__ = ["SOURCES", "MASSIVE51", "Source", "load", "read_rows", "fetched_files", "reset_fetch_log",
"csv_rows_datasets_style"]