Fine-tune with the API or CLI

更新时间:
复制 MD 格式

Learn how to tune Qwen models in Alibaba Cloud Model Studio using the API (HTTP) and the command line (shell). Model tuning involves three methods: supervised fine-tuning (SFT), continual pre-training (CPT), and direct preference optimization (DPO).

Important

This topic is applicable only to the China (Beijing) region.

Prerequisites

Note

The API supports only token-based billing for training jobs. To use model training units (prepaid or postpaid), create the job in the console.

Tuning file upload

Preparing fine-tuning files

SFT training set

The SFT training set uses the ChatML (Chat Markup Language) format, which supports multi-turn conversations and various role settings.

The OpenAI parameters name and weight are not supported. All assistant outputs are used for training.
# A typical line of expanded JSON training data:
{"messages": [
  {"role": "system", "content": "System input 1"}, 
  {"role": "user", "content": "User input 1"}, 
  {"role": "assistant", "content": "Desired model output 1"}, 
  {"role": "user", "content": "User input 2"}, 
  {"role": "assistant", "content": "Desired model output 2"}
  ...
]}

For details on the system, user, and assistant roles, see Overview. For training dataset samples, see SFT-ChatML Format Sample.jsonl and SFT-ChatML Format Sample.xlsx. Note that the XLS and XLSX formats support only single-turn conversations.

In a single training example, all assistant messages support the "loss_weight" parameter. This parameter sets the message's relative importance during training. The value ranges from 0.0 to 1.0, where a higher value indicates greater importance.

This is a beta parameter. To use it, please contact your account manager.
 {"role": "assistant", "content": "Desired model output 1", "loss_weight": 1.0}, 
 {"role": "assistant", "content": "Desired model output 2", "loss_weight": 0.5}

SFT thinking model

The training data supports multi-turn conversations and various role settings, but the model trains only on the last assistant output. Each expanded line of training data has the following structure:

The newline characters \n before and after the tag must be preserved.
# A single line of training data (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 must not include <think> tags.
   ...
  {"role": "user", "content": "User input 2"}, 
  {"role": "assistant", "content": "<think>\nDesired thinking content 2\n</think>\n\nDesired output 2"} --Include thinking content only in the final assistant output. 
]}

For details on the system, user, and assistant roles, see Overview. For a training dataset sample, see SFT-Deep Thinking Content Sample.jsonl.

You can also provide training examples without the <think> tag. If you use this method, we do not recommend enabling thinking mode for inference after training.

{"role": "assistant", "content": "Desired model output 2"}  --Instructs the model not to enable thinking.

In a single training example, the final assistant message supports the "loss_weight" parameter. This parameter sets the message's relative importance during training. The value ranges from 0.0 to 1.0, where a higher value indicates greater importance.

This is a beta parameter. To use it, please contact your account manager.
 {"role": "assistant", "content": "<think>\nDesired thinking content 2\n</think>\n\nDesired output 2", "loss_weight": 1.0}

SFT for visual understanding

The OpenAI parameters name and weight are not supported. All assistant outputs are used for training.

For the differences between system, user, and assistant, see Overview. The following is an example of training data in the ChatML format:

If you pass a system message, its content must use the array format [{"text":"..."}]. The string format "content":"string" is not supported.
# A typical line of expanded JSON training data:
{"messages": [
  {"role": "system", "content": [{"text": "System input"}]},
  {"role": "user", "content": [{"text": "User input 1"}, {"image": "image_filename_1.jpg", "resized_width": 200, "resized_height": 200}]},
  {"role": "assistant", "content": [{"text": "Desired model output 1"}]},
  {"role": "user", "content": [{"text": "User input 2"}, {"video": "video_filename_1.mp4", "fps": 3.0, "resized_width": 200, "resized_height": 200, "video_start": 0.0, "video_end": 3.0}]},
  {"role": "assistant", "content": [{"text": "Desired 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": "Desired model output 2"}]},
  ...
]}

More supported parameters

Parameter

Type

Required

Description

Image file

image

str

