Giuliocc's picture
Publish source-aware model SDK, forty-deliverable evidence and annotated-review tooling
1f5647a verified
Raw History Blame Contribute Delete
5.84 kB
"""Register the bounded reference-span experiment before fitting any heads."""
from hashlib import sha256
import json
from pathlib import Path
HERE = Path(__file__).resolve().parent
SOURCE = HERE.parent / "context_data/local/frozen-v2"
def main():
protocol = {
"id": "doxa-basil-frozen-minilm-source-span-probe-v1", "version": 1,
"task": "Recover upstream BASIL lexical/informational marked source spans, independently per type",
"non_claims": ["Not model rationale faithfulness", "Not evidence sufficiency", "Not prejudice classification",
"Not an author-ideology or global unbiasedness detector"],
"source_revision": "4fdbc4f68d5ddae648990063cb6dd11424d96222",
"source_role_manifest_sha256": sha256((SOURCE / "split_manifest.json").read_bytes()).hexdigest(),
"role_files": {name: {"sha256": sha256((SOURCE / (name + ".jsonl")).read_bytes()).hexdigest()}
for name in ("train", "validation")},
"test_access_policy": "Do not open/encode/score test.jsonl until context_model explicitly sends LOCKED_SELECTION; record its exact message/receipt before access",
"source_roles": "Retain frozen-v2 event/source-family roles; no rerandomization or new event selection",
"target_scope": "Eligible body sentences only, titles excluded; original end-exclusive Unicode codepoint spans relative to row.text",
"label_provenance": "Actual upstream consensus spans, paper reports two annotators; individual votes unavailable; zero new DOXA human reviews",
"input_features": "Focal sentence text only; never IDs/event/outlet/date/quote/speaker/target/polarity/notes/annotation fields",
"units": {"pattern": "\\w+(?:['’]\\w+)*|[^\\w\\s]", "alignment": "original Python Unicode codepoint offsets",
"gold": "A regex token is positive for a type if it overlaps any original span of that type by at least one codepoint",
"outside_marked_span": "No marked source annotation under this task, not a universal harmless/unbiased label"},
"encoder": {"id": "sentence-transformers/all-MiniLM-L6-v2", "revision": "1110a243fdf4706b3f48f1d95db1a4f5529b4d41",
"frozen": True, "features": "L2-normalized mean last hidden state of overlapping original-offset WordPieces for each regex token",
"windows": "256 tokens, stride32; earliest complete overlapping window per token; specials/padding excluded; all tokens covered or explicitly counted",
"batch_size": 16, "cpu_threads": 1},
"probe": {"algorithm": "two independent SGDClassifier logistic heads", "alpha": 0.0001,
"max_iter": 20, "tol": None, "class_weight": "balanced", "average": True, "random_state": 1729},
"controls": ["all_negative", "all_positive", "smoothed_train_token_frequency_posterior",
"train_only_token_character_ngram_logistic (2..4, min_df3, max_features15000, same SGD settings)"],
"control_features": "Current token characters or training-only counts only; no publisher/event identity",
"threshold_selection": "For each nonconstant method/head independently select from .05,.10,...,.95 on validation token F1; tie favors higher precision then higher threshold; no test tuning",
"selection_lock": "Freeze every fitted parameter/vocabulary hash, thresholds and validation outcomes before test release; no model changes after test",
"primary_metric": "Macro mean of lexical/informational corpus-token F1 on all eligible tokens",
"other_metrics": ["per-head token precision/recall/F1 and confusion counts", "strict exact source-span F1",
"one-to-one span IoU>=.5 F1", "character overlap F1", "token/source coverage",
"source/event counts", "source-span boundary representability", "failure counts"],
"predicted_spans": "Merge contiguous positive regex tokens only across original whitespace; original first.start to last.end; keep heads separate",
"span_matching": "Exact original start/end for strict; maximum-cardinality one-to-one IoU>=.5 matching for relaxed; original annotation alternatives are not fabricated",
"uncertainty": "Paired event-cluster bootstrap, 2000 draws, seed1729; macro metrics recomputed from aggregate counts in each draw",
"technical_gate": {"token_macro_F1_gain_vs_every_fixed_control": 0.05,
"paired_95pct_lower_bound_vs_validation_selected_control": ">0",
"per_head_F1_regression_max": 0.02,
"strict_and_relaxed_span_macro_F1": ">= validation-selected control",
"regex_token_encoder_coverage_min": 0.995,
"positive_token_encoder_coverage_min": 0.99,
"all_methods_identical_evaluation_units": True},
"release_gate": "No parameters unless technical gate passes AND lead explicitly approves artifact rights. BASIL text/annotations/vocabulary never public in this task.",
"public_outputs": "Original code/protocol, aggregate results/coverage/runtime/failure summaries and rights/withholding decision only",
"private_outputs": "All BASIL text, tokens, source annotation spans/row labels, fitted lexical vocabularies, weights, embeddings and row predictions",
"paid_spend_usd": 0, "training_compute": "existing local CPU environment read-only, one CPU thread",
}
raw = json.dumps(protocol, ensure_ascii=False, indent=2) + "\n"
(HERE / "PROTOCOL.json").write_text(raw, encoding="utf-8")
(HERE / "public/PROTOCOL.json").write_text(raw, encoding="utf-8")
print(sha256(raw.encode()).hexdigest())
if __name__ == "__main__":
main()