Repository navigation
Conversation
… cache - Add sqlite-vec extension for fast vector search (vec_chunks virtual table) - Double-write embeddings to both embeddings table and vec_chunks - Switch vectorSearch to use sqlite-vec index when available, with brute-force fallback - Add embedding cache (EmbeddingCache) to avoid redundant API calls - Use embedQueryWithCache in recall engine for hybrid search - Add Ollama embedding provider support - Add ownerFilter config option for recall search
shinetata
left a comment
There was a problem hiding this comment.
Thanks for the contribution! The direction (indexed vector search + query-embedding cache + Ollama) is welcome, but this needs changes before it can land. Key blockers:
- Sort regression (
src/recall/engine.ts): skill vector candidates are now sorted with(a, b) => b.score - b.score, which is always 0 — this disables ranking. Must beb.score - a.score. - Hardcoded
FLOAT[2048](src/storage/sqlite.ts): default embeddings are 384-D (local) or 1536-D (remote), never 2048. Sovec_chunksstays empty and every query throws + falls back to brute force. Derive the dimension fromEmbedder.dimensionsinstead of hardcoding. - Distance→score (
src/storage/vector.ts): vec0 defaults to L2, so1 - distanceis not cosine similarity and is inconsistent with the brute-force path — it breaksminScore/RRF. Please declaredistance_metric=cosineand convert accordingly. - Cache key (
src/embedding/cache.ts): keyed on text only. It must incorporateembeddingSignature(provider:model:dimensions), otherwise cached vectors are reused across models. - Native dependency:
sqlite-vecships native binaries. Please wire it through the existing postinstall/prebuild + ESM packaging flow (see the #1733 module-format tests and the better-sqlite3 native-binding setup). - Tests: no tests were added. Please cover cache hit/expiry/LRU/model-keying, indexed-vs-brute-force score parity, dimension-mismatch fallback, and the Ollama provider.
Also minor: use the injected Logger instead of console.warn; the indexed path ignores vectorSearchMaxChunks; Ollama default model "qwen" isn't an embedding model; please avoid non-English inline comments.
Suggestion: split into 3 smaller PRs (Ollama provider / embedding cache / sqlite-vec index) and rebase onto main (currently conflicting). Happy to re-review once updated.
|
@shinetata The branch is now updated on top of the latest The previous blockers are addressed in
Local validation completed with 73 focused tests and 26 integration tests passing. The PR description has also been updated to match the current implementation. |
883bc5d to
2afd7b2
Compare
Automated Test Results: PASSEDManual cloud Test Engine rerun against the current PR head completed successfully after the automated OCR gate failed to start AutoTest.
The |
✅ Automated Test Results: PASSEDAll tests passed (51/51 executed). memos_local_openclaw/unit: 51/51. Duration: 11s Branch: |
|
Thanks for the contribution and for addressing the previous review feedback. We are closing this PR because Any future work on indexed or ANN-based vector retrieval should target |
Summary
Add optional
sqlite-vecindexed vector search, a signature-aware query embedding cache, and an Ollama embedding provider tomemos-local-openclaw-plugin.This branch has been merged with the latest
main, and the previous review blockers have been addressed.Changes
sqlite-vec indexed search
sqlite-vecthrough the existing native dependency checks, with a verified fallback when the extension is unavailable.vec0table using the configuredEmbedder.dimensionsanddistance_metric=cosine.ownerandsession_keymetadata in the index so access and session filters are applied during KNN search.embeddingstable as the source of truth and fallback path.vectorSearchMaxChunksbehavior by using the existing brute-force path when a bounded candidate scan is requested.Set
MEMOS_USE_VEC_INDEX=falseto force the original brute-force search path.Embedding cache
provider:model:dimensionsplus the exact query text.Embedderinstances and return cloned vectors.Ollama provider
/api/embedsupport withnomic-embed-textas the default model.Regression fixes
re-embed --dry-run.Validation
Backward compatibility
embeddingstable.