Yes

The path to the image file.

resized_width

int

No

The target width of the resized image, in pixels.

resized_height

int

No

The target height of the resized image, in pixels.

Video file - File path mode (Supported on Qwen-VL models qwen3.5 and later)

Example: Aliyun_VL_Video.zip

video

str

Yes

File path mode for videos: {"video": "video_filename_1.mp4"}

resized_width

int

No

The target width of the resized video, in pixels.

resized_height

int

No

The target height of the resized video, in pixels.

fps

float

No

The frame rate for training, in frames per second (FPS). For example, a value of 30 sets the rate to 30 FPS.

video_start

float

No

The start time for video trimming, in seconds.

video_end

float

No

The end time for video trimming, in seconds.

Video file - Image frame list mode (Supported on Qwen-VL models qwen3.5 and later)

video

List[str]

Yes

Image frame list mode for videos: {"video": ["0.jpg", "1.jpg", "2.jpg", ...], "sample_fps": 2.0}

sample_fps

float

No

Specifies the frame rate of the image frames.

resized_width

int

No

The target width of the resized image frames, in pixels.

resized_height

int

No

The target height of the resized image frames, in pixels.

Note

When training a thinking model, also follow the data format requirements for the SFT thinking model.

ZIP file requirements
  1. The ZIP file must be 2 GB or smaller. Folder and file names within it must contain only ASCII letters (a-z, A-Z), digits (0-9), underscores (_), and hyphens (-).

  2. Place the training text file, named data.jsonl, in the root directory of the ZIP file.

  3. Each image must be 10 MB or smaller, with dimensions no greater than 1024x1024 pixels. Supported formats include .bmp, .jpeg/.jpg, .png, .tif/.tiff, or .webp.

  4. Image file names must be unique within the ZIP file, even if they are in different folders.

  5. ZIP file directory structure:

    Single-level directory (recommended)

    Place image and video files in the root directory with the data.jsonl file.

    Trainingdata_vl.zip
       |--- data.jsonl # Note: Do not place this file inside another folder.
       |--- image1.png
       |--- video1.mp4
    Multi-level directory
    1. The data.jsonl file must be in the root directory.

    2. In data.jsonl, you only need to declare the image or video filename, not the file path. For example:

      Correct: image1.jpg; Incorrect: jpg_folder/image1.jpg.

    3. Image and video filenames must be unique across the entire ZIP file.

    Trainingdata_vl.zip
        |--- data.jsonl # Note: Do not place this file inside another folder.
        |--- jpg_folder
        |   └── image1.jpg
        |--- mp4_folder
            └── video.mp4

DPO dataset

The DPO dataset uses the ChatML format. Each expanded line of training data has the following structure:

For details on the system, user, and assistant roles, see Overview. For a training dataset sample, see DPO ChatML Format Sample.jsonl.

# A typical line of expanded JSON training data:
{"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": "The chosen model output for Input 3"},
 "rejected":
   {"role": "assistant", "content": "The rejected model output for Input 3"}}

The model uses all content within messages as input. DPO then trains the model to prefer the chosen response over the rejected response for the final user input.

To include thinking content, wrap it with the <think> tag:

{"role": "assistant", "content": "<think>Desired model thinking content</think>Desired model output"}

The "chosen" module of a single training data sample supports the "loss_weight" parameter, which sets the relative importance of that sample during training. (The valid range is 0.0 to 1.0, where a larger value indicates higher importance.)

This is a beta parameter. To use it, please contact your account manager.
 "chosen":
   {"role": "assistant", "content": "The chosen model output for Input 3", "loss_weight": 1.0},

CPT training set

The CPT training set uses the plain text format. Each line of training data has the following structure:

{"text":"Text content"}

For a training dataset sample, see CPT-Text Generation Training Set Sample.jsonl.

You can also download a data template from the Model Studio console.

image

Upload fine-tuning file to Model Studio

DashScope API

