feat: BM25 hybrid retrieval, learn_document(), config wiring, MABench resume#30
Merged
feat: BM25 hybrid retrieval, learn_document(), config wiring, MABench resume#30
Conversation
… resume Move BM25 keyword search, document chunking, and auto-consolidation into elfmem core so benchmark adapters stay thin. Fix three config fields that existed in MemoryConfig but were never wired through to consolidate(). Add resume support to MABench runner. - BM25 stage 2b in hybrid_retrieve() (soft dep on rank_bm25) - learn_document() with auto-dream at inbox_threshold intervals - dream(skip_llm=, skip_contradictions=) forwarding - Wire contradiction_threshold, near_dup_*_threshold from config - MABench adapter: 319→160 lines (removed BM25/RRF/chunking) - MABench runner: atomic per-example writes + --resume - 30 new tests (572 total) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CI doesn't have nltk installed. The adapter imports nltk at module level, so the test file needs the same importorskip guard used by the other benchmark test files. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
rank_bm25 is an optional dependency not installed in CI. The direct unit tests on _stage_2b_bm25_search need the same importorskip guard so they skip gracefully when the package is absent. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove tests on private functions (_stage_2b_bm25_search, _default_chunker, _assemble_chunks) and internal state (_HAS_BM25). All behaviour is now tested through the public API (recall(), learn_document(), dream(), consolidate()). No importorskip guards needed since tests no longer depend on optional packages directly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
hybrid_retrieve()discovers blocks with strong keyword overlap that vector search misses. Soft dependency onrank_bm25(pip install elfmem[bm25]); silently skipped when not installed.learn_document()— chunk, learn, auto-consolidate in one call. Accepts optionalchunkercallback (e.g.nltk.sent_tokenize). ReturnsLearnDocumentResult.dream(skip_llm=, skip_contradictions=)— forwards toconsolidate(), enabling fast-path consolidation without bypassing policy tracking.contradiction_threshold,near_dup_exact_threshold,near_dup_near_thresholdexisted inMemoryConfigbut were never passed throughapi.pytoconsolidate()._BM25Index,_rrf_merge,chunk_text, manual session/consolidation management.--resumeflag skips completed examples.Test plan
ruff checkclean on all changed filespython -m benchmarks.memoryagentbench.runner --test--resumeskips completed examples on re-run🤖 Generated with Claude Code