Create a model fine-tuning job.
Create a tuning task
For Windows CMD, replace${DASHSCOPE_API_KEY}with%DASHSCOPE_API_KEY%. For PowerShell, use$env:DASHSCOPE_API_KEY.
curl --location --request POST "https://dashscope-intl.aliyuncs.com/api/v1/fine-tunes" \
--header "Authorization: Bearer ${DASHSCOPE_API_KEY}" \
--header 'Content-Type: application/json' \
--data '{
"model":"qwen3-14b",
"training_file_ids":[
"86a9fe7f-dd77-43b0-9834-2170e12339ec",
"03ead352-6190-4328-8016-61821c23d4fc"
],
"hyper_parameters":{
"n_epochs":3,
"batch_size":32,
"max_length":8192,
"learning_rate":"1.6e-5",
"lr_scheduler_type":"linear",
"split":0.9
},
"training_type":"sft",
"finetuned_output_suffix":"suffix"
}'
Input parameters
|
Parameter |
Required |
Type |
Passing method |
Description |
|
training_file_ids |
Yes |
Array |
Body |
A list of file IDs for the training set. The File Management API generates these IDs. |
|
validation_file_ids |
No |
Array |
Body |
A list of file IDs for the validation set. The File Management API generates these IDs. |
|
model |
Yes |
String |
Body |
The ID of the to fine-tune, or the ID of a model from a previous fine-tuning job for further fine-tuning. |
|
hyper_parameters |
No |
Map |
Body |
The hyperparameter settings for fine-tuning. The supported hyperparameters and their default values vary by model. To view the actual default values, select the corresponding model and fine-tuning method in the console.
|
|
training_type |
No |
String |
Body |
The fine-tuning method. Valid values are |
|
job_name |
No |
String |
Body |
The name of the fine-tuning job. |
|
model_name |
No |
String |
Body |
The name for the fine-tuned model. |
hyper_parameters supported settings
Sample response
{
"request_id": "9654e55a-d74b-4113-aee1-fa19c9384fcc",
"output": {
"job_id": "ft-202410291653-1c7f",
"job_name": "ft-202410291653-1c7f",
"status": "PENDING",
"model": "qwen3-14b",
"base_model": "qwen3-14b",
"training_file_ids": [
"976bd01a-f30b-4414-86fd-50c54486e3ef"
],
"validation_file_ids": [
],
"hyper_parameters": {
"n_epochs": 3,
"batch_size": 32,
"max_length": 8192,
"learning_rate": "1.6e-5",
"lr_scheduler_type": "linear",
"split": 0.9
},
"training_type": "sft",
"create_time": "2024-10-29 16:53:53",
"workspace_id":"llm-v71tlv***",
"user_identity": "1396993924585947",
"modifier": "1396993924585947",
...Response parameters
|
Parameter |
Type |
Description |
|
request_id |
String |
The ID of the request. |
|
output |
Object |
Details of the fine-tuning job. |
|
output.job_id |
String |
The ID of the fine-tuning job. Use this ID to call APIs such as Query Training Job Details, Query Training Log, Cancel Training Job, and Delete Training Job. Format: |
|
output.job_name |
String |
Same as |
|
output.status |
String |
The task status of the fine-tuning job. |
|
output.model |
String |
The ID of the model for the fine-tuning job. |
|
output.base_model |
String |
The ID of the base model used for the fine-tuning job. For example, the base model for the fine-tuning job |
|
output.training_file_ids |
Array |
A list of training file IDs. |
|
output.validation_file_ids |
Array |
A list of validation file IDs. |
|
output.hyper_parameters |
Object |
An object containing the explicitly specified hyperparameters. |
|
output.training_type |
String |
The fine-tuning method. |
|
output.create_time |
String |
The time the fine-tuning job was created. |
|
output.workspace_id |
String |
The ID of the workspace containing the fine-tuning job. |
|
output.user_identity |
String |
The UID of the primary account that owns the fine-tuning job. |
|
output.modifier |
String |
The UID of the account that last modified the fine-tuning job. Example: If a sub-account cancels the job, this field contains the sub-account's UID. |
|
output.creator |
String |
The UID of the user who created the fine-tuning job. |
|
output.group |
String |
The type of the model fine-tuning job. |
|
Task status |
Description |
|
PENDING |
The fine-tuning job is pending. |
|
QUEUING |
The fine-tuning job is queued (only one fine-tuning job can run at a time). |
|
RUNNING |
The fine-tuning job is running. |
|
CANCELING |
The fine-tuning job is being canceled. |
|
SUCCEEDED |
The fine-tuning job succeeded. |
|
FAILED |
The fine-tuning job failed. |
|
CANCELED |
The fine-tuning job was canceled. |
Request error codes
This response is returned when a request fails.
|
Field |
Type |
Description |
Example value |
|
code |
String |
The error code. |
NotFound |
|
request_id |
String |
The unique ID for the request. |
6332fb02-3111-43f0-bf79-f9e8c5ffa7f9 |
|
message |
String |
The error message. |
Not Found! |
Example error response
{
"code": "NotFound",
"request_id": "BE213CDD-8A5C-59EE-9A67-055EAB0CB59B",
"message": "Not Found!"
}
Common error codes
|
HTTP status code |
Error code |
Example message |
Description |
Suggested action |
|
400 |
InvalidParameter |
Missing training files |
The request included a missing, malformed, or incorrectly formatted parameter. |
Correct the parameter as indicated in the error message. |
|
400 |
UnsupportedOperation |
The fine-tune job cannot be deleted because its status is Succeeded, Failed, or Canceled. |
The resource is in a state that prevents this operation. |
Retry the operation after the resource enters a valid state. |
|
404 |
NotFound |
Not found! |
The specified resource does not exist. |
Verify that the resource ID is correct. |
|
409 |
Conflict |
model instance xxxxx already exists, please specify a suffix |
A deployment instance with this name already exists. |
Provide a unique suffix. |
|
429 |
Throttling |
|
The request has triggered a platform limit. |
|
|
500 |
InternalError |
Internal server error! |
An internal error occurred. |
Record the request ID and submit a ticket to an Alibaba Cloud engineer. |