***

layout: overview
slug: nemo-curator/nemo\_curator/utils/hf\_download\_utils
title: nemo\_curator.utils.hf\_download\_utils
----------------------------------------------

## Module Contents

### Functions

| Name                                                                                     | Description                         |
| ---------------------------------------------------------------------------------------- | ----------------------------------- |
| [`download_model_from_hf`](#nemo_curator-utils-hf_download_utils-download_model_from_hf) | Download a model from Hugging Face. |

### API

<Anchor id="nemo_curator-utils-hf_download_utils-download_model_from_hf">
  <CodeBlock showLineNumbers={false} wordWrap={true}>
    ```python
    nemo_curator.utils.hf_download_utils.download_model_from_hf(
        model_id: str,
        local_dir: str | pathlib.Path,
        ignore_patterns: list[str] | None = None,
        filename: str | None = None,
        revision: str | None = None
    ) -> None
    ```
  </CodeBlock>
</Anchor>

<Indent>
  Download a model from Hugging Face.

  This function downloads either a specific file or the entire model repository
  from Hugging Face Hub to a local directory.

  **Parameters:**

  <ParamField path="model_id" type="str">
    The Hugging Face model identifier (e.g., 'gpt2', 'bert-base-uncased')
  </ParamField>

  <ParamField path="local_dir" type="str | Path">
    Local directory where the model will be downloaded
  </ParamField>

  <ParamField path="ignore_patterns" type="list[str] | None" default="None">
    List of glob patterns to ignore when downloading.
    Only used when filename is not provided. Defaults to None.
  </ParamField>

  <ParamField path="filename" type="str | None" default="None">
    Specific file to download from the repository.
    If provided, only this file will be downloaded and ignore\_patterns will be ignored.
    Defaults to None.
  </ParamField>

  <ParamField path="revision" type="str | None" default="None">
    Git revision (branch, tag, or commit hash) to download.
    Defaults to None (latest main branch).
  </ParamField>

  **Raises:**

  * `ValueError`: If both filename and ignore\_patterns are provided (not supported).

  **Examples:**

  <CodeBlock showLineNumbers={false}>
    ```python
    # Download entire model repository
    download_model_from_hf('gpt2', './models/gpt2')

    # Download specific file
    download_model_from_hf('gpt2', './models/gpt2', filename='config.json')

    # Download with ignore patterns
    download_model_from_hf('gpt2', './models/gpt2',
                          ignore_patterns=['*.bin', '*.safetensors'])

    # Download specific revision
    download_model_from_hf('gpt2', './models/gpt2', revision='main')
    ```
  </CodeBlock>
</Indent>
