Export MFQ2 sample logprobs for N bootstrap

This commit is contained in:
wassname committed 2026-07-01 06:24:13 +08:00
1 parent 8f7067b525
commit 061ce8a4f6
4 files changed
+143

No files matched your search

+8
View File
@@ -42,7 +42,11 @@ class ItemFrameRow(TypedDict):
id: str
framing: str # forward | inverted | negated
foundation: str
sign: int
lp: list[float] # raw logprobs at the M scale tokens (presented orientation)
sample_lp: list[list[float]] # [N, scale_max] raw logprobs before BMA
sample_pmass_allowed: list[float]
sample_nll_prefill: list[float]
E: float # forward-canonicalized E toward the original statement
C: float # forward-canonicalized logit contrast
keyed_E: float
@@ -120,7 +124,11 @@ def administer(model, tok, instr: Instrument, *, batch_size: int = 36,
by_dim_frame.setdefault((r["dimension"], r["frame"]), []).append((M + 1 - E) if sign < 0 else E)
per_item_frame.append({
"id": r["id"], "framing": r["frame"], "foundation": r["dimension"],
"sign": sign,
"lp": list(map(float, r["lp"])),
"sample_lp": r["sample_lp"],
"sample_pmass_allowed": r["sample_pmass_allowed"],
"sample_nll_prefill": r["sample_nll_prefill"],
"E": E, "C": Cval,
"keyed_E": (M + 1 - E) if sign < 0 else E,
"keyed_C": -Cval if sign < 0 else Cval,
+3
View File
@@ -117,6 +117,9 @@ def read_items(model, tok, instr: Instrument, items: list[InstrItem], answer_ids
out.append({
"id": it.id, "frame": it.frame,
"lp": lp, # raw logprobs at the M scale tokens
"sample_lp": sample_lp.tolist(), # [N,A] raw logprobs before BMA
"sample_pmass_allowed": [float(s["pmass_allowed"]) for s in sample_slots],
"sample_nll_prefill": [float(s["nll_prefill"]) for s in sample_slots],
"p": p_norm,
"pmass_allowed": pmass,
"dimension": it.dimension, "sign": it.sign,