> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Hugging Face Embedder

> Call a Hugging Face feature-extraction endpoint with HuggingfaceCustomEmbedder.

`HuggingfaceCustomEmbedder` defaults to `intfloat/multilingual-e5-large`. Set `dimensions=1024` so Agno records that model's expected vector width.

```python huggingface_embedder.py theme={null}
from agno.knowledge.embedder.huggingface import HuggingfaceCustomEmbedder

embedder = HuggingfaceCustomEmbedder(dimensions=1024)

passage_vector = embedder.get_embedding(
    "passage: The quick brown fox jumps over the lazy dog."
)
query_vector = embedder.get_embedding("query: Which animal jumps?")

print(f"Passage output length: {len(passage_vector)}")
print(f"Query output length: {len(query_vector)}")
```

> [!WARNING]
>
> The default E5 model expects `passage: ` for indexed passages and `query: ` for retrieval queries. `HuggingfaceCustomEmbedder` does not add these prefixes. Add them before calling the embedder. The adapter also returns the feature-extraction response without pooling or flattening it. Confirm that your endpoint returns one flat vector before using it with a vector database.

The `dimensions` field does not request pooling or a specific output size from Hugging Face. It configures the expected width used by Agno's vector database integrations.

## Run the Example

<Snippet file="create-venv-step.mdx" />

**1. Export the API key**

```bash theme={null}
export HUGGINGFACE_API_KEY=your_hugging_face_api_key_here
```

**2. Install dependencies**

```bash theme={null}
uv pip install -U agno huggingface-hub
```

**3. Run the example**

```bash theme={null}
python huggingface_embedder.py
```

## Developer Resources

* [HuggingfaceCustomEmbedder reference](https://agno-v2.mintlify.site/reference/knowledge/embedder/huggingface.md)
* [Embedders overview](https://agno-v2.mintlify.site/knowledge/concepts/embedder/overview.md)
* [Hugging Face InferenceClient](https://huggingface.co/docs/huggingface_hub/en/package_reference/inference_client)
* [Multilingual E5 model card](https://huggingface.co/intfloat/multilingual-e5-large)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.