For Windows CMD, replace ${DASHSCOPE_API_KEY} with %DASHSCOPE_API_KEY%. For PowerShell, replace it with $env:DASHSCOPE_API_KEY.
curl --request POST \
'https://dashscope.aliyuncs.com/api/v1/files' \
--header 'Authorization: Bearer '${DASHSCOPE_API_KEY} \
--form 'files=@"/path/to/your/file.jsonl"' \
--form 'purpose="fine-tune"' \
--form 'descriptions="a sample fine-tune data file for qwen"'
Note

Limitations:

  • The maximum size of a single file is 300 MB.

  • The total size of all non-deleted files is limited to 5 GB.

  • You can store a maximum of 100 non-deleted files.

  • Files are stored indefinitely.

For more details, see model fine-tuning file management service.

Sample response:

{
  "request_id":"xx",
  "data":{
    "uploaded_files":[{
      "file_id":"976bd01a-f30b-4414-86fd-50c54486e3ef",
      "name":"qwen-fine-tune-sample.jsonl"}],
   "failed_uploads":[]}
 }

Model fine-tuning

Create a fine-tuning job

HTTP

For Windows CMD, replace ${DASHSCOPE_API_KEY} with %DASHSCOPE_API_KEY%. For PowerShell, use $env:DASHSCOPE_API_KEY.
curl --location "https://dashscope.aliyuncs.com/api/v1/fine-tunes" \
--header "Authorization: Bearer ${DASHSCOPE_API_KEY}" \
--header 'Content-Type: application/json' \
--data '{
    "model":"qwen3-8b",
    "training_file_ids":[
        "<your_training_file_id_1>",
        "<your_training_file_id_2>"
    ],
    "hyper_parameters":
    {
        "n_epochs": 3,
        "batch_size": 16,
        "max_length": 8192,
        "learning_rate": "1.6e-5",
        "lr_scheduler_type": "linear",
        "split": 0.9,
        "warmup_ratio": 0.05,
        "eval_steps": 50,
        "data_augmentation": true,
        "augmentation_ratio": "0.1,0.05,0.15",
        "augmentation_types": "dialogue_CN,general_purpose_CN,NLP",
        "save_strategy": "epoch",
        "save_total_limit": 10
    },
    "training_type":"sft"
}'

Parameters

Parameter

Required

Type

Location

Description

training_file_ids

Yes

Array

Body

A list of file IDs for the training set.

validation_file_ids

No

Array

Body

A list of file IDs for the validation set.

model

Yes

String

Body

The ID of the base model for fine-tuning, or the ID of a previously fine-tuned model.

hyper_parameters

No

Map

Body

Hyperparameters for the fine-tuning job. Supported parameters and their default values vary by model. To view the default values, go to the console and select the same model and fine-tuning method.

The following parameters are required because they affect the training cost: n_epochs (number of epochs), batch_size (batch size), and max_length (sequence length).

training_type

No

String

Body

Specifies the fine-tuning method. Valid values are:

cpt

sft

efficient_sft

dpo_full

dpo_lora

job_name

No

String

Body

Specifies the name of the fine-tuning job.

model_name

No

String

Body

Specifies the name of the fine-tuned model. This is not the model ID, which is generated by the system.

Response

{
    "request_id": "635f7047-003e-4be3-b1db-6f98e239f57b",
    "output":
    {
        "job_id": "ft-202511272033-8ae7",
        "job_name": "ft-202511272033-8ae7",
        "status": "PENDING",
        "finetuned_output": "qwen3-8b-ft-202511272033-8ae7",
        "model": "qwen3-8b",
        "base_model": "qwen3-8b",
        "training_file_ids":
        [
            "9e9ffdfa-c3bf-436e-9613-6f053c66aa6e"
        ],
        "validation_file_ids":
        [],
        "hyper_parameters":
        {
            "n_epochs": 3,
            "batch_size": 16,
            "max_length": 8192,
            "learning_rate": "1.6e-5",
            "lr_scheduler_type": "linear",
            "split": 0.9,
            "warmup_ratio": 0.05,
            "eval_steps": 50,
            "data_augmentation": true,
            "augmentation_ratio": "0.1,0.05,0.15",
            "augmentation_types": "dialogue_CN,general_purpose_CN,NLP",
            "save_strategy": "epoch",
            "save_total_limit": 10
        },
        "training_type": "sft",
        "create_time": "2025-11-27 20:33:15",
        "workspace_id": "llm-8v53etv3hwb8orx1",
        "user_identity": "1654290265984853",
        "modifier": "1654290265984853",
        "creator": "1654290265984853",
        "group": "llm",
        "max_output_cnt": 10
    }
}

