Repository navigation
feat: select the local embedding model with embedding.model - #541
Merged
Merged
Conversation
The local provider was hard-coded to all-MiniLM-L6-v2 and ignored embedding.model. It now supports all-MiniLM-L6-v2 (default, unchanged), bge-small-en-v1.5 and bge-base-en-v1.5, each pinned to a Hugging Face revision and downloaded on first use. An unknown name is a ConfigError instead of a warning. Model files now stream to a uniquely named temp file that is renamed on success and removed on failure, and the whole download is retried.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
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.



Problem
The
localembedding provider was hard-coded to all-MiniLM-L6-v2 and ignoredembedding.model, which the ollama and openai providers use. The only way to get a stronger embedding model was to run an Ollama or OpenAI-compatible server.Change
embedding.modelselects the local model from a built-in list insrc/providers/local.ts:all-MiniLM-L6-v2: the default, unchanged. Same index identifier (sentence-transformers/all-MiniLM-L6-v2), same cache path, revision, 256-token limit and mean pooling.bge-small-en-v1.5: Xenova/bge-small-en-v1.5 atea104dac. CLS pooling, 512 tokens, 384 dimensions, about 130 MB.bge-base-en-v1.5: Xenova/bge-base-en-v1.5 at4d6cd88e. CLS pooling, 512 tokens, 768 dimensions, about 440 MB.Each model downloads on first use into
~/.libscope/models/<repo>, pinned to its revision. Nothing is added to the npm package. Pooling, max length and dimensions come from each model's1_Pooling/config.json,sentence_bert_config.jsonandconfig.json.Switching models changes the index identity, so the existing model-change error and
libscope admin reindex --rebuildapply.Downloads
downloadModelFilenow streams to<file>.<uuid>.partialand renames it on success. It used to buffer the whole file in memory, which would peak near 870 MB for bge-base.Behaviour change
With provider
local, a leftoverembedding.modelused to log a warning and run MiniLM. Now:nomic-embed-text, is aConfigErrorthat namesembedding.modeland how to fix it.admin reindex --rebuild.Users with no
embedding.modelset see no change. Documented indocs/guide/configuration.md.Tests
tests/unit/local-embedding.test.ts: model selection, the unknown-model error (including prototype keys such asconstructor), CLS pooling, and truncation per limit.tests/unit/local-embedding-models.test.ts(new), with fs, tokenizer and onnxruntime mocked:embed();Verification
npm run format:check,lint(0 errors),typecheck,npm test(2155 tests),build,docs:check.bge-small-en-v1.5with a fresh HOME:.partialfiles left;tokenizersreference on BAAI's own ONNX export within 2.2e-07, over 5 texts including one truncated at 512 tokens.Not verified
EmbeddingProviderhas no query/document distinction.embedding.dimensionsis still ignored by the local provider.