# HuggingFaceModelLoader

> **Class** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/document_loaders/hugging_face_model/HuggingFaceModelLoader)

Load model information from `Hugging Face Hub`, including README content.

This loader interfaces with the Hugging Face Models API to fetch and load
model metadata and README files.
The API allows you to search and filter models based on specific criteria
such as model tags, authors, and more.

API URL: https://huggingface.co/api/models
DOC URL: https://huggingface.co/docs/hub/en/api

Examples:

    .. code-block:: python

        from langchain_community.document_loaders import HuggingFaceModelLoader

        # Initialize the loader with search criteria
        loader = HuggingFaceModelLoader(search="bert", limit=10)

        # Load models
        documents = loader.load()

        # Iterate through the fetched documents
        for doc in documents:
            print(doc.page_content)  # README content of the model
            print(doc.metadata)      # Metadata of the model

## Signature

```python
HuggingFaceModelLoader(
    self,
    *,
    search: Optional[str] = None,
    author: Optional[str] = None,
    filter: Optional[str] = None,
    sort: Optional[str] = None,
    direction: Optional[str] = None,
    limit: Optional[int] = 3,
    full: Optional[bool] = None,
    config: Optional[bool] = None,
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `search` | `Optional[str]` | No | Filter based on substrings for repos and their usernames. (default: `None`) |
| `author` | `Optional[str]` | No | Filter models by an author or organization. (default: `None`) |
| `filter` | `Optional[str]` | No | Filter based on tags. (default: `None`) |
| `sort` | `Optional[str]` | No | Property to use when sorting. (default: `None`) |
| `direction` | `Optional[str]` | No | Direction in which to sort. (default: `None`) |
| `limit` | `Optional[int]` | No | Limit the number of models fetched. (default: `3`) |
| `full` | `Optional[bool]` | No | Whether to fetch most model data. (default: `None`) |
| `config` | `Optional[bool]` | No | Whether to also fetch the repo config. (default: `None`) |

## Extends

- `BaseLoader`

## Constructors

```python
__init__(
    self,
    *,
    search: Optional[str] = None,
    author: Optional[str] = None,
    filter: Optional[str] = None,
    sort: Optional[str] = None,
    direction: Optional[str] = None,
    limit: Optional[int] = 3,
    full: Optional[bool] = None,
    config: Optional[bool] = None,
)
```

| Name | Type |
|------|------|
| `search` | `Optional[str]` |
| `author` | `Optional[str]` |
| `filter` | `Optional[str]` |
| `sort` | `Optional[str]` |
| `direction` | `Optional[str]` |
| `limit` | `Optional[int]` |
| `full` | `Optional[bool]` |
| `config` | `Optional[bool]` |


## Properties

- `BASE_URL`
- `README_BASE_URL`
- `params`

## Methods

- [`fetch_models()`](https://reference.langchain.com/python/langchain-community/document_loaders/hugging_face_model/HuggingFaceModelLoader/fetch_models)
- [`fetch_readme_content()`](https://reference.langchain.com/python/langchain-community/document_loaders/hugging_face_model/HuggingFaceModelLoader/fetch_readme_content)
- [`lazy_load()`](https://reference.langchain.com/python/langchain-community/document_loaders/hugging_face_model/HuggingFaceModelLoader/lazy_load)

---

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