Base models (model) and training types (training_type)

Supported models
Text generation

Model service

Model code

Full-parameter CPT (cpt)

Full-parameter SFT (sft)

Efficient SFT (efficient_sft)

Full-parameter DPO (dpo_full)

Efficient DPO (dpo_lora)

Qwen3.6-Flash-2026-04-16

qwen3.6-flash-2026-04-16

×

Supported

×

×

×

Qwen3.5-27B

qwen3.5-27b

×

Supported

Supported

×

×

Qwen3.5-9B

qwen3.5-9b

×

Supported

Supported

×

×

Qwen3.5-Flash-2026-02-23

qwen3.5-flash-2026-02-23

×

Supported

×

×

×

Qwen3-32B

qwen3-32b

Supported

Supported

Supported

Supported

Supported

Qwen3-30B-A3B-Instruct-2507

qwen3-30b-a3b-instruct-2507

Supported

Supported

Supported

×

×

Qwen3-14B

qwen3-14b

×

Supported

Supported

Supported

Supported

Qwen3-8B

qwen3-8b

×

Supported

Supported

Supported

Supported

Qwen3-4B-Instruct-2507

qwen3-4b-instruct-2507

Supported

Supported

Supported

Supported

Supported

Qwen3-1.7B

qwen3-1.7b

Supported

Supported

Supported

Supported

Supported

Qwen3-0.6B

qwen3-0.6b

Supported

Supported

Supported

Supported

Supported

Qwen2.5-72B-Instruct

qwen2.5-72b-instruct

Supported

Supported

Supported

Supported

Supported

Qwen2.5-32B-Instruct

qwen2.5-32b-instruct

Supported

Supported

Supported

Supported

Supported

Qwen2.5-14B-Instruct

qwen2.5-14b-instruct

Supported

Supported

Supported

Supported

Supported

Qwen2.5-7B-Instruct

qwen2.5-7b-instruct

Supported

Supported

Supported

Supported

Supported

Qwen-Plus-Character-2025-11-06

qwen-plus-character-2025-11-06

×

Supported

Supported

Supported

Supported

-Base indicates that the model has only completed pre-training. While it contains extensive knowledge, it has not been fine-tuned for conversation.
Visual understanding (Qwen-VL)

Model service

Model code

Full-parameter CPT (cpt)

Full-parameter SFT (sft)

Efficient SFT (efficient_sft)

Full-parameter DPO (dpo_full)

Efficient DPO (dpo_lora)

Qwen3-VL-8B-Instruct

qwen3-vl-8b-instruct

×

Supported

Supported

×

×

Qwen3-VL-8B-Thinking

qwen3-vl-8b-thinking

×

Supported

Supported

×

×

Qwen3-VL-4B-Instruct

qwen3-vl-4b-instruct

×

Supported

Supported

×

×

Qwen2.5-VL-72B-Instruct

qwen2.5-vl-72b-instruct

×

Supported

Supported

×

×

Qwen2.5-VL-32B-Instruct

qwen2.5-vl-32b-instruct

×

Supported

Supported

×

×

Qwen2.5-VL-7B-Instruct

qwen2.5-vl-7b-instruct

×

Supported

Supported

×

×

-Base indicates that the model has only completed pre-training. While it contains extensive knowledge, it has not been fine-tuned for conversation.
Tuning method comparison

Feature

CPT (continual pre-training)

SFT (supervised fine-tuning)

DPO (direct preference optimization)

Core concept

Inject knowledge(injects domain knowledge)

