Skip to content

feat(v0.4-beta): learned-selector seam (model-free, shadow-only) - #5

Closed
snchimata wants to merge 2 commits into
feat/v0.4-alpha-corpus-baselinesfrom
feat/v0.4-beta-learned-selector-seam
Closed

feat(v0.4-beta): learned-selector seam (model-free, shadow-only)#5
snchimata wants to merge 2 commits into
feat/v0.4-alpha-corpus-baselinesfrom
feat/v0.4-beta-learned-selector-seam

Conversation

@snchimata

Copy link
Copy Markdown
Owner

Summary

Starts v0.4-beta (Phase 8): the committed, model-free seam that lets a locally-trained keep/drop selector plug into the baseline harness as just another SELECTORS entry — with no model code or weights in git. Stacked on PR #4 (base feat/v0.4-alpha-corpus-baselines, which carries the 11-fixture corpus); still shadow-only, nothing served.

What's in it (3 files, model-free)

  • run_baselines.py_load_learned_selectors(): discovers an optional local module via $TOKENFOLD_LEARNED_MODULE (default learned.selector), reads its LEARNED_SELECTORS dict of (units, query) -> list[float] score functions, and registers them into SELECTORS. When the ML stack / module / weights are absent the import fails and the selector is skipped cleanly — the exact optional-dep pattern already used for tiktoken and the tokenfold CLI. Report + summary now label learned vs. deterministic selectors.
  • test_learned_selector_wiring.py: stdlib, assert-based, runs with no ML installed. Proves skip-when-absent never raises, the real register path flows through build_report/run_gate, a baseline-name collision is rejected, and any learned score function still passes the hard gates.
  • .gitignore: /eval/learned/ — model/training code + weights stay local, never committed.

Contract (why this is safe)

Per model-research.md: the learned selector emits scores only. The deterministic critical-atom forcing + ceiling allocator + byte-copy assembly own the output, so 100% critical-atom survival and the token ceiling stay structural — independent of what the model scores. --gate proves this holds for the learned selector too.

Integrity guard (from review)

A 4-lens adversarial review flagged that a learned selector named like a deterministic baseline (e.g. bm25) would silently overwrite that baseline, run under its name, yet be reported as deterministic. The seam now fails loud on any name collision with a deterministic baseline, and a test asserts it. A second finding — the register line was never exercised end-to-end — is fixed with a test that drives the actual SELECTORS.update(...) through build_report/run_gate.

The bar to beat

bm25 = 0.82 task success @ 0.25 token ratio (v0.4-alpha finding). The local (gitignored) frozen-Granite probe trains + runs against this bar once the ML stack is installed; "stop if it can't beat bm25."

Testing

python eval/test_learned_selector_wiring.py   # 5 checks pass (model-free)
python eval/run_baselines.py --gate           # gate: pass, 132 checks
python eval/run_baselines.py                  # "learned selectors: none (ML absent, skipped)"

git check-ignore confirms eval/learned/{selector,train_probe}.py + weights/head.pt are excluded; the index holds only the 3 files above.

…nly)

Optional-dep seam so a locally-trained keep/drop selector plugs into the
baseline harness as just another SELECTORS entry, with no model code in git.

- run_baselines.py: _load_learned_selectors() discovers a gitignored local
  module (TOKENFOLD_LEARNED_MODULE, default learned.selector) and registers its
  LEARNED_SELECTORS; ML/module/weights absent -> cleanly skipped, exactly like
  tiktoken and the tokenfold CLI. Fails loud if a learned name would shadow a
  deterministic baseline. Report + summary label learned vs deterministic.
- test_learned_selector_wiring.py: model-free test — skip-when-absent never
  raises, the real register path flows through build_report/run_gate, a
  baseline-name collision is rejected, and any learned score fn still passes the
  hard gates (critical-atom survival + ceiling stay structural).
- .gitignore: /eval/learned/ so model/training code + weights never enter git.

Contract per model-research.md: the learned selector emits scores only; the
deterministic forcing + ceiling allocator + byte-copy assembly own the output.
Bar to beat = bm25's 0.82 task @ 0.25 ratio.
@snchimata
snchimata deleted the branch feat/v0.4-alpha-corpus-baselines July 27, 2026 00:25
@snchimata snchimata closed this Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant