Repository navigation
feat: Use FastEmbed as the default dense embedder - #80
Merged
Merged
Conversation
|
API Documentation is up to date. |
There was a problem hiding this comment.
All reported issues were addressed across 25 files
Architecture diagram
sequenceDiagram
participant App as Application
participant Builder as build_embedder()
participant Settings as EmbeddingSettings
participant Cache as EmbeddingCache
participant FE as FastEmbedEmbedder
participant ONNX as ONNX Runtime (FastEmbed)
participant ST as SentenceTransformerEmbedder
Note over App,ST: Dense Embedding Architecture - FastEmbed Default
App->>Builder: build_embedder("model-name")
alt Model name provided
Builder->>Settings: Create EmbeddingSettings
Builder->>FE: FastEmbedEmbedder(settings, tracer)
Note over FE: NEW: FastEmbed is default dense embedder
FE-->>App: Embedder instance
else Embedder instance passed
Builder-->>App: Return unchanged instance
end
Note over App,ONNX: Runtime Embedding Flow
App->>FE: embed(texts)
FE->>Cache: get(text, model, normalize)
alt Cache hit (all texts)
Cache-->>FE: Cached vectors
FE-->>App: Return vectors
else Cache miss (some texts)
Cache-->>FE: Partial/None
FE->>FE: _ensure_model_async()
alt Model not loaded yet
FE->>FE: Acquire model lock
FE->>ONNX: Load TextEmbedding (lazy, in worker thread)
Note over ONNX: NEW: Runs ONNX models on CPU<br/>No PyTorch dependency
ONNX-->>FE: Model instance
Note over FE: NEW: Lazy load, shared across concurrent calls
end
FE->>ONNX: embed(texts, batch_size)
Note over ONNX: Blocking call in worker thread
ONNX-->>FE: Raw vectors
FE->>FE: Normalize vectors (if enabled)
FE->>Cache: set(text, model, normalize, vector)
FE-->>App: Vectors
end
Note over App,ONNX: Model Loading Path
FE->>FE: _build_model()
FE->>ONNX: Import TextEmbedding
alt Granite default model
ONNX->>ONNX: Check list_supported_models()
alt Model not in FastEmbed release
ONNX->>ONNX: add_custom_model()
Note over ONNX: NEW: Register granite ONNX export<br/>CLS pooling, raw vectors
end
end
ONNX-->>FE: TextEmbedding instance
Note over App,ST: Alternative Path - Sentence Transformers
App->>ST: SentenceTransformerEmbedder(settings)
Note over ST: CHANGED: Requires embed-local extra<br/>Optional alternative to FastEmbed
ST-->>App: Embedder instance
Note over App,Builder: Key Changes
Note over Builder: CHANGED: build_embedder creates FastEmbedEmbedder<br/>instead of SentenceTransformerEmbedder
Note over FE: NEW: FastEmbed is default embedder<br/>- Same interface as before<br/>- Same cache keys<br/>- Same vector compatibility
Note over ST: CHANGED: Now optional, not default<br/>Use for unsupported models or custom device
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
awinml
force-pushed
the
fastembed_default_embedder
branch
from
October 7, 2026 18:18
a2909d3 to
31f60db
Compare
There was a problem hiding this comment.
All reported issues were addressed across 7 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
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.
Proposed Changes
build_embedder("<model name>")now returns a FastEmbed embedder instead of a sentence-transformers embedder. FastEmbed runs ONNX models on the CPU, so the default embedder no longer needs PyTorch.FastEmbedEmbedderinagrag/embedding/fastembed_dense.pyimplementsEmbedderthe same waySentenceTransformerEmbedderdoes: lazy model load, blocking calls in a worker thread, a cache key of text, model, andnormalize, and the same tracing spans.agrag.embedding.embedon everyembed()call withtext_count,cache_hit_count, andmodel, so fully cached calls stay traceable. The miss-onlyagrag.embedding.encodespan is unchanged, and the new span is listed in the trace-spans reference.fastembedmoves into the base dependencies (>=0.8.0). The base install grows by about 38 MB of wheels, mostlyonnxruntime. Theqdrantextra keepsqdrant-client. The BM25 embedder no longer raisesEmbeddingMissingExtraError, because its package is always installed.SentenceTransformerEmbedderstays behind theembed-localextra. Pass an instance to use it. There is no alias for the old behavior.TextEmbedding.add_custom_model, only whilelist_supported_models()lacks it. The shim uses CLS pooling (mean pooling gives cosine 0.87). It registers raw vectors, because the embedder appliesEmbeddingSettings.normalizeitself, as FastEmbed's own entry does.model,normalize, andbatch_sizeapply to both embedders.cache_folderis FastEmbed's cache directory. FastEmbed ignoresdevice, and the settings docs say so.embed-localwhere it only supplied the default embedder. The configuration reference, the storage guide, and the README describe the new default.How did you test it?
tests/unit/embedding/test_fastembed_dense.py. They mock FastEmbed at its boundary and cover normalization, batching, the worker thread, lazy and shared loading, the cache, tracing, and when the granite model is registered. The full unit suite passes (2,219 tests).ruff,ruff format,ty, andtypospass.Notes for the reviewer
build_embeddernow fails for a model that FastEmbed does not support. Pass aSentenceTransformerEmbedderfor those.neo4jandllmextras into the base install, and delete the granite shim once the minimumfastembedversion lists the model.Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:Summary by cubic
Makes FastEmbed the default dense embedder and hardens LLM retry behavior.
build_embedder("<model>")now returns aFastEmbedEmbedderthat runs ONNX models on the CPU, so the default embedder no longer needs PyTorch or theembed-localextra. Retry now jitters backoff waits, supports an overall deadline, and retries successful calls whose results are unusable.fastembedmoves into the base dependencies, andSentenceTransformerEmbedderstays behind theembed-localextra.build_embeddernow fails for models FastEmbed does not support, so pass aSentenceTransformerEmbedderfor those.add_custom_model, only while an installed release lacks it.agrag.embedding.embedspan.onnxruntime; the first run downloads about 180 MB of model weights.RetryConfig.timeout_msbounds the whole call, sleeps are clamped to the remaining deadline, and no new attempt starts past it;accept_resultretries rejected results until the budget runs out.Written for commit 25d04a6. Summary will update on new commits.