Teach skills(trains the model to follow instructions)

Refine behavior(aligns the model with human preferences)

Data requirements

10M+ tokens

Unlabeled domain-specific text

1,000+

High-quality instruction-response pairs

100+

Preference pairs (chosen vs. rejected responses)

Primary objective

Domain adaptation to learn new vocabulary and facts.

Teach the model to follow conversational formats and execute specific tasks.

Align model outputs with human values and preferences.

Learning approach

self-supervised learning(predicts the next token)

supervised learning(imitates a reference answer)

Direct Preference Optimization(increases the likelihood of the preferred response over the rejected one)

When to use

Typically used before SFT.

Used after CPT and before DPO.

Typically used after SFT as a final alignment step.

Training mode comparison

Full-parameter fine-tuning

Efficient fine-tuning (LoRA)

Use cases

• To teach the model new capabilities.

• To achieve the best overall performance.

• To optimize model performance for a specific use case.

• For time- and cost-sensitive applications.

Training time

Longer training time and slower convergence speed.

Shorter training time and faster convergence speed.

hyper_parameters: Supported settings

Supported parameters and their default values vary by model. To view specific default values, go to the console and select the model and training method.

Parameter

Recommended setting

Type

Description

n_epochs

(Number of epochs) [Required]

Data size < 10,000: 3–5

Data size > 10,000: 1–2

Integer

The number of times the model iterates over the entire training set. Adjust this value based on your fine-tuning experience.

More epochs increase training time and cost.

learning_rate

(Learning rate)

Use the recommended default value provided by Model Studio.

Float

Controls the step-size for weight updates during training.

  • A high learning rate can cause training to diverge, yielding poor results.

  • A low learning rate can result in slow training and minimal performance improvement.

freeze_vit

(Freeze visual backbone)

Adjust as needed

Boolean

Whether to freeze the visual backbone parameters, which prevents their weights from being updated during training. This parameter applies only to Qwen-VL (visual understanding) models.

Warning

Billing by token usage is available only when freeze_vit is set to "true".

batch_size

(Batch size) [Required]

Use the recommended default value provided by Model Studio.

Integer

Specifies the number of training examples processed in one iteration. A small value can significantly increase training time. Default values vary by model; check the console for details.

eval_steps

(Evaluation steps)

Adjust as needed

Integer

The step interval for evaluating the model's training accuracy and loss.

This parameter affects how often Validation Loss and Validation Token Accuracy are displayed during fine-tuning.

logging_steps

(Logging steps)

Adjust as needed

Integer

The step interval for logging fine-tuning progress.

lr_scheduler_type

(Learning rate scheduler)

Recommended linear/Inverse_sqrt

String

The strategy for dynamically adjusting the learning rate during training.

For details about each strategy, see Fine-tune a model in the console.

max_length

(Sequence length) [Required]

8192

Integer

The maximum sequence length (in tokens) for a single training example. Examples that exceed this length are discarded.

For the relationship between characters and tokens, see How to convert between tokens and characters.

max_split_val_dataset_sample

(Max validation set samples)

Use the recommended default value provided by Model Studio.

Integer

When "validation_file_ids" is not set, the validation set that is automatically split by Model Studio contains a maximum of 1,000 entries.

This parameter has no effect when "validation_file_ids" is set.

split

(Training set ratio)

Use the recommended default value provided by Model Studio.

Float

If you do not set "validation_file_ids", Alibaba Cloud Model Studio automatically uses 80% of the training file as the training set and 20% as the validation set.

When "validation_file_ids" is set, this parameter has no effect.

warmup_ratio

(Warm-up ratio)

Use the recommended default value provided by Model Studio.

Float

The proportion of the total training process used for learning rate warm-up. During warm-up, the learning rate linearly increases from a small initial value to the specified learning rate.

This parameter helps stabilize training by limiting large parameter changes at the beginning.

A ratio that is too high has an effect similar to a low learning rate, causing minimal performance changes.

A ratio that is too low has an effect similar to a high learning rate and may degrade model performance.

