Feature/feature/semantic search#97
Merged
Merged
Conversation
Adds full semantic search behind the `semantic` Cargo feature.
Core changes:
- `src/semantic/mod.rs`: `Embedder` trait (sync, Send+Sync); gated
`FasEmbedder`
- `src/semantic/fastembed_impl.rs`: fastembed 5.x wrapper with Mutex
guard
(TextEmbedding::embed takes &mut self); batch size 32;
all-MiniLM-L6-v2
- `src/traits.rs`: default no-op `save_embedding` and
`search_semantic` on
storage/searcher traits; `get_unembedded` fallback; tracing in all
defaults
- `src/storage/turso_storage.rs`: additive ALTER TABLE migration adds
nullable `embedding BLOB` column; `save_embedding` writes via
`vector32()`;
`get_unembedded` queries `WHERE embedding IS NULL`
- `src/storage/turso_searcher.rs`: `search_semantic` queries
`vector_distance_cos(embedding, vector32(?))` ORDER BY dist ASC;
score = (1.0 - dist).max(0.0)
`get_unembedded` queries `WHERE embedding IS NULL`
- `src/storage/turso_searcher.rs`: `search_semantic` queries
`vector_distance_cos(embedding, vector32(?))` ORDER BY dist ASC;
score = (1.0 - dist).max(0.0)
- `src/engine.rs`: adds `embedder: Option<Arc<dyn Embedder>>` field
(gated);
`assemble` now runs BM25 + semantic then fuses via full-union RRF
(k=60,
worst_rank=51); recency decay and lexicon boost applied after RRF;
`save_snapshot` embeds new entries non-fatally via spawn_blocking;
`backfill_embeddings` for existing entries (batched, progress
callback)
- `src/builder.rs`: `with_embedding_model(cache_dir)` wires
FasEmbedder
- `src/lib.rs`: `pub mod semantic`, re-exports
`Embedder`/`FasEmbedder`,
`backfill_embeddings` on `ContextForge`
- `Cargo.toml`: `tracing = "0.1"` (always), `fastembed` optional,
`semantic`
feature flag
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.
No description provided.