fixes, naming

This commit is contained in:
wassname
2026-05-08 15:23:54 +08:00
parent c96d02a675
commit b12770cb78
15 changed files with 1001 additions and 977 deletions
+3 -3
View File
@@ -139,8 +139,8 @@ Each vignette row includes LLM-generated multi-label ratings across all 7 founda
| Column pattern | Scale | Description |
|---|---|---|
| `llm_dominant` | string | Foundation with highest LLM score (argmax) |
| `calibrated_Care`, `calibrated_Fairness`, … | 0100% | LLM scores linearly mapped to human rater % scale |
| `calibrated_wrongness` | 15 | Wrongness mapped to human scale |
| `ai_Care`, `ai_Fairness`, … | 0100% | grok-4-fast judge, linearly rescaled to align with human-rater % scale on classic |
| `ai_wrongness` | 15 | grok wrongness rescaled to human range |
**Calibration quality** (classic set, n=132):
@@ -153,7 +153,7 @@ Each vignette row includes LLM-generated multi-label ratings across all 7 founda
| Loyalty | +0.69 | +0.75 | 9.3% |
| Authority | +0.39 | +0.69 | 11.7% |
> **Note:** Calibrated values for `scifi` and `clifford_ai` are extrapolated from the classic-set fit — treat with appropriate caution.
> **Note:** `ai_*` for `scifi` and `clifford_ai` are extrapolated from the classic-set rescale -- treat as a noisy proxy. Use `human_*` (inherited from the parent classic item) as the primary label.
## Eval
+5 -5
View File
@@ -22,7 +22,7 @@ across all 7 foundations. We use these to:
Calibration is fitted on the classic set ONLY then applied to all sets.
Non-classic sets (scifi, clifford_ai) have no human ground truth, so their
calibrated values are extrapolated treat with appropriate caution.
ai values are extrapolated -- treat with appropriate caution.
Outputs:
data/multilabel[_<name>].jsonl — one row per vignette with all ratings
@@ -450,7 +450,7 @@ async def amain(args) -> None:
continue
if cfg_name != "classic" and cal_results:
logger.warning(f"[{cfg_name}] Calibration was fitted on classic set only — "
f"calibrated values for '{cfg_name}' are extrapolated")
f"ai values for '{cfg_name}' are extrapolated")
for rec in records:
for f in FOUNDATIONS:
@@ -458,19 +458,19 @@ async def amain(args) -> None:
cal = cal_results.get(f)
if llm_v is not None and cal and not np.isnan(cal.get("slope", float("nan"))):
cal_v = cal["slope"] * llm_v + cal["intercept"]
rec[f"calibrated_{f}"] = round(max(0.0, min(100.0, float(cal_v))), 1)
rec[f"ai_{f}"] = round(max(0.0, min(100.0, float(cal_v))), 1)
w_v = rec.get("llm_wrongness")
w_cal = cal_results.get("wrongness")
if w_v is not None and w_cal and not np.isnan(w_cal.get("slope", float("nan"))):
cal_w = w_cal["slope"] * w_v + w_cal["intercept"]
rec["calibrated_wrongness"] = round(max(1.0, min(5.0, float(cal_w))), 2)
rec["ai_wrongness"] = round(max(1.0, min(5.0, float(cal_w))), 2)
out = out_path(cfg_name if cfg_name != "classic" else "")
with out.open("w") as fh:
for rec in records:
fh.write(json.dumps(rec) + "\n")
logger.info(f"[{cfg_name}] wrote {len(records)} records (with calibrated labels) to {out}")
logger.info(f"[{cfg_name}] wrote {len(records)} records (with ai labels) to {out}")
print("\n" + "=" * 60)
print("SUMMARY")
+4 -4
View File
@@ -1,6 +1,6 @@
"""Merge calibrated machine labels into the main vignette files.
"""Merge ai (grok-4-fast, post-hoc rescaled) labels into the main vignette files.
Reads `data/multilabel_<name>.jsonl` and merges the `llm_*` and `calibrated_*`
Reads `data/multilabel_<name>.jsonl` and merges the `ai_*`
columns into `data/vignettes_<name>_{other,self}_violate.jsonl`. This prepares
the files so that `05_upload_hf.py` will upload the machine labels to HuggingFace.
@@ -28,14 +28,14 @@ def main() -> None:
ml_lines = [json.loads(line) for line in ml_path.read_text().splitlines() if line.strip()]
# We extract all llm_* and calibrated_* keys
# We extract all ai_* keys
# The multilabel script only runs on other_violate by default, but the labels apply
# to the vignette ID as a whole.
extra_by_id = {}
for row in ml_lines:
extra = {}
for k, v in row.items():
if k.startswith("calibrated_") or k == "llm_dominant":
if k.startswith("ai_"):
extra[k] = v
extra_by_id[row["id"]] = extra
+3 -2
View File
@@ -9,7 +9,8 @@ Wraps `tinymfv.evaluate()`. Reports the AI-vs-label distribution match:
Labels:
classic: human_* (Clifford 2015 % distributions)
scifi / clifford_ai: calibrated_* (grok-4-fast judge, mapped to human scale)
(paraphrased sets carry the same `human_*` as their classic parent;
`ai_*` columns are available for cross-source diagnostics)
Usage:
python scripts/09_forced_choice.py --model Qwen/Qwen3-0.6B
@@ -88,7 +89,7 @@ def main() -> None:
# === Per-foundation table ===
print(f"\n=== per-foundation aggregates on {args.name} ===")
print("SHOULD: pearson_label > 0.5 on most foundations for a calibrated model")
print("SHOULD: pearson_label > 0.5 on most foundations for a well-calibrated model")
print(tabulate(out["table"], headers="keys", tablefmt="pipe", floatfmt=".3f", showindex=False))
# === Headline scalars ===