This parameter has no effect if the learning rate scheduler is set to constant.

weight_decay

(Weight decay)

Use the recommended default value provided by Model Studio.

Float

The strength of L2 regularization. Regularization helps maintain the model's generalization ability. An excessively high value can reduce fine-tuning effectiveness.

Parameters for efficient fine-tuning (supports efficient_sft and dpo_lora)

Note

When you perform a second round of efficient fine-tuning on a model that has already been efficiently fine-tuned, the lora_rank, lora_alpha, and lora_dropout parameters must remain consistent.

lora_rank

(LoRA rank)

64

Integer

The rank of the low-rank matrices in LoRA. A higher rank can improve fine-tuning results but may slightly increase training time.

lora_alpha

(LoRA alpha)

Use the recommended default value provided by Model Studio.

Integer

The scaling factor that controls the combination of original model weights and the LoRA low-rank correction term.

A larger alpha gives more weight to the LoRA correction, making the model rely more on task-specific information.

A smaller alpha makes the model retain more knowledge from the base model.

lora_dropout

(LoRA dropout)

Use the recommended default value provided by Model Studio.

Float

The dropout rate for the values in the low-rank matrices during LoRA training.

Using the recommended value enhances the model's generalization capabilities.

An overly large value can diminish the fine-tuning effect.

Parameters for mixed training (supports efficient_sft and sft)

data_augmentation

(Enable mixed training)

Mix based on the model's use case.

Boolean

If enabled, Model Studio mixes your training data with its general-purpose datasets. This improves training performance and helps prevent catastrophic forgetting. The mixed-in data is included in the total training token count and billed at the standard rate.

augmentation_types

(Preset data types)

Mix based on the model's use case.

Example: "augmentation_types": "dialogue_CN,general_purpose_CN,NLP"

Must be used in conjunction with augmentation_ratio.

String

Dataset code

Dataset name

Supported models

dialogue_cn

Chinese-Dialogue

Qwen2 series

math_cn

Chinese-Math

general_coding_cn

Chinese-Code

general_purpose_cn

Chinese-General

nlp

NLP-Understanding

dialogue_en

English-Dialogue

math_en

English-Math

general_coding_en

English-Code

general_purpose_en

English-General

mix_v2

General-V2

Qwen 3 series

vl_mix

General

Qwen 3 VL series

augmentation_ratio

(Mixing ratio)

Mix based on the model's use case.

String

  • The format must be a one-to-one match with augmentation_types.

  • Example: "0.1,0.05,0.15" (The values correspond to the three datasets listed in augmentation_types, respectively.)

  • Description: Randomly samples and mixes 10%/5%/15% of the training data.

  • Range: 0.0 ~ 2.0

Parameters for publishing model parameter snapshots (for efficient_sft and sft only)

save_strategy

(Snapshot save strategy)

It can be set to epoch or steps.

  • When set to steps, you can adjust the save interval by setting the save_steps parameter.

String

The strategy for saving model parameter snapshots (checkpoints). Valid options are epoch (save after each epoch) and steps (save at a specified step interval).

save_steps

(Save steps)

If you need to modify it manually, set it to an integer multiple of the eval_steps parameter.

Integer

The interval, in training steps, between each model parameter snapshot save.

save_total_limit

(Snapshot save limit)

10

Integer

The maximum number of model parameter snapshots to retain. Once the limit is reached, older snapshots are automatically deleted.

Retrieve a fine-tuning job

To retrieve the details of a fine-tuning job, use the job_id returned when you create the job.

HTTP

curl 'https://dashscope.aliyuncs.com/api/v1/fine-tunes/<job_id>' \
--header 'Authorization: Bearer '${DASHSCOPE_API_KEY} \
--header 'Content-Type: application/json'

Request parameters

Parameter

Type

Location

Required

Description

job_id

String

Path

Yes

The ID of the fine-tuning job.

Successful response

{
    "request_id": "d100cddb-ac85-4c82-bd5c-9b5421c5e94d",
    "output":
    {
        "job_id": "ft-202511272033-8ae7",
        "job_name": "ft-202511272033-8ae7",
        "status": "RUNNING",
        "finetuned_output": "qwen3-8b-ft-202511272033-8ae7",
        "model": "qwen3-8b",
        "base_model": "qwen3-8b",
        "training_file_ids":
        [
            "9e9ffdfa-c3bf-436e-9613-6f053c66aa6e"
        ],
        "validation_file_ids":
        [],
        "hyper_parameters":
        {
            "n_epochs": 3,
            "batch_size": 16,
            "max_length": 8192,
            "learning_rate": "1.6e-5",
            "lr_scheduler_type": "linear",
            "split": 0.9,
            "warmup_ratio": 0.05,
            "eval_steps": 50,
            "data_augmentation": true,
            "augmentation_ratio": "0.1,0.05,0.15",
            "augmentation_types": "dialogue_CN,general_purpose_CN,NLP",
            "save_strategy": "epoch",
            "save_total_limit": 10
        },
        "training_type": "sft",
        "create_time": "2025-11-27 20:33:15",
        "workspace_id": "llm-8v53etv3hwb8orx1",
        "user_identity": "1654290265984853",
        "modifier": "1654290265984853",
        "creator": "1654290265984853",
        "group": "llm",
        "max_output_cnt": 10
    }
}

Job status

Description

PENDING

The job is waiting to start.

QUEUING

The job is queued. Only one fine-tuning job runs at a time.

RUNNING

The job is running.

CANCELING

The job is being canceled.

SUCCEEDED

The job succeeded.

FAILED

The job failed.

CANCELED

The job was canceled.

Note

After a fine-tuning job succeeds, the finetuned_output field provides the resulting model ID. Use this ID for model deployment.

Get fine-tuning job logs

HTTP

curl 'https://dashscope.aliyuncs.com/api/v1/fine-tunes/<job_id>/logs?offset=0&line=1000' \
--header 'Authorization: Bearer '${DASHSCOPE_API_KEY} \
--header 'Content-Type: application/json' 
Use the offset and line parameters to retrieve a range of log lines. The offset parameter specifies the starting line, and the line parameter specifies the maximum number of lines to return.

Sample response:

{
    "request_id":"1100d073-4673-47df-aed8-c35b3108e968",
    "output":{
        "total":57,
        "logs":[
            "{Fine-tuning log 1}",
            "{Fine-tuning log 2}",
            ...
            ...
            ...
        ]
    }
}

Query and publish model checkpoints

Only SFT fine-tuning (efficient_sft and sft) supports saving and publishing checkpoints from intermediate training states.

List checkpoints for a fine-tuning job

curl 'https://dashscope.aliyuncs.com/api/v1/fine-tunes/<job_id>/checkpoints' \
--header 'Authorization: Bearer '${DASHSCOPE_API_KEY} \
--header 'Content-Type: application/json'

Request parameters

Parameter

Type

Parameter location

Required

Description

job_id

String

Path Parameter

Yes

The ID of the fine-tuning job.

Sample response

Note

The checkpoint field contains the checkpoint ID, which specifies the checkpoint to publish in the Model publishing (optional) API. The model_name field contains the model ID used for model deployment. The finetuned_output field in the original fine-tuning job response is the model_name of the final checkpoint.

{
    "request_id": "c11939b5-efa6-4639-97ae-ed4597984647",
    "output":
    [
        {
            "create_time": "2025-11-11T16:25:42",
            "full_name": "ft-202511272033-8ae7-checkpoint-20",
            "job_id": "ft-202511272033-8ae7",
            "checkpoint": "checkpoint-20",
            "model_name": "qwen3-8b-instruct-ft-202511272033-8ae7",
            "status": "SUCCEEDED"
        }
    ]
}

Status

Description

PENDING

The checkpoint is pending publication. You must publish it using the Model publishing API before you can use it for model deployment and invocation.

PROCESSING

The checkpoint is being published.

SUCCEEDED

The checkpoint has been published successfully. You can now use it for model deployment and invocation.

