Hugging Face

Hugging Face — User Guide

Models and datasets hub—the open-source AI community home.

Visit website VPN may be required Freemium Sign-up required
Strengths
  • 500,000+ open source models, covering all AI fields such as NLP, CV, audio, etc.
  • The Transformers library is an industry-standard tool for deep learning
  • The Spaces platform allows you to deploy and experience AI applications for free
  • Data set warehouse to facilitate model training and evaluation
  • Active developer community, detailed model documentation
Best for
  • Find and download pre-trained models (BERT, LLaMA, Stable Diffusion, etc.)
  • Use the Transformers library for model inference and fine-tuning
  • Experience various AI demos on Spaces
  • Upload and share your own trained models
  • Find high-quality training data sets

Find and use pretrained models

Hugging Face's model warehouse is the world's largest AI model library. Learning to search and use models is the first step.

Scenario

Find the right model for your task

Prompt example
(On the Hugging Face model search page)




Search strategy:


1. Enter the task type in the search box, such as "text-classification"


2. Use filters: Sort by language (Chinese), task type, download volume


3. View the Model Card to learn how to use it


4. See "Files and versions" for model sizes
Output / what to expect

Find a suitable Chinese text classification model, such as hfl/chinese-roberta-wwm-ext,

Model cards contain:

  • Model introduction and applicable scenarios

  • Use code examples

  • Performance evaluation results

  • License information

Tips

Give priority to models with high download volume and detailed Model Cards, so the quality is more guaranteed.

Scenario

Use the Transformers library to quickly call models

Prompt example
Please show how to use the Hugging Face Transformers library for Chinese
sentiment analysis:




Requirements:


- Use pipeline API (easiest way)


- Choose a sentiment analysis model suitable for Chinese


- Process a batch of text and output the results


- Code can be run directly
Output / what to expect
from transformers import pipeline

#Load Chinese sentiment analysis model
classifier = pipeline(
    "text-classification",
    model="lxyuan/distilbert-base-multilingual-cased-sentiments-student"
)

texts = [
    "This product is really easy to use, highly recommended!",
    "The quality is very poor and not worth the price.",
    "It's okay, so-so."
]

results = classifier(texts)
for text, result in zip(texts, results):
    print(f"Text: {text}")
    print(f"Sentiment: {result['label']}, Confidence: {result['score']:.3f}\n")

Output the sentiment label (positive/negative) and confidence of each text.

Tips

The pipeline API is the simplest way to use it and is suitable for rapid prototyping. In the production environment, it is recommended to load the model directly.

Try the AI ​​Demo in Spaces

There are tens of thousands of free AI demos on Hugging Face Spaces, so you can experience various models without writing code.

Scenario

Experience the latest image generation models

Prompt example
(Visit huggingface.co/spaces)




Search steps:


1. Search "Stable Diffusion XL" or "FLUX" in Spaces


2. Select the Running Space


3. Enter the image description in the text box


4. Click Generate and wait for the result




Example prompt:


"A serene mountain lake at sunset, photorealistic,


8k resolution, golden hour lighting"
Output / what to expect

Generate high-quality images directly in the browser,

No need to install any software,

Experience the latest image generation model for free.

Tips

Choose GPU-accelerated Space (marked with the 🚀 icon) to build faster.

Model fine-tuning and training

Hugging Face provides a complete model fine-tuning tool chain, suitable for developers with a certain AI foundation.

Scenario

LoRA fine-tuning using PEFT

Prompt example
Please show how to use the Hugging Face PEFT library for LoRA fine-tuning
on an LLaMA model:




Task: Fine-tune a Chinese question answering model


Hardware: Single A100 GPU (40GB)




Request to show:


1. Dataset preparation format


2. LoRA configuration parameters


3. Training code framework


4. How to save and upload the fine-tuned model
Output / what to expect

Shows the complete LoRA fine-tuning code framework, including:

  • Dataset format (instruction-input-output format)

  • LoRA configuration (rank=16, alpha=32 and other parameters)

  • Trainer training loop

  • Code for model saving and pushing to Hub

Tips

LoRA fine-tuning can significantly reduce graphics memory requirements, and the 8B parameter model can be fine-tuned on a single 24GB GPU.

Compared with similar tools

ToolStrengthBest forPricing
Hugging Face This toolThe largest number of models, the most active community, and the most complete tool chainAI researchers, ML engineers, developers who need open source modelsFree / Pro $9/month / Enterprise customization
ReplicateNo environment configuration required, API calls are simpleQuickly call model APIs without having to manage infrastructurePay as you go
Together AIOpen source model inference is fast and cheapNeed low-latency, low-cost open source model inferencePay by token
OllamaRun locally, data privacy guaranteedScenarios that require local deployment and data not leaving the countrycompletely free