Create a model fine-tuning training job for text generation. Datasets can be uploaded via API or mounted from OSS.
Prerequisites
-
Supported regions: The features described in this topic are only available in the China (Beijing) region, and you must use an API Key from this region.
-
Account permissions: If you use an Alibaba Cloud sub-account (RAM user), you need to grant the sub-account permissions for model invocation, training, and deployment.
-
Configure environment variables: You have successfully obtained an API Key and configured it as an environment variable.
-
Preparation: You have read Qwen model tuning to understand the supported models for fine-tuning, fine-tuning steps, data formats, and billing.
Create a fine-tuning job
China (Beijing)
POST https://dashscope.aliyuncs.com/api/v1/fine-tunes
For Windows CMD, replace$DASHSCOPE_API_KEYwith%DASHSCOPE_API_KEY%. For PowerShell, replace with$env:DASHSCOPE_API_KEY
Request parameters |
Using file_id dataset
Using OSS mounted dataset
|
Headers |
|
|
Content-Type Fixed value: |
|
|
Authorization API Key authentication, in the format |
|
Request Body |
|
|
model The base model ID for fine-tuning, or the model ID produced by another fine-tuning job (for re-tuning an already fine-tuned model). |
|
|
training_type Fine-tuning method. Available values:
|
|
|
hyper_parameters Hyperparameter settings. Different models support different parameter sets with different default values. Please check the console with the same model and tuning method to view actual default values. Among them, |
|
|
training_datasets Training dataset file list. |
|
|
validation_datasets Validation dataset file list. Same structure as |
|
|
job_name Tuning job name. |
|
|
model_name Model name after tuning is complete. |
|
Response parameters |
Success response example
Error response example
|
|
request_id The ID of this request. |
|
|
output Job details. |
|
|
code Error code. Returned when the call fails. See the error code table below. |
|
|
message Error message details. Returned when the call fails. |
Error codes
If the call fails and returns an error message, refer to the following table for troubleshooting.
|
HTTP status code |
Error code |
Solution |
|
400 |
InvalidParameter |
Parameter error: missing parameters or format issues. Correct your parameters based on the error message. |
|
400 |
UnsupportedOperation |
Cannot operate on the resource when it is in a specific state. Wait until the resource reaches an operable state before retrying. |
|
404 |
NotFound |
The resource to query/operate does not exist. Check if the resource ID is incorrect. |
|
409 |
Conflict |
A deployment instance with the same name already exists. Specify a suffix to differentiate. |
|
429 |
Throttling |
Resource creation triggered a platform limit. Delete models that are no longer in use.If you need to increase fine-tuning job concurrency or retain more successfully tuned models, please contact your account manager. |
|
500 |
InternalError |
Internal error. Record the request_id and contact Alibaba Cloud engineers through a ticket for investigation. |
Next step
Fine-tuning is an asynchronous operation. After calling this API, you can query the tuning job status through the Query and manage tuning jobs API.