text stringclasses 4
values |
|---|
torch>=2.1 |
transformers>=4.45 |
numpy |
tqdm |
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Student Simulation v7
A clean rewrite for a single goal: find the monitoring (reflection / self-correction) dimension in Qwen3-30B-A3B-Thinking and expose a single α ∈ [0, 1] knob that smoothly slides between "full reflection" (α=1) and "no reflection" (α=0) at inference time.
What's different from reflection_4 (and why)
reflection_project_4 worked on a dense Qwen-2.5 7B model. v7 keeps its pipeline almost verbatim — patterns, decision-point labeling, projection- removal hook math, multi-layer co-application at inference, monotonic- sweep gate for KEEP/SKIP — and changes ONE thing:
| Stage | reflection_4 | v7 |
|---|---|---|
| Direction | mean-diff over hidden states | top-K expert selection → PCA on pos-vs-neg → expert-aware coordinate mask → ortho |
The change is forced by the MoE architecture. Qwen3-30B-A3B has 128 experts per layer with top-8 routing, and only a handful of experts fire disproportionately on monitoring-positive tokens. Mean-diff over the full hidden state averages signal with noise from irrelevant experts. v7's direction extraction:
- Top-K expert selection (Stage A): score each expert at each layer
by
E_pos[gate_prob] - E_neg[gate_prob], keep the top K=16. - PCA on pos-vs-neg (Stage B): top 2 principal axes of the
[h_pos - μ_neg ; h_neg - μ_neg]matrix at each layer. - Expert coordinate mask (Stage C): weight each PC's coordinates by the L1 norm of the selected experts' input projections at that coordinate.
- Orthogonalize against general direction (Stage D), then Gram-Schmidt the surviving components.
Everything else is reflection_4: the regex patterns, the decision-point labeling (5 tokens before / 2 tokens after each trigger), the projection-removal hook, the multi-layer co-application at inference, the monotonic-sweep KEEP/SKIP gate.
Pipeline
01: label + capture ~1.5 h
02: build directions ~10 min (CPU PCA, expert mask, ortho)
03: calibrate ~10-14 h (per-layer × 3 strengths × 20 problems)
04: infer (deliverable) ~30 min (3 problems × 4 alphas)
--------
~12-16 h
Running
# Interactive (default GPU 6):
bash runall.sh
# Specific GPU:
CUDA_VISIBLE_DEVICES=3 bash runall.sh
# Single stage for debugging:
STAGES=04 bash runall.sh
# Slurm:
sbatch slurm/run-v7.sbatch
Reading the outputs
In order:
data/checkpoints/directions_summary.json— Stage 02 result. Look atn_layers_with_direction(should be 15-19 of 19 target layers) anddiagnostics.<L>.var_explained(top PC should explain >5% of variance).data/checkpoints/monitoring_calibration_v7.json— Stage 03 result.kept_layersis the multi-layer set that passed the monotonic gate. If it's empty, the direction either has no causal effect or side-effect rate is too strict; relax--side-effect-rate 0.15and rerun stage 03.data/results/alpha_comparison_v7.json— Stage 04 deliverable. Each record is(problem, alpha, cot, monitoring_total, repetition_score). For each problem, you should seemonitoring_totaldecrease as α goes from 1.0 → 0.0 with nocollapsed: truealong the way.
Key configuration
configs/monitoring.pycontrols dimension-specific hyperparameters.SWEEP_ALPHAS = [0.0, 0.3, 0.7, 1.0]per user spec.configs/paths.pycontrols all I/O paths.MODEL_PATHandRAW_COTS_PATHdefault to the v6 install but can be overridden via env.
- Downloads last month
- -