FAILED

The checkpoint failed to publish.

Model publishing (optional)

Note

In Model Studio, after a fine-tuning job completes, you must export a checkpoint before you can deploy the model.

Exported checkpoints are stored in cloud storage. You cannot access or download them at this time.

curl --request GET 'https://dashscope.aliyuncs.com/api/v1/fine-tunes/<job_id>/export/<checkpoint_id>?model_name=<model_name>' \
--header 'Authorization: Bearer '${DASHSCOPE_API_KEY} \
--header 'Content-Type: application/json'

Request parameters

Parameter

Type

Parameter location

Required

Description

job_id

String

Path Parameter

Yes

The ID of the fine-tuning job.

checkpoint_id

String

Path Parameter

Yes

The ID of the checkpoint to publish.

model_name

String

Path Parameter

Yes

The custom model ID to assign to the published model.

Sample response

{
    "request_id": "ed3faa41-6be3-4271-9b83-941b23680537",
    "output": true
}

The publishing task is asynchronous. Use the List checkpoints for a fine-tuning job API to monitor the publishing status of the checkpoint.

More fine-tuning operations

List fine-tuning jobs

curl 'https://dashscope.aliyuncs.com/api/v1/fine-tunes' \
--header 'Authorization: Bearer '${DASHSCOPE_API_KEY} \
--header 'Content-Type: application/json' 

Cancel a fine-tuning job

Cancels a running fine-tuning job.
curl --request POST 'https://dashscope.aliyuncs.com/api/v1/fine-tunes/<job_id>/cancel' \
--header 'Authorization: Bearer '${DASHSCOPE_API_KEY} \
--header 'Content-Type: application/json' 

Delete a fine-tuning job

You cannot delete a running fine-tuning job.
curl --request DELETE 'https://dashscope.aliyuncs.com/api/v1/fine-tunes/<job_id>' \
--header 'Authorization: Bearer '${DASHSCOPE_API_KEY} \
--header 'Content-Type: application/json' 

API reference

This topic provides a reference for DashScope command-line calls. For details on API calls, see API details.

Model deployment and invocation

Model deployment

For other deployment methods, see Deploy a model by using the API.

By token

curl "https://dashscope.aliyuncs.com/api/v1/deployments" \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
    "model_name": "qwen3-8b-ft-202511132025-0260",
    "plan": "lora",
    "capacity": 1,
    "name": "qwen3-8b-ft"
}'

By model unit

curl "https://dashscope.aliyuncs.com/api/v1/deployments" \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
    "name": "my_qwen_plus",
    "model_name": "qwen-plus-2025-12-01",
    "plan": "mu",
    "deploy_spec": "MU1",
    "enable_thinking": true,
    "capacity": 4,
    "max_context_length": 10000,
    "rpm_limit": 500,
    "tpm_limit": 1000
}'

Query deployment status

Once the deployment status is RUNNING, you can invoke the model.

curl 'https://dashscope.aliyuncs.com/api/v1/deployments/<your_model_instance_id>' \
--header 'Authorization: Bearer '${DASHSCOPE_API_KEY}  \
--header 'Content-Type: application/json' 

For other deployment operations, such as scaling and deprovisioning, see Model Deployment - API Details.

Model invocation

Once the model deployment status is RUNNING, you can invoke the fine-tuned model just like any other model.

You can also get the Model Code from the model deployment console.

For details on usage and parameters, see the DashScope API Reference.

curl 'https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation' \
--header 'Authorization: Bearer '${DASHSCOPE_API_KEY}  \
--header 'Content-Type: application/json' \
--data '{
    "model": "<your_model_instance_id>",
    "input":{
        "messages":[
            {
                "role": "user",
                "content": "Who are you?"
            }
        ]
    },
    "parameters": {
        "result_format": "message"
    }
}'

Model evaluation

The model evaluation feature is exclusive to the Alibaba Cloud Model Studio console. Go to the Model Evaluation page to evaluate model performance.

For more information, see Model Evaluation.