feat(v0.4-beta): learned-selector seam (model-free, shadow-only) - #7
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
SELECTORSentry — with no model code or weights in git. Originally stacked on PR #4 (now merged intodevelop, carrying the paired-task corpus); still shadow-only, nothing served. (Re-opened as a fresh PR targetingdevelopdirectly — the original PR #5 was auto-closed when its base branch,feat/v0.4-alpha-corpus-baselines, was deleted after PR #4 merged; same branch, same commits, no content lost.)What's in it (3 files, model-free)
run_baselines.py—_load_learned_selectors(): discovers an optional local module via$TOKENFOLD_LEARNED_MODULE(defaultlearned.selector), reads itsLEARNED_SELECTORSdict of(units, query) -> list[float]score functions, and registers them intoSELECTORS. When the ML stack / module / weights are absent the import fails and the selector is skipped cleanly — the exact optional-dep pattern already used fortiktokenand 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 throughbuild_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.--gateproves 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 actualSELECTORS.update(...)throughbuild_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
git check-ignoreconfirmseval/learned/{selector,train_probe}.py+weights/head.ptare excluded; the index holds only the 3 files above.