-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Description
Overview
The project currently supports OpenAI, Gemini, and Voyage embedders, all of which require API keys and incur usage costs. This issue proposes adding support for local Hugging Face embedding models, which are open source and can run locally without API costs.
Requirements
- Add support for local Hugging Face embedding models
- Make dependencies optional to avoid bloating the main package
- Maintain compatibility with the existing
EmbedderClientinterface - Support async operations matching the current client pattern
Implementation Plan
1. Add Optional Dependencies
Update pyproject.toml to include Hugging Face dependencies as an optional requirement.
2. Create HuggingFaceEmbedder Class
Create a new file graphiti_core/embedder/huggingface.py implementing:
HuggingFaceEmbedderConfig- Configuration class for model selection and parametersHuggingFaceEmbedder- Implementation ofEmbedderClientfor Hugging Face models
3. Update Embedder Module Exports
Update graphiti_core/embedder/__init__.py to export the new classes.
4. Implementation Details
HuggingFaceEmbedderConfig
model_name: String for model selection (default to a small, general-purpose model)embedding_dim: Match the required dimension from the base configdevice: Option to specify CPU or GPU (with fallback to CPU)model_kwargs: Additional parameters to pass to the model
HuggingFaceEmbedder
- Implement the required
createmethod for generating embeddings - Add skeleton for
create_batchwith NotImplementedError for now - Handle both synchronous and asynchronous operations
- Add lazy loading of models to avoid unnecessary imports when not used
5. Testing
- Add unit tests for the new embedder in the test suite
- Test with various model sizes and on different input types
- Verify compatibility with the rest of the Graphiti system
- Ensure graceful fallback when GPU is not available
6. Documentation
- Update documentation to include information about the new embedder
Technical Considerations
- The implementation will use the
sentence-transformerspackage for model loading and embedding generation - Models will be loaded on demand and cached for reuse
- May require thread/process management for async operations with CPU-only setup
- Default to small models to minimize memory footprint
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels