Hugging Face Guide 2025: Models, Spaces & Inference API
A practical guide for ML engineers and developers — browsing the model hub, downloading with transformers, using the serverless Inference API, hosting Gradio demos in Spaces, and choosing between Hugging Face, Replicate, and Together AI.
What Is Hugging Face?
Hugging Face is the GitHub of machine learning. It provides:
- Model Hub — 500,000+ pre-trained models: LLMs, image generation, speech-to-text, embeddings, translation
- Datasets Hub — 100,000+ datasets for training and evaluation
- Spaces — 200,000+ interactive demos built with Gradio or Streamlit, hosted free
- Inference API — run any model via HTTP without managing GPUs, with both serverless and dedicated endpoints
- transformers library — the Python library that powers most of the ecosystem
Browsing and Finding Models
Go to huggingface.co/models and filter by:
- Task — text-generation, text-classification, image-to-text, automatic-speech-recognition, sentence-similarity
- Library — transformers, diffusers, timm, sentence-transformers
- License — apache-2.0, mit, llama3 (gated)
- Language — en, zh, multilingual
Model cards show downloads/month, last commit date, and whether the model is gated (requires license acceptance + HF token). Sort by "Most Downloads" for the most-used models in each category.
Downloading Models with transformers
# Install
pip install transformers torch accelerate
# Run a text generation model
from transformers import pipeline
# Downloads ~280MB to ~/.cache/huggingface/hub/
generator = pipeline("text-generation", model="microsoft/Phi-3-mini-4k-instruct")
result = generator("The key advantage of transformers is", max_new_tokens=100)
print(result[0]["generated_text"]) # Lower-level: from_pretrained for full control
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "meta-llama/Llama-3.2-1B-Instruct"
tokenizer = AutoTokenizer.from_pretrained(model_id, token="hf_YOUR_TOKEN")
model = AutoModelForCausalLM.from_pretrained(
model_id,
token="hf_YOUR_TOKEN",
torch_dtype=torch.bfloat16,
device_map="auto" # uses GPU if available
)
inputs = tokenizer("Explain neural networks in simple terms:", return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=200)
print(tokenizer.decode(outputs[0], skip_special_tokens=True)) Gated models (Llama 3, Gemma 2, etc.): Accept the license on the model page, then set HF_TOKEN=hf_... environment variable or pass token="hf_..." to from_pretrained. Generate tokens at huggingface.co/settings/tokens.
Inference API (Serverless & Dedicated)
Run any Hub model via HTTP without downloading it. Free tier has rate limits; Pro unlocks higher limits:
# Python with huggingface_hub
pip install huggingface_hub
from huggingface_hub import InferenceClient
client = InferenceClient(token="hf_YOUR_TOKEN")
# Text generation (serverless — shared GPU, may queue)
result = client.text_generation(
"Translate to French: The weather is nice today.",
model="mistralai/Mistral-7B-Instruct-v0.3",
max_new_tokens=100
)
print(result) # Dedicated Endpoints — always-on, your own GPU
# Create at: ui.endpoints.huggingface.co
# Then use the endpoint URL:
client = InferenceClient(
model="https://YOUR-ENDPOINT.endpoints.huggingface.cloud"
)
result = client.text_generation("Hello, world!", max_new_tokens=50) Spaces — Host ML Demos Free
Spaces let you deploy Gradio or Streamlit apps on Hugging Face infrastructure — free public hosting for demos. Create one at huggingface.co/new-space:
# Example: Gradio Space (app.py)
import gradio as gr
from transformers import pipeline
classifier = pipeline("sentiment-analysis")
def analyze(text):
result = classifier(text)[0]
return f"{result['label']} ({result['score']:.2f})"
demo = gr.Interface(fn=analyze, inputs="text", outputs="text")
demo.launch() Free Spaces use a 2-vCPU / 16GB RAM CPU container. They sleep after 48h of inactivity. Pro ($9/mo) or ZeroGPU grants keep them always-on. For GPU Spaces, choose a hardware tier at deployment time (T4 ~$0.60/hr, A10G ~$1.05/hr).
GGUF Models for Local Use
For local inference with Ollama or LM Studio, download GGUF quantized models from the Hub:
# Search: filter by tag "GGUF" on huggingface.co/models # Popular providers: bartowski, TheBloke, ggml-org # Download a single file with huggingface_hub CLI: pip install "huggingface_hub[cli]" huggingface-cli download \ bartowski/Llama-3.2-3B-Instruct-GGUF \ Llama-3.2-3B-Instruct-Q4_K_M.gguf \ --local-dir ./models # Then run with Ollama (ollama run) or llama.cpp: # ./llama-cli -m models/Llama-3.2-3B-Instruct-Q4_K_M.gguf -p "Hello" -n 100
For more on local LLMs, see our Ollama guide and Llama guide.
Pricing: Free vs Pro vs Enterprise
| Plan | Price | Key Limits |
|---|---|---|
| Free | $0 | Rate-limited Inference API, Spaces sleep, public repos only |
| Pro | $9/mo | Higher Inference API limits, always-on Spaces, private repos (3) |
| Enterprise | $20/seat/mo | SSO, private hub, audit logs, SLAs, Dedicated Endpoints included |
Dedicated Endpoints (always-on GPU instances) are billed separately based on hardware tier and hours used — independent of your account plan.
HF vs Replicate vs Together AI
| Factor | Hugging Face | Replicate | Together AI |
|---|---|---|---|
| Model catalog | 500k+ (everything) | Community curated | 100+ popular LLMs |
| Cold start | Variable (serverless) | 5s-3min | Warm (fast) |
| Custom models | ✅ Easy deploy | ✅ Custom Docker | ❌ Pre-selected only |
| Free tier | ✅ Rate-limited | ✅ $0.005 credit | ✅ 60 RPM/day |
| Best for | Research, wide access | Image/video generation | Fast LLM inference |
Monitor Hugging Face Status
Hugging Face Spaces and the Inference API have occasional outages. Prismix monitors Hugging Face availability in real-time and sends alerts when something goes down.
Monitor Hugging Face Free →