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).
This topic is applicable only to the China (Beijing) region.
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
During the fine-tuning process, the model learns business-specific or scenario-specific features from the training data, such as knowledge, tone, expression styles, and self-awareness. Because the model has already learned many examples for specific industries or scenarios during training, its one-shot or zero-shot prompt performance after training is better than its few-shot performance before training. This saves input tokens and reduces model output latency.
Model fine-tuning process
For more information, see:
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 Computing Details to view the total number of training tokens, number of epochs, and training unit price. |
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 for model deployment billing, 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.
Fine-tuning performance examples
Role assumption
| Object detection
|
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. |
|
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
Note 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 Model Deployment 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. | |
Step 7: Use the Alibaba Cloud Model Studio Model Evaluation feature to evaluate the training performance of the custom model. For more information, see Model evaluation. | |
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 termsMedical model:
Memorizes drug pathologyLegal model:
Understands legal articles and precedents
SFT (supervised fine-tuning) - Learns how to perform tasks
Customer service bot:
Learns customer service proceduresCode assistant:
Learns programming paradigmsTool calling (Agent):
Learns to use MCP
DPO (direct preference optimization) - Performs tasks better
Safety and responsibility:
Rejects harmful suggestionsConciseness and effectiveness:
Provides concise answersObjectivity and neutrality:
Evaluates fairly and objectively
Fine-tuning data format
SFT training set
SFT ChatML (Chat Markup Language) format training data supports multi-turn conversations and various role settings.
The OpenAInameandweightparameters are not supported. All assistant outputs will be trained.
# A single line of training data (in JSON format) has the following typical structure when expanded:
{"messages": [
{"role": "system", "content": "System input 1"},
{"role": "user", "content": "User input 1"},
{"role": "assistant", "content": "Expected model output 1"},
{"role": "user", "content": "User input 2"},
{"role": "assistant", "content": "Expected model output 2"}
...
]}For information about the differences between system, user, and assistant, see Overview. Sample training datasets: SFT-ChatML_format_example.jsonl, SFT-ChatML_format_example.xlsx. XLS and XLSX formats support only single-turn conversations.
All assistant lines in a single training data entry support the "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.
{"role": "assistant", "content": "Expected model output 1", "loss_weight": 1.0},
{"role": "assistant", "content": "Expected model output 2", "loss_weight": 0.5}SFT thinking model
The training data supports multi-turn conversations and various role settings, but only the last assistant output can be trained. A single line of training data has the following structure when expanded:
The newline characters \n before and after the think tag must be preserved.# A single line of training data (in JSON format) has the following typical structure when expanded:
{"messages": [
{"role": "system", "content": "System input 1"},
{"role": "user", "content": "User input 1"},
{"role": "assistant", "content": "Model output 1"}, --Intermediate assistant outputs should not have <think> tags
...
{"role": "user", "content": "User input 2"},
{"role": "assistant", "content": "<think>\nExpected thinking content 2\n</think>\n\nExpected output 2"} --Thinking content can only be included in the last assistant output.
]}For information about the differences between system, user, and assistant, see Overview. Sample training dataset: SFT-deep_thinking_content_example.jsonl.
You can also set the model not to output the <think> tag in the training samples. If you use this output method, it is not recommended to enable the thinking mode for calls after the model is trained.
{"role": "assistant", "content": "Expected model output 2"} --Tells the model not to enable thinkingThe last assistant line of a single training data entry supports the "loss_weight" parameter, which sets the relative importance of that entry 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.
{"role": "assistant", "content": "<think>\nExpected thinking content 2\n</think>\n\nExpected output 2", "loss_weight": 1.0}SFT visual understanding (Qwen-VL)
The OpenAInameandweightparameters are not supported. All assistant outputs will be trained.
For information about the differences between system, user, and assistant, see Overview. Sample ChatML format training data:
To pass asystemmessage, the correspondingcontentmust use the array format[{"text":"..."}]and not the string format"content":"string".
If you are training a thinking model, you must also follow the data format requirements for the SFT thinking model.
# A single line of training data (in JSON format) has the following structure when expanded:
{"messages": [
{"role": "system", "content": [{"text": "System input"}]},
{"role": "user", "content": [{"text": "User input 1"}, {"image": "image_file_name1.jpg", "resized_width": 200, "resized_height": 200}]},
{"role": "assistant", "content": [{"text": "Expected model output 1"}]},
{"role": "user", "content": [{"text": "User input 2"}, {"video": "video_file_name1.mp4", "fps": 3.0, "resized_width": 200, "resized_height": 200, "video_start": 0.0, "video_end": 3.0}]},
{"role": "assistant", "content": [{"text": "Expected model output 2"}]},
{"role": "user", "content": [{"text": "User input 2"}, {"video": ["0.jpg", "1.jpg", "2.jpg", "3.jpg"], "sample_fps": 5.0, "resized_width": 200, "resized_height": 200}]},
{"role": "assistant", "content": [{"text": "Expected model output 2"}]},
...
]}Suggestions for training object localization:
Qwen2.5-VL: The training coordinates are absolute values relative to the top-left corner of the scaled image, in pixels.
Qwen3-VL: The training coordinates are relative, and the coordinate values are scaled to the range of
[0, 999].
ZIP file requirements:
Format: ZIP. The maximum size is 2 GB. Folders and file names within the ZIP file must only contain ASCII characters, including letters (a-z, A-Z), numbers (0-9), underscores (_), and hyphens (-).
The training text file must be named data.jsonl and located in the root directory of the ZIP file. Ensure that the
data.jsonlfile is at the top level of the ZIP file and not in a subfolder.The width and height of a single image must not exceed 1024 pixels, and the size must not exceed 10 MB. The supported formats are
.bmp,.jpeg /.jpg,.png,.tif /.tiff, and.webp.Image file names must be unique, even if they are in different folders.
ZIP file directory structure:
Single-level directory (recommended)
The image files and the
data.jsonlfile are all located in the root directory of the ZIP file.Trainingdata_vl.zip |--- data.jsonl #Note: Do not wrap in an outer folder |--- image1.png |--- video1.mp4Multi-level directory
The data.jsonl file must be in the root directory of the ZIP file.
In the data.jsonl file, you only need to specify the image or video filename, not the file path. For example:
Correct example:
image1.jpg. Incorrect example:jpg_folder/image1.jpg.Image/video file names must be globally unique within the ZIP file.
Trainingdata_vl.zip |--- data.jsonl #Note: Do not wrap in an outer folder |--- jpg_folder | └── image1.jpg |--- mp4_folder └── video.mp4
DPO dataset
DPO ChatML format training data. A single line of training data has the following structure when expanded:
For information about the differences between system, user, and assistant, see Overview. Sample training dataset: DPO_ChatML_format_example.jsonl.
# A single line of training data (in JSON format) has the following typical structure when expanded:
{"messages": [
{"role": "system", "content": "System input"},
{"role": "user", "content": "User input 1"},
{"role": "assistant", "content": "Model output 1"},
{"role": "user", "content": "User input 2"},
{"role": "assistant", "content": "Model output 2"},
{"role": "user", "content": "User input 3"}
],
"chosen":
{"role": "assistant", "content": "Agreed-upon expected model output 3"},
"rejected":
{"role": "assistant", "content": "Rejected expected model output 3"}}The model takes all content within messages as input. DPO is used to train the model on positive and negative feedback for User input 3.
For deep thinking content, you need to wrap it with <think> tags:
{"role": "assistant", "content": "<think>Expected model thinking content</think>Expected model output"}The "chosen" module of a single training data entry supports the "loss_weight" parameter, which sets the relative importance of that training data in the training process. (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.
"chosen":
{"role": "assistant", "content": "Agreed-upon expected model output 3", "loss_weight": 1.0},CPT training set
CPT plain text format training data. A single line of training data has the following structure when expanded:
{"text":"Text content"}Sample training dataset: CPT-text_generation_training_set_example.jsonl
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.)
Use the data processing feature of Alibaba Cloud Model Studio to perform data cleaning and data augmentation on your dataset.
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. |
It is also important to note that the amount of data for each scenario/business should be relatively balanced, and the data proportion should match the actual scenario proportion. This avoids having too much data of one type, which could cause the model to be biased towards learning those features and affect its generalization ability.
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.
The console displays the validation set loss and token accuracy in real time during training.

FAQ
Can I fine-tune my own model?
Model Studio does not support fine-tuning your own models. However, you can import open source Qwen series models in safetensor format using My Models (Beijing region). For more information, see Model import. After a model is imported, you can deploy and use it on the Model Studio platform.




