> ## Documentation Index
> Fetch the complete documentation index at: https://phidatainc.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.
</Warning>

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

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

  <Step title="Export the API key">
    ```bash theme={null}
    export HUGGINGFACE_API_KEY=your_hugging_face_api_key_here
    ```
  </Step>

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno huggingface-hub
    ```
  </Step>

  <Step title="Run the example">
    ```bash theme={null}
    python huggingface_embedder.py
    ```
  </Step>
</Steps>

## Developer Resources

* [HuggingfaceCustomEmbedder reference](/reference/knowledge/embedder/huggingface)
* [Embedders overview](/knowledge/concepts/embedder/overview)
* [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)
