Upgrade embedder + reranker to 8K context, raise chunk size#5
Merged
Conversation
Two stale models with a context-window mismatch were the real ceiling on recall, not the +0.3 MTEB delta between same-class peers: - Bi-encoder: BAAI/bge-small-en-v1.5 (Sep 2023, 384d, 512 tok limit) -> nomic-ai/nomic-embed-text-v1.5-Q (130MB, 768d, 8K tokens) - Cross-encoder: Xenova/ms-marco-MiniLM-L-6-v2 (2021, ~512 tok) -> jinaai/jina-reranker-v1-tiny-en (130MB, 8K tokens) - MAX_CHUNK_CHARS: 2000 -> 8000 (chunks were truncating mid-conversation at the old 512-token ceiling; an entire 5-turn window now fits). The new embedder uses asymmetric prefixes, so embed()/embed_single() now go through passage_embed()/query_embed() rather than the bare embed(). Dim is sourced from Embedder.DIM and chunks_vec auto-migrates: if an existing table has the wrong dim, it's dropped and the indexer re-embeds all chunks on the next run. Subtle bug fixed along the way: nomic returns float64 while sqlite-vec expects float32, so raw embeddings tripped "Dimension mismatch (received 1536)" — cast to float32 at the Embedder boundary. 331 tests pass. Smoke eval on 7 synthetic vague-memory queries: 6/7, including the two queries the README highlights.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 058622e2da
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Two follow-on UX fixes surfaced when testing on a real 1695-session index: 1. TUI crashed with MarkupError on session data containing unbalanced square-bracket sequences (e.g. a prompt with literal "[/dim]" in it). Even with escape() applied at every visible interpolation site, a missed call anywhere in the render path takes down the whole TUI. Added _safe_markup() — validates Rich markup with Text.from_markup, falls back to fully-escaped on MarkupError so the worst case is "tags render as literal text" rather than "TUI dies". Wrapped the three composite render sites that mix user data with markup. 2. _generate_embeddings was one giant batched embedder.embed(texts) call followed by a per-50-chunks counter inside the insert loop. The actual embedding compute (where time is spent) was silent. Now embeds in batches of 64 with a tqdm progress bar showing count / rate / ETA, so users see steady feedback instead of a frozen "Generating embeddings for N chunks..." line. Falls back to the old line-print when stderr isn't a tty. 331 tests still pass.
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
The bi-encoder and cross-encoder were both pre-2024 and the chunker was tuned to the old 512-token ceiling. Raising the context window everywhere — including chunk size — is a bigger quality lever than swapping for a +0.3 MTEB peer.
Changes
Subtle bug fixed
nomic returns `float64` while sqlite-vec stores `float[N]` as `float32`. Without a cast, sqlite-vec reads the 6144-byte buffer as 1536 floats and throws "Dimension mismatch". Cast to `float32` at the Embedder boundary.
Validation
Migration impact for existing users
Size impact
Both still under `pip install 'code-recall[all]'`. No new dependencies.
Test plan