Skip to main content

hf-serve

Installation

First you need to setup your environment with uv (or with your preferred Python environment manager).

uv venv --python 3.12
source .venv/bin/activate

Install it from the uv.lock file for CPU / MPS as follows:

uv sync --active --frozen --extra cpu

Alternatively, install it on NVIDIA CUDA 12.6 as follows:

uv sync --active --frozen --extra cuda --extra flash-attn --preview-features extra-build-dependencies

Or if you're on CUDA 12.8 then:

uv sync --active --frozen --extra cuda-128 --extra flash-attn --preview-features extra-build-dependencies
$ uv run hf-serve --help

Examples

🤏 Run HuggingFaceTB/SmolLM3-3B with an OpenAI API

uv run hf-serve --model-id HuggingFaceTB/SmolLM3-3B --task text-generation --dtype float16

🔵 Run sentence-transformers/all-MiniLM-L6-v2 on Azure AI

uv run hf-serve --model-id sentence-transformers/all-MiniLM-L6-v2 --task sentence-similarity --dtype float32 --cloud azure

🟠 Run sentence-transformers/all-MiniLM-L6-v2 on Amazon SageMaker

uv run hf-serve --model-id sentence-transformers/all-MiniLM-L6-v2 --task sentence-similarity --dtype float32 --cloud sagemaker

👂 Run facebook/wav2vec2-base-960h an automatic-speech-recognition model

uv run hf-serve --model-id facebook/wav2vec2-large-960h --task automatic-speech-recognition --dtype float16

And, then you can send a sample request as:

curl -L http://localhost:8080/predict \
    -H "Content-Type: application/json" \
    -d '{"inputs":"https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/1.flac"}'

Run voice activity detection

The voice-activity-detection task supports diarization-capable audio frame classification models whose processor exposes extract_speaker_dict. It returns speaker segments with start, end (seconds), and speaker (arrival-order index):

uv run hf-serve --model-id your-org/your-model --task voice-activity-detection

Send an audio URL, base64-encoded audio, or an audio file through the same JSON, form, or binary endpoints used by ASR:

curl -L http://localhost:8080/predict-json \
    -H "Content-Type: application/json" \
    -d '{"inputs":"https://huggingface.co/datasets/hf-internal-testing/dummy-audio-samples/resolve/main/diarization_example.mp3"}'

Offline inference is the default. To process the recording in streaming chunks within one request, add "parameters":{"streaming_mode":"low_latency"} to the JSON body, or send streaming_mode=low_latency with a form upload. The other supported modes are very_low_latency and ultra_low_latency. Each request has its own speaker cache; the API does not retain a streaming session across requests.

On Google Cloud, run with --cloud google and send audio strings in instances. The same parameters apply to every instance, and the response contains one predictions entry per instance:

{"instances": ["<base64-encoded audio>"], "parameters": {"streaming_mode": "low_latency"}}

🔈 Run facebook/wav2vec2-lv-60-espeak-cv-ft (with phonemizer and espeak)

To run facebook/wav2vec2-lv-60-espeak-cv-ft on e.g. MacOS, you need to run the following:

DYLD_FALLBACK_LIBRARY_PATH=/opt/homebrew/lib uv run hf-serve --model-id facebook/wav2vec2-lv-60-espeak-cv-ft --task automatic-speech-recognition --dtype float16 --device mps

Note that if you have installed another version of ffmpeg with brew as e.g. brew install ffmpeg@7, you should use the following command instead:

DYLD_FALLBACK_LIBRARY_PATH=/opt/homebrew/opt/ffmpeg@7/lib uv run hf-serve --model-id facebook/wav2vec2-lv-60-espeak-cv-ft --task automatic-speech-recognition --dtype float16 --device mps

The main difference relies on the path used for DYLD_FALLBACK_LIBRARY_PATH which is now pointing to the exact brew-installed version of ffmpeg instead. More information on the compatibility issues with ffmpeg, torchcodec and torch at https://github.com/meta-pytorch/torchcodec?tab=readme-ov-file#installing-torchcodec.

Release files for hf-serve 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hf-serve 0.1.5
File Size Uploaded
hf_serve-0.1.5.tar.gz 54.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hf-serve 0.1.5
File Interpreter ABI Platform
hf_serve-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 159.5 kB

Release files / hf_serve-0.1.5.tar.gz

Download URL hf_serve-0.1.5.tar.gz
Size 54.8 kB
Tags Source
SHA-256 checksum
How to use checksums
43f559e94d4e6a8db1fac75c11620950351b47e9f8c84fdeee77194c696dda56
BLAKE2b-256 checksum
How to use checksums
70a027a9aca8c39d295eefccc12a6843d3e416589ccb0d79223b4e01cd7e4ab5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release files / hf_serve-0.1.5-py3-none-any.whl

Download URL hf_serve-0.1.5-py3-none-any.whl
Size 104.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2727d74f6175d645b88561ed7822d470af7a995937e05de300c1cf2e7ed8d75d
BLAKE2b-256 checksum
How to use checksums
0840c7ddd9940dc550b46b524b7c72fbbd9b625252f0eb7b74e76c64eb81b8d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page