File size: 9,745 Bytes
b98daa4 | 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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | """Frozen constants for the sparse/semantic attractor probe — see
../PROTOCOL-SPARSE.md. Pinned before any job runs.
Everything the frozen census pinned (token budget, SEQ, flow steps/seeds,
clustering threshold, count rule, colored floor, lift measurement) is
imported unchanged from `protocol.py` / `wprotocol.py`. This module adds
only:
1. the domain-dense corpus conditions (Q1) and their document rules,
2. the depth-spanning block sets for the two censused models,
3. the tail-concentration flow (Q2) — one changed ingredient, the on-set,
4. the novelty rule against the models' existing Pile libraries,
5. the pre-registered verdict rules.
Nothing here is chosen at runtime.
"""
import protocol as P # noqa: F401 (re-exported constants are used verbatim)
# ==========================================================================
# provenance: where the frozen pipeline and the Pile reference come from
CENSUS_RAW_EID = "exp_01m0rjapkveyqr5fytnhtwdzg8" # raw GPT-2 census
CENSUS_RAWNEW_EID = "exp_01m0sy4fjhefv9tv0nwz9cx1nd" # raw Pythia/Qwen census
CENSUS_WGPT2_EID = "exp_01m0tedzxhejkrq70x0pvcsay1" # whitened GPT-2 census
CENSUS_WNEW_EID = "exp_01m0xrq2h1fdertpjmkd9x80cs" # whitened Pythia/Qwen
INTERP_EID = "exp_01m0zrgczdeemty0aep579zjnx" # label/validate pipeline
# ==========================================================================
# 1. the four measures (corpus conditions)
#
# `pile` is the reference measure of every completed census; it is NOT rerun
# here — the stored per-block results are reused (identical slices, identical
# protocol). The three new conditions are built with the census's own slice
# construction: documents in dataset order, fit until >= FIT_TOKENS, held
# from the first document the fit slice never touched, both truncated to a
# multiple of SEQ. A document is a repo file / paper / conversation.
CONDITIONS = ("pile", "code", "math", "chat")
NEW_CONDITIONS = ("code", "math", "chat")
CORPORA = {
"code": dict(
hf="codeparrot/codeparrot-clean", config=None, split="train",
field="content", kind="text",
note="Python repository files; document = one file"),
"math": dict(
hf="math-ai/AutoMathText", config="arxiv-0.70-to-1.00", split="train",
field="text", kind="text",
note="arXiv papers with AutoMathText math score >= 0.70; "
"document = one paper"),
"chat": dict(
hf="HuggingFaceH4/ultrachat_200k", config="default", split="train_sft",
field="messages", kind="chat",
note="UltraChat SFT dialogues rendered as a plain-text transcript; "
"document = one conversation"),
}
# Plain-text chat rendering. Deliberately NOT a model chat template: the
# measure must be the same *text* for both tokenizer families, so the role
# markers are ordinary words rather than special tokens.
CHAT_ROLE_NAMES = {"user": "User", "assistant": "Assistant",
"system": "System"}
CHAT_TURN_SEP = "\n\n"
CHAT_ROLE_SEP = ": "
# Streaming caps: how many documents we are willing to walk per split before
# declaring the corpus too short (guards a silent short slice).
MAX_DOCS_SCAN = 200_000
MIN_DOC_CHARS = 64 # skip degenerate/empty documents
# ==========================================================================
# 2. models and blocks
#
# The two most-baselined small models, plus their random-init floors.
# Blocks span depth at fixed fractions that reproduce each census's own
# representative blocks: round(L/6), round(L/3), round(L/2), round(5L/6).
MODELS = ("gpt2", "qwen3-0.6b")
FLOOR_OF = {"gpt2": "gpt2-randinit", "qwen3-0.6b": "qwen3-0.6b-randinit"}
TAGS = ("gpt2", "gpt2-randinit", "qwen3-0.6b", "qwen3-0.6b-randinit")
BASE_OF = {"gpt2": "gpt2", "gpt2-randinit": "gpt2",
"qwen3-0.6b": "qwen3-0.6b", "qwen3-0.6b-randinit": "qwen3-0.6b"}
BLOCKS = {"gpt2": (2, 4, 6, 10), "qwen3-0.6b": (5, 9, 14, 23)}
# ==========================================================================
# 3. the tail-concentration flow (Q2)
#
# The frozen census flow ascends
# Delta(v) = E[G(v; h) | h in top-q of a_v] - E[G(v; h)]
# with q = FLOW_Q = 0.1 re-drawn inside each 1024-state batch, i.e. it
# conditions on a ~10% event. The tail flow ascends the SAME pointwise
# conductance under a rare-event conditioning: the on-set is the TAIL_M fit
# states with the largest signed projection under the CURRENT direction.
# Everything else — optimizer, learning rate, steps, batch, clamp, seeds,
# init directions, unit projection — is the frozen flow's, unchanged.
#
# TAIL_MODE selects how that on-set is found. `exact` re-selects the corpus
# top-M every step (one chunked projection of the whole fit slice; a few
# seconds over the 200 steps at census scale), so the flow ascends the
# pre-registered functional itself. `reservoir` is the cheaper persistent
# approximation the plan sketched; it only ever sees the states the flow drew
# (~40% of the corpus at this budget) and is kept as a robustness line.
TAIL_Q = 0.001 # rare-event quantile (0.1%), search and measure
TAIL_M = 399 # on-set size = max(30, round(TAIL_Q * N_fit))
# pinned for the 399,923-state census slices
# Reporting-only diagnostic (not a decision rule): how many poles concentrate
# their top-M states into fewer than N distinct held sequences. The library
# group is bimodal, so group medians are reported alongside these counts.
CONC_THRESHOLDS = (50, 100, 200)
TAIL_MODE = "exact" # production selection
TAIL_MODE_SENS = "reservoir" # robustness line, one block per model
TAIL_LIFT_Q = TAIL_Q # held-out measurement quantile for the tail arm
TAIL_STEPS = P.FLOW_STEPS # 200, frozen
TAIL_BATCH = P.FLOW_BATCH # 1024 off-set draws per step, frozen
TAIL_LR = P.FLOW_LR # 0.05, frozen
TAIL_CLAMP = P.FLOW_CLAMP # 6.0, frozen
TAIL_SEED = P.FLOW_SEED # 3, frozen (same batch stream as the raw flow)
# Concentration diagnostics measured for every accepted axis (and, as the
# comparison group, for the block's standard attractors).
CONC_TOPK = TAIL_M # states in the measured tail
CONC_SEQ = P.SEQ # a "moment" is a 127-token sequence
# ==========================================================================
# 4. novelty against the existing Pile libraries
#
# An attractor axis found here is NOVEL iff its centroid's largest absolute
# cosine against the union of the model's Pile attractor axes — raw census
# and whitened census, ALL blocks — is below JOIN_COS. The bar is the
# clustering / identity threshold used by every census in this line of work.
NOVEL_COS = 0.9 # = P.CLUSTER_COS = wprotocol.JOIN_COS
NOVEL_FRAMES = ("raw", "whitened") # reported in both; raw is primary
# Secondary (reported, not part of the rule): the join against ALL Pile
# cluster centroids, attractor or not, and against the same block only.
# ==========================================================================
# 5. exemplar extraction + labelling (interpretation pipeline, exp-8)
EXEMPLAR_TOKENS = 2_000_000 # per (family, condition), truncated to SEQ
PILE_EXEMPLAR_START_ROW = 363 # exp-8 NEW_SLICE_START_ROW (untouched rows)
LABEL_CATEGORIES = ("generic_syntactic", "domain_structural",
"semantic_topical")
CATEGORY_DESC = {
"generic_syntactic":
"domain-independent surface syntax: punctuation, sentence or line "
"boundaries, function words, word fragments, whitespace, formulaic "
"continuations — the kinds already catalogued in the Pile library.",
"domain_structural":
"structure specific to this domain's format: LaTeX environments or "
"math mode, code block/indentation/bracket structure, identifiers as "
"syntax, dialogue turn boundaries or role tags, markup.",
"semantic_topical":
"content rather than format: a topic, an entity or entity class, a "
"mathematical concept, a subject-matter category.",
}
# ==========================================================================
# 6. pre-registered verdict rules (../PROTOCOL-SPARSE.md section 6)
#
# Q1 (density). Per condition c, over the 8 cells (2 models x 4 blocks):
# n_novel(cell) = novel attractor axes in the trained model, either
# census arm, passing that block/arm's own count rule
# n_novel_floor(cell) = the same quantity for the random-init model of the
# same architecture under the same condition, joined
# against ITS OWN Pile library
# supported iff sum_cells n_novel >= 1 AND one-sided Wilcoxon signed-rank
# (trained > floor) over the 8 paired cells has p < ALPHA.
# Q1b (content). Every novel pole that earns a detection-validated label is
# categorised into LABEL_CATEGORIES by the judge; counts are reported with
# exact binomial CIs. "Semantics under a domain-dense measure" requires at
# least one validated novel pole categorised semantic_topical.
# Q2 (sparsity in time). Identical shape, with the tail census in place of
# the condition census and the Pile measure throughout.
ALPHA = 0.05
N_PERM = 10_000 # permutation draws where a permutation null is used
PERM_SEED = 42
BOOT_N = 10_000
BOOT_SEED = 42
WILCOXON_ALT = "greater" # trained > floor, one-sided
# Candidate-matched chance level for the novelty join: under a uniform random
# direction in d dimensions, cos^2 ~ Beta(1/2, (d-1)/2); the reported chance
# level is the expected maximum |cos| over the same number of library
# candidates (order statistic, Monte-Carlo with this seed).
CHANCE_SEED = 7
CHANCE_DRAWS = 20_000
|