
Hugging Face — User Guide
Models and datasets hub—the open-source AI community home.
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.
Find the right model for your task
(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
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
Give priority to models with high download volume and detailed Model Cards, so the quality is more guaranteed.
Use the Transformers library to quickly call models
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
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.
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.
Experience the latest image generation models
(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"
Generate high-quality images directly in the browser,
No need to install any software,
Experience the latest image generation model for free.
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.
LoRA fine-tuning using PEFT
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
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
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
| Tool | Strength | Best for | Pricing |
|---|---|---|---|
| Hugging Face This tool | The largest number of models, the most active community, and the most complete tool chain | AI researchers, ML engineers, developers who need open source models | Free / Pro $9/month / Enterprise customization |
| Replicate | No environment configuration required, API calls are simple | Quickly call model APIs without having to manage infrastructure | Pay as you go |
| Together AI | Open source model inference is fast and cheap | Need low-latency, low-cost open source model inference | Pay by token |
| Ollama | Run locally, data privacy guaranteed | Scenarios that require local deployment and data not leaving the country | completely free |
Sources & references:
- Hugging Face official documentation (2025-03)
- Transformers library documentation (2025-03)
- Hugging Face Course (Free) (2025-03)