llama_hf_download: Download a GGUF model from Hugging Face

View source: R/hf.R

llama_hf_downloadR Documentation

Download a GGUF model from Hugging Face

Description

Downloads a GGUF model file from a Hugging Face repository. Files are cached locally so subsequent calls return the cached path without re-downloading.

Usage

llama_hf_download(
  repo_id,
  filename = NULL,
  pattern = NULL,
  tag = NULL,
  token = NULL,
  cache_dir = NULL,
  revision = "main",
  force = FALSE
)

Arguments

repo_id

Character. Hugging Face repository in "org/repo" format.

filename

Character or NULL. Exact filename to download.

pattern

Character or NULL. Glob pattern for filename matching (case-insensitive). If multiple files match, an error is thrown listing the matches.

tag

Character or NULL. Ollama-style tag. First tries the Ollama manifest API; on failure, falls back to pattern matching with *{tag}*.

token

Character or NULL. Hugging Face API token. If NULL, uses the HF_TOKEN environment variable.

cache_dir

Character or NULL. Custom cache directory. Defaults to llama_hf_cache_dir().

revision

Character. Git revision (branch/tag/commit). Defaults to "main".

force

Logical. If TRUE, re-download even if cached. Defaults to FALSE.

Details

Exactly one of filename, pattern, or tag must be specified to identify which file to download.

Value

A character string containing the absolute path to the downloaded (or cached) GGUF model file.

Examples

## Not run: 
path <- llama_hf_download("TheBloke/Llama-2-7B-GGUF",
                          pattern = "*q2_k*")
print(path)

## End(Not run)

llamaR documentation built on May 28, 2026, 1:06 a.m.