Improve embedding backends with error handling, batching, and consistent naming#35
Conversation
…nd consistent naming - Create shared normalize_embeddings utility for L2 normalization - Rename *Vectorizer classes to *Embedder for consistency with protocol - Rename create_vectorizer to create_embedder - Add batching and tqdm progress to LlamaCppEmbedder - Add error handling for llama.cpp inference failures - Replace print() with logging.info() in LlamaCppEmbedder - Narrow truncation warning exception in TransformerEmbedder - Add model loading error handling in TransformerEmbedder - Move yield outside try/except in RemoteEmbedder - Add malformed API response detection in RemoteEmbedder - Remove per-batch torch.cuda.empty_cache() in TransformerEmbedder - Add explicit backend validation in create_embedder factory - Add normalization utility tests Co-authored-by: Cursor <cursoragent@cursor.com>
The container-manifest job was getting 403 Forbidden when pulling digests from GHCR. Switch from github.actor to github.repository_owner for consistent authentication across build and manifest jobs. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR systematically refactors the embedding generation API from a vectorizer-based interface to an embedder-based interface. The factory function is renamed, all three embedding backends (remote, llama-cpp, transformer) are refactored with updated class names and improved batch processing logic, a new shared L2 normalization utility is introduced, and all application code, benchmarks, tests, and CI workflows are updated to use the new API surface. ChangesEmbedder API Refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|


Summary
*Vectorizerclasses to*Embedderfor consistency with theEmbedderprotocol (TransformerEmbedder,LlamaCppEmbedder,RemoteEmbedder)create_vectorizertocreate_embeddernormalize_embeddings()utility inembedding/normalize.pyfor vectorized L2 normalizationLlamaCppEmbedder(previously processed one window at a time)print()withlogging.info()inLlamaCppEmbeddermodel downloadTransformerEmbedderwith user-friendly messagesexcept Exception: passin truncation warning to specific exception types with debug loggingyieldoutsidetry/exceptinRemoteEmbedderto prevent consumer exceptions from being swallowedRemoteEmbeddercreate_embedderfactory (raisesValueErrorfor unknown backends)torch.cuda.empty_cache()inTransformerEmbedderrepository_ownerinstead ofactorfor consistent container registry authenticationSummary by CodeRabbit
New Features
Tests