This library integrates HuggingFace embedding models, including Sentence Transformer models, with LlamaIndex. It allows users to create embeddings for documents and queries for retrieval, supporting models like BGE, Mixedbread, Nomic, Jina, and E5. The current version is 0.7.0, and it's part of the LlamaIndex ecosystem, which maintains a regular release cadence for its integration packages.
pip install llama-index-embeddings-huggingfaceVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to initialize the `HuggingFaceEmbedding` class with a specified model (e.g., 'BAAI/bge-small-en-v1.5') and use it to either set the global embedding model for LlamaIndex or generate embeddings for a single piece of text directly.
Ensure `pip install sentence-transformers` is run in your environment alongside `llama-index-embeddings-huggingface`.
Consult the latest LlamaIndex documentation for `HuggingFaceEmbedding` to use current parameter names and configurations.
Upgrade your Python environment to version 3.10 or higher.
Install the necessary `sentence-transformers` extras based on your chosen backend (e.g., `pip install 'sentence-transformers[onnx]'`) to enable optimized inference.
Always check the `pyproject.toml` or `setup.py` of `llama-index-embeddings-huggingface` for the exact `llama-index-core` version compatibility and ensure your `llama-index-core` installation aligns with it.
Install the package using pip: `pip install llama-index-embeddings-huggingface`
Ensure `llama-index-core` and `llama-index-embeddings-huggingface` are compatible versions. Explicitly provide a `model_name` during initialization, e.g., `HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")`, and verify the `sentence-transformers` library is also installed (`pip install sentence-transformers`). For deepcopy issues, re-initialize the embedding model after the copy.
When initializing `HuggingFaceEmbedding`, pass a valid model identifier as the `model_name` argument, such as `embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")`.
Try installing `torch` first with a version compatible with your `llama-index-embeddings-huggingface` version, then install the `llama-index` package. Alternatively, use a robust dependency resolver like `uv` (e.g., `pip install uv` then `uv pip install llama-index-embeddings-huggingface`) or consider using a fresh virtual environment with a Python version known to be compatible (e.g., Python 3.9 or 3.10 for older `llama-index` versions).