| """Monitoring dimension config — v8b (dense Qwen3-8B). |
| |
| PATTERNS define the 5 metacognition-theory families (backtrack, verify, |
| uncertainty, self_correct, strategy_switch). They are used by |
| BehaviorDetector at evaluation time (stages 03/04) ONLY. The steering |
| DIRECTION itself is learned via contrastive prompting in stage 00, NOT |
| via these regexes. |
| |
| TARGET_LAYERS: |
| Qwen3-8B is a DENSE transformer with 36 blocks (L0..L35), hidden 4096, |
| no MoE. We sweep L2..L35 (skip the first two embedding-dominated |
| layers). Stage 03 keeps a per-layer cache and [resume]s any layer it |
| already calibrated, so an interrupted job only recomputes new layers. |
| """ |
|
|
| NAME = "monitoring" |
|
|
| |
| PATTERNS = { |
| |
| "backtrack": [ |
| r"(?i)\bwait\b[,.]?\s", |
| r"(?i)\bactually\b[,.]?\s", |
| r"(?i)\bhmm\b", |
| r"(?i)\b(no|hmm)[,.]?\s+that('?s|\s+is)\s+(not|wrong|incorrect)", |
| r"(?i)\blet\s+me\s+(reconsider|rethink|redo|go\s+back|re-?examine)", |
| r"(?i)\b(going|go)\s+back\s+to", |
| r"(?i)\bthis\s+(is|was)\s+(wrong|incorrect|not\s+right)", |
| r"(?i)\bthat\s+doesn'?t\s+(work|seem\s+right|make\s+sense)", |
| r"(?i)\bbut\s+wait", |
| r"(?i)\boh\s+wait", |
| r"(?i)\bhold\s+on", |
| r"(?i)\bon\s+second\s+thought", |
| r"(?i)\bscratch\s+that", |
| r"(?i)\bnever\s+mind", |
| ], |
| |
| "verify": [ |
| r"(?i)\blet\s+me\s+(check|verify|confirm|double[- ]?check|validate)", |
| r"(?i)\bto\s+(check|verify|confirm)\b", |
| r"(?i)\b(double-?)?check\s+(this|that|my|the)", |
| r"(?i)\bsubstitut(e|ing)\s+(back|into|this)", |
| r"(?i)\bplug(ging)?\s+(back\s+)?(in|into)\b", |
| r"(?i)\bsanity\s+check", |
| r"(?i)\bdoes\s+(this|that)\s+(make\s+sense|check\s+out|hold|work)", |
| r"(?i)\bis\s+(this|that)\s+(right|correct)", |
| r"(?i)\blet\s+me\s+make\s+sure", |
| r"(?i)\blet\s+me\s+test", |
| r"(?i)\bcross-?check", |
| r"(?i)\bvalidate(d|s)?\b", |
| ], |
| |
| "uncertainty": [ |
| r"(?i)\bnot\s+(entirely|completely|fully|quite)?\s*sure\b", |
| r"(?i)\bunsure\b", |
| r"(?i)\bi'?m\s+not\s+(entirely|completely|fully)?\s*(sure|certain)\b", |
| r"(?i)\bperhaps\b", |
| r"(?i)\bmaybe\b", |
| r"(?i)\bpossibly\b", |
| r"(?i)\bi\s+(wonder|suspect)\s+(if|whether)", |
| r"(?i)\bi\s+(think|guess|believe)\b", |
| r"(?i)\bi'?m\s+guessing\b", |
| r"(?i)\bcould\s+be\b", |
| r"(?i)\bmight\s+be\b", |
| r"(?i)\bseems?\s+(like|to\s+be)\b", |
| r"(?i)\bappears?\s+to\b", |
| r"(?i)\bif\s+i'?m\s+(right|correct|not\s+mistaken)", |
| r"(?i)\bunless\s+i'?m\s+mistaken", |
| ], |
| |
| "self_correct": [ |
| r"(?i)\bi\s+(must|might|may)\s+have\s+(made|been\s+making)\s+(a\s+|an\s+)?(mistake|error)", |
| r"(?i)\bi\s+(made|have)\s+a?\s*(mistake|error)", |
| r"(?i)\bi\s+misread\b", |
| r"(?i)\bi\s+mis(under)?stood\b", |
| r"(?i)\bi\s+mis-?(typed|wrote|read|calculated|spoke)", |
| r"(?i)\bi\s+got\s+confused\b", |
| r"(?i)\bi\s+was\s+wrong\b", |
| r"(?i)\bi'?ve\s+been\s+(doing|getting)\s+(this|it)\s+wrong", |
| r"(?i)\bmy\s+(mistake|error|bad)\b", |
| r"(?i)\bthat\s+was\s+wrong\b", |
| r"(?i)\boops\b", |
| r"(?i)\bcorrection\b[,.]", |
| r"(?i)\bto\s+correct\s+(myself|this|that)\b", |
| ], |
| |
| "strategy_switch": [ |
| r"(?i)\b(try|use)\s+(a\s+)?(different|another|alternative)\s+(approach|method|way|strategy|technique)", |
| r"(?i)\binstead[,.]?\s+(let|i|i'?ll)", |
| r"(?i)\blet\s+me\s+try\s+(a\s+different|another|something\s+else)", |
| r"(?i)\bthis\s+(approach|method)\s+(isn'?t|doesn'?t|won'?t)\s+work", |
| r"(?i)\bperhaps\s+(a\s+)?(better|different|another)\s+(way|approach|method)", |
| r"(?i)\balternatively[,.]", |
| r"(?i)\b(a|the)\s+(better|easier|cleaner|simpler|more\s+elegant)\s+(way|approach|method)", |
| r"(?i)\bmore\s+efficient(ly)?\b", |
| r"(?i)\bswitch\s+(to|approaches?|tactics?)", |
| r"(?i)\bchange\s+(strategy|approach|tack)", |
| r"(?i)\baha\b", |
| r"(?i)\bah,?\s+(i\s+see|of\s+course|right)", |
| r"(?i)\bkey\s+insight", |
| r"(?i)\bthe\s+trick\s+is", |
| ], |
| } |
|
|
| |
| |
| |
| |
| SWEEP_ALPHAS = [0.0, 0.3, 0.7, 1.0] |
| |
| NON_TRIVIAL_ALPHAS = [0.7, 0.3, 0.0] |
|
|
| |
| |
| |
| CALIBRATION_N_TEST = 15 |
| CALIBRATION_ACTIVE_THRESHOLD = 2 |
| CALIBRATION_SIDE_EFFECT_RATE = 0.0 |
| SEVERE_REPETITION = 0.3 |
|
|
| |
| |
| |
| TARGET_LAYERS = list(range(2, 36)) |
|
|
| |
| N_TRAIN_COTS = 200 |
|
|
| |
| SAMPLES_PER_COT = 64 |
| MAX_SEQ_LEN_FOR_CAPTURE = 4096 |
|
|
| |
| GEN_MAX_NEW_TOKENS = 32768 |
|
|
| |
| DEFAULT_TEMPERATURE = 0.6 |
| DEFAULT_TOP_P = 0.95 |
|
|