Beginner

Hugging Face Spaces

Spaces are hosted web applications on the Hugging Face platform. They let you turn any AI model into a shareable interactive demo — no server setup, no infrastructure. Over 1 million Spaces are publicly available as of May 2026.

What Spaces Are

A Space is a Git repository that runs a web app. You push code + a configuration file, and Hugging Face builds and deploys it automatically. Think of it like Vercel or GitHub Pages, but purpose-built for AI demos.

Spaces are used to:

  • Demo a newly released model alongside a paper
  • Let non-technical users try a model without code
  • Build quick internal tools (image classifiers, document summarizers)
  • Host evaluation leaderboards (the LMSYS Chatbot Arena runs as a Space)
  • Prototype AI apps before moving to production infrastructure

Gradio vs Streamlit

Gradio (recommended for AI)
  • Built specifically for ML demos
  • Native support for images, audio, video, chat UIs
  • Auto-generates a shareable link for any function
  • Built-in API endpoint (everything Gradio exposes is also callable as an API)
  • Maintained by Hugging Face — tightest integration
  • 10 lines of code for a working demo
Streamlit
  • More flexible — arbitrary UI layouts
  • Good for data dashboards alongside AI features
  • Larger ecosystem of components
  • More Python-first; feels more like a web app
  • Better for complex multi-page apps
  • Slightly more boilerplate than Gradio for simple demos

Minimal Gradio Space

# app.py — the entire app
import gradio as gr
from transformers import pipeline

summarizer = pipeline("summarization", model="facebook/bart-large-cnn")

def summarize(text):
    return summarizer(text, max_length=130, min_length=30)[0]["summary_text"]

demo = gr.Interface(fn=summarize, inputs="text", outputs="text", title="Text Summarizer")
demo.launch()
# requirements.txt
gradio
transformers
torch

Push these two files to your Space repository and Hugging Face builds and deploys it automatically. The Space gets a public URL at huggingface.co/spaces/your-username/your-space-name.

Hardware Tiers

TierHardwareCostNotes
Free CPU2 vCPU + 16 GB RAMFreeDefault. Good for lightweight demos, no GPU-heavy models.
ZeroGPUShared A100 GPUFreeGPU allocated per request, not continuously. Great for demos — free A100 time.
T4 SmallNVIDIA T4 (16 GB)~$0.60/hrSmallest dedicated GPU. Good for 7B models.
A10G SmallNVIDIA A10G (24 GB)~$1.05/hrMedium GPU. Good for 13B models or image generation.
A100 LargeNVIDIA A100 (80 GB)~$3.15/hrLarge models, high-throughput. Production-grade.

ZeroGPU — Free A100 Time

ZeroGPU is a feature that gives Spaces free GPU time on A100 hardware — allocated per inference request rather than continuously. This is one of the most cost-effective features on the platform: you can demo a model that requires an A100 without paying for a dedicated GPU.

To use ZeroGPU, your Space must be a Gradio app. Decorate the GPU-intensive function with @spaces.GPU:

import spaces
import gradio as gr
import torch
from transformers import pipeline

@spaces.GPU
def generate(prompt):
    pipe = pipeline("text-generation", model="meta-llama/Llama-3.2-3B-Instruct",
                    torch_dtype=torch.float16, device="cuda")
    return pipe(prompt, max_new_tokens=200)[0]["generated_text"]

gr.Interface(fn=generate, inputs="text", outputs="text").launch()

Private Spaces

Spaces can be set to private — only visible to you and collaborators. This is useful for internal tools or work-in-progress demos that aren't ready for public sharing. Private Spaces require a paid Hugging Face Pro or Enterprise account.

Checklist: Do You Understand This?

  • Can you explain what a Hugging Face Space is in one sentence?
  • Do you know the difference between Gradio and Streamlit for building Spaces?
  • Can you create a minimal Gradio Space from scratch (app.py + requirements.txt)?
  • Do you understand what ZeroGPU is and when to use it?
  • Do you know what hardware tier to choose for a 7B vs 70B model demo?

Page built: 01 Jun 2026