# HuggingFaceHubEmbeddings

> **Class** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/embeddings/huggingface_hub/HuggingFaceHubEmbeddings)

HuggingFaceHub embedding models.

To use, you should have the ``huggingface_hub`` python package installed, and the
environment variable ``HUGGINGFACEHUB_API_TOKEN`` set with your API token, or pass
it as a named parameter to the constructor.

## Signature

```python
HuggingFaceHubEmbeddings()
```

## Description

**Example:**

.. code-block:: python

from langchain_community.embeddings import HuggingFaceHubEmbeddings
model = "sentence-transformers/all-mpnet-base-v2"
hf = HuggingFaceHubEmbeddings(
    model=model,
    task="feature-extraction",
    huggingfacehub_api_token="my-api-key",
)

## Extends

- `BaseModel`
- `Embeddings`

## Properties

- `client`
- `async_client`
- `model`
- `repo_id`
- `task`
- `model_kwargs`
- `huggingfacehub_api_token`
- `model_config`

## Methods

- [`validate_environment()`](https://reference.langchain.com/python/langchain-community/embeddings/huggingface_hub/HuggingFaceHubEmbeddings/validate_environment)
- [`post_init()`](https://reference.langchain.com/python/langchain-community/embeddings/huggingface_hub/HuggingFaceHubEmbeddings/post_init)
- [`embed_documents()`](https://reference.langchain.com/python/langchain-community/embeddings/huggingface_hub/HuggingFaceHubEmbeddings/embed_documents)
- [`aembed_documents()`](https://reference.langchain.com/python/langchain-community/embeddings/huggingface_hub/HuggingFaceHubEmbeddings/aembed_documents)
- [`embed_query()`](https://reference.langchain.com/python/langchain-community/embeddings/huggingface_hub/HuggingFaceHubEmbeddings/embed_query)
- [`aembed_query()`](https://reference.langchain.com/python/langchain-community/embeddings/huggingface_hub/HuggingFaceHubEmbeddings/aembed_query)

## ⚠️ Deprecated

Deprecated since version 0.2.2.

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/4b280287bd55b99b44db2dd849f02d66c89534d5/libs/community/langchain_community/embeddings/huggingface_hub.py#L14)