ScoutRoute / phase1 /README.md
Raj-deep's picture
Upload 28 files
c950b9e verified
|
Raw History Blame Contribute Delete
5.46 kB

Phase 1 β€” Calibration study (earlier work)

The exploratory study that preceded the main pipeline in ../src/. It asked whether an expert's stated (verbalised) confidence or its answer-token confidence is a better routing signal, then prototyped routers and a cascade on top of the answer. The main project then moved to internal logit and hidden-state signals only. Read Known issues before relying on any of the stated-confidence numbers here.

Scope: 5 experts Γ— 344 questions = 1,720 (expert, question) rows, across 4 domains: math, code, commonsense, knowledge.

Layout

phase1/
β”œβ”€β”€ notebooks/
β”‚   β”œβ”€β”€ 01_calibration_data_collection.ipynb   # Kaggle: prompts, scoring, resumable collection loop
β”‚   └── 02_calibration_analysis.ipynb          # Colab: re-scoring, ECE, routers, cascade simulation
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ calibration_dataset.csv                # combined dataset, as first collected
β”‚   β”œβ”€β”€ calibration_dataset_fixed.csv          # same, after re-scoring math answers
β”‚   β”œβ”€β”€ checkpoints_stated_conf/               # per-expert raw output + verbalised confidence
β”‚   β”œβ”€β”€ checkpoints_logprob/                   # per-expert raw output + answer-token confidence
β”‚   └── _done_pairs.json                       # resume state: (expert, qid) pairs already completed
└── results/
    β”œβ”€β”€ phase02_calibration.csv                # ECE + calibration gap per expert Γ— domain
    └── phase05_cascade_simulation.csv         # escalation-threshold sweep

What each piece is

File Contents
01_calibration_data_collection.ipynb Self-probing and multi-step prompt templates, per-domain scoring, checkpointed collection loop, and the step that combines per-expert checkpoints into the final dataset.
02_calibration_analysis.ipynb Math re-scoring (boxed-answer extraction fix), then Phases 02–05: ECE and calibration gap for both confidence signals, a question β†’ best-expert competence predictor, a class-balanced router, per-expert confidence regressors as router features, a no-ML domain-rule baseline, and a retrospective cascade simulation.
calibration_dataset.csv One row per (expert, question): prediction, ground truth, correctness, stated_confidence, and the answer-token confidences model_answer_confidence / model_answer_min_confidence.
calibration_dataset_fixed.csv Same schema after math re-scoring. 30 math rows flip to correct; overall accuracy goes from 0.494 to 0.512. Use this one for analysis.
checkpoints_stated_conf/*.csv Per-expert raw answers with stated_confidence.
checkpoints_logprob/*.csv Per-expert raw answers with answer-token confidence columns.
phase02_calibration.csv Columns: expert, domain, n, accuracy, mean_stated_conf, mean_logit_conf, ece_stated, ece_logit, gap_stated, gap_logit. See Known issues for how n relates to the stated-confidence columns.
phase05_cascade_simulation.csv Columns: threshold, escalate_rate, routed_acc. Always call a generalist first, escalate to the specialist when calibrated confidence falls below threshold. Routed accuracy sits at 0.718 with no escalation and peaks at about 0.735 around threshold = 0.65 (roughly 7.6% of queries escalated).

Known issues

Stated confidence is mostly missing from the combined dataset. stated_confidence is filled for only 482 of the 1,720 rows in calibration_dataset.csv / calibration_dataset_fixed.csv, yet the per-expert files in checkpoints_stated_conf/ hold 1,318 filled values. The 836 values that never reached the combined file are all code (591) and math (245) rows; where both files have a value, they agree. Rows per expert with a stated confidence, in the combined file:

Domain (questions) Rows with stated_confidence per expert
code (164) 2–6
math (60) 11
knowledge (60) 21–60
commonsense (60) 2–60

Effect on results/phase02_calibration.csv. The n column counts every row for that expert and domain, but mean_stated_conf, ece_stated and gap_stated use only the rows that have a stated confidence, and are compared against accuracy over all rows. For phi-3-mini-4k-instruct on code, for example, n is 164 while the stated-confidence average rests on 6 rows. Treat the stated-confidence columns as unreliable for code and math until the combine step is re-run with all stated confidences merged back in. The answer-token confidence columns (model_answer_confidence, model_answer_min_confidence) are complete.

Expert naming

Phase 1 files and the expert column use HuggingFace-style slugs; the main pipeline uses short model keys.

Phase 1 slug Main-pipeline key
qwen2.5-1.5b-instruct qwen25_1b
qwen2.5-3b-instruct qwen25_3b
phi-3-mini-4k-instruct phi3_mini
qwen2.5-math-1.5b-instruct qwen25_math
qwen2.5-coder-1.5b-instruct qwen25_coder

Running the notebooks

Both notebooks were written for hosted runtimes: 01_… for Kaggle (it reads and writes /kaggle/working) and 02_… for Colab (it reads CSVs from the working directory, e.g. calibration_dataset_fixed.csv and phase02_calibration.csv). To rerun locally, place those files next to the notebook or adjust the paths in the first cells.