You can use model fine-tuning in Alibaba Cloud Model Studio if a model's performance does not meet your expectations after you have tried optimization methods such as prompt engineering and plugin calls. As a core strategy for improving model performance, model fine-tuning can significantly enhance a model's capabilities in specific industries or business scenarios, align its outputs with human preferences, and reduce output latency. Model fine-tuning includes three training methods: supervised fine-tuning (SFT), continual pre-training (CPT), and direct preference optimization (DPO).
Introduction to model fine-tuning
Model fine-tuning is an important method for optimizing model performance. It can:
- Improve model performance in specific industries or for specific business needs
- Reduce model output latency
- Suppress model hallucination
- Align the model with human values or preferences
- Replace larger models with fine-tuned lightweight models
Model fine-tuning process
Supported models
Supported models
Supported models
- Singapore
- North China 2 (Beijing)
- Text generation
- Visual understanding (Qwen-VL)
Model name | Model code | SFT full-parameter training (sft) | SFT efficient training (efficient_sft) |
|---|---|---|---|
Qwen3-14B | qwen3-14b | × | Supported |
Comparison of tuning methods
Feature | CPT (Continual Pre-training) | SFT (Supervised Fine-tuning) | DPO (Direct Preference Optimization) |
|---|---|---|---|
Summary | Supplements knowledge (Injects domain knowledge) | Learns to perform tasks (Follows instructions) | Performs tasks better (Aligns with human preferences) |
Input data | 10 million+ tokens Unlabeled domain text | Over 1,000 entries High-quality "question-answer" pairs | 100+ sets "Better-worse" response pairs for the same instruction |
Core objective | Domain adaptation. Learns specialized vocabulary and facts. | Teaches the model conversation formats and task execution capabilities. | Makes model outputs better align with human values and preferences. |
Learning method | Self-supervised learning (Predicts the next word) | Supervised learning (Imitates the ground truth) | Direct preference learning (Increases the probability of good responses and decreases the probability of bad responses) |
Model stage | Typically before SFT | After CPT and before DPO | Typically after SFT, as the final step for alignment. |
Comparison of training patterns
Full-parameter training | Efficient training (LoRA, recommended) | |
|---|---|---|
Scenarios | • The model needs to acquire new capabilities • Achieving optimal global performance. | • Optimizing model performance for specific scenarios. • For cost-sensitive and time-sensitive scenarios. |
Training time | Longer, with slower convergence. | Shorter, with faster convergence. |
Billing
| Billing method | Pay-as-you-go based on the amount of training data |
| Billing formula | Model training fee = (Total tokens in training data + Total tokens in mixed training data) × Number of epochs × Training unit price (Minimum billing unit: 1 token)You can view the estimated training fee at the bottom of the Model Fine-tuning console and click Billing Details to view the total number of training tokens, number of epochs, and training unit price. |
Training unit price
Training unit price
- Singapore
- North China 2 (Beijing)
- Qwen
- Qwen-VL
Model service | Model code | Price |
|---|---|---|
Qwen3-14B | qwen3-14b | $0.0016/1,000 tokens |
Before you fine-tune a model
-
Although text generation model fine-tuning can achieve excellent results in specific business scenarios, it has the following limitations:
- Time-consuming: This includes creating a large-scale CPT dataset (at least 50 million tokens), building an effective SFT dataset (1,000+ entries), collecting enough bad cases (100+) to build an effective DPO dataset, and the slow speed of model optimization iterations.
- High cost: A fine-tuned model can only be used after deployment, and the model deployment billing is high.
-
Alibaba Cloud Model Studio recommends that you first try using Prompt Engineering or Function Calling to customize your application. Model fine-tuning is usually the "last resort" for improving model performance. This is because:
- In many tasks, a model may initially perform poorly, but applying the correct prompt techniques can improve the results without requiring model fine-tuning.
- Iteratively optimizing prompts and plugins is more agile and cost-effective than model fine-tuning iterations, because fine-tuning may require re-collecting, cleaning, and optimizing data, collecting bad cases, and conducting customer surveys.
- Even if you ultimately decide to perform model fine-tuning, the initial work on prompt engineering and plugin optimization will not be wasted. This preliminary work can be fully reused when building the fine-tuning dataset.
Getting started
Fine-tune a model using the console
Fine-tuning steps | Console screenshot |
|---|---|
Step 1: On the Model Fine-tuning page, click Create Training Task. | On the Create Training Task page, complete the following configurations:
|
Step 2: Configure training
This combination has a short training time and low data requirements. | |
Step 3: Configure data
| |
Step 4: Configure model parameter snapshot (checkpoint) saving parameters
After model fine-tuning is complete, you can export a parameter snapshot on the Model Studio platform. You can then deploy the model on Model Studio based on this parameter snapshot. The exported parameter snapshots are saved in cloud storage and cannot be accessed or downloaded. | |
Step 5: Click "Start Training" and wait for the model training to complete. | |
Step 6: Use the Deployments feature of Alibaba Cloud Model Studio to deploy the trained custom model. After deployment, you can evaluate the fine-tuned model. For more information, see Model deployment. | |
Typical fine-tuning process
The three fine-tuning methods provided by Model Studio are not mutually exclusive but are progressive and complementary.
CPT (optional) → SFT → DPO (optional)
-
CPT (continual pre-training) - Supplements knowledge (General models have broad but shallow knowledge, which may not meet the depth and precision requirements of professional fields)
- Finance model:
Learns financial terms - Medical model:
Memorizes drug pathology - Legal model:
Understands legal articles and precedents
- Finance model:
-
SFT (supervised fine-tuning) - Learns how to perform tasks
- Customer service bot:
Learns customer service procedures - Code assistant:
Learns programming paradigms - Tool calling (Agent):
Learns to use MCP
- Customer service bot:
-
DPO (direct preference optimization) - Performs tasks better
- Safety and responsibility:
Rejects harmful suggestions - Conciseness and effectiveness:
Provides concise answers - Objectivity and neutrality:
Evaluates fairly and objectively
- Safety and responsibility:
Fine-tuning data format
- SFT training set
The OpenAInameandweightparameters are not supported. All assistant outputs will be trained.
"loss_weight" parameter, which sets the relative importance of that line during training. (Range: 0.0 to 1.0. A larger value indicates higher importance.)This parameter is available for invitational preview. To use it, contact your account manager.
Dataset building tips
Dataset size requirements
For CPT, the dataset requires at least 50 million tokens of high-quality pre-training data. For SFT, the dataset requires at least 1,000 high-quality fine-tuning data entries. For DPO, the dataset generally requires hundreds of human preference data entries. If the model evaluation results after data fine-tuning are not satisfactory, the simplest way to improve is to collect more data for training.
If you lack data, we recommend building an agent application and using a knowledge base index to enhance the model's capabilities. In many complex business scenarios, you can also use a combination of model fine-tuning and knowledge base retrieval.
For example, in a customer service scenario, you can use model fine-tuning to address issues with the customer service agent's tone, expression styles, and self-awareness. Professional knowledge related to the scenario can be dynamically introduced into the model's context using a knowledge base.
Alibaba Cloud Model Studio recommends that you first build and test a retrieval-augmented generation (RAG) application. After collecting enough application data, you can then use model fine-tuning to further improve the model's performance.
You can also use the following strategies to expand your dataset:
- Use a large language model (LLM) to simulate the generation of content for specific business scenarios to help you generate more data for fine-tuning. (We recommend selecting a larger, high-performing model for generation.)
- Acquire more data through various methods, such as collecting from application scenarios, web scraping, social media and online forums, public datasets, partners and industry resources, and user contributions.
Data diversity and balance
The requirements for model fine-tuning vary by scenario. For example, professionalism is critical for specific business scenarios, whereas versatility is more important for Q&A scenarios. You need to design data use cases based on the business modules or usage scenarios the model is responsible for. Therefore, the training effectiveness depends not only on the data volume but also on the professionalism and diversity of the data for the specific scenario.
For example, in an intelligent AI conversation scenario, a professional and diverse dataset should include the following business scenarios:
Specific business | Diverse scenarios/businesses |
|---|---|
E-commerce customer service | Promotion pushes, pre-sales consultation, in-sales guidance, after-sales service, after-sales follow-up, complaint handling, etc. |
Financial services | Loan consultation, investment and wealth management advice, credit card services, bank account management, etc. |
Online healthcare | Symptom consultation, appointment registration, visit instructions, drug information inquiry, health tips, etc. |
AI secretary | IT information, administrative information, HR information, employee benefit inquiries, company calendar queries, etc. |
Travel assistant | Travel planning, entry and exit guides, travel insurance consultation, destination customs and culture introductions, etc. |
Corporate legal counsel | Contract review, intellectual property protection, compliance checks, labor law Q&A, cross-border transaction consultation, individual case legal analysis, etc. |
Splitting the training and validation sets
You can perform model fine-tuning in the console.
- Automatically split a complete training dataset and randomly sample a small amount of data to form a validation set.
- Choose to upload a separate dataset.