- Reinforcement Learning Development Guide
- Reinforcement Learning Training Configuration
- Reinforcement learning observability and metrics
Learn about the basic concepts and use cases of RL training.
Learn about the basic concepts and use cases of RL training.
continued pre-training (CPT) (optional) → supervised fine-tuning (SFT) → direct preference optimization (DPO) (optional) → RL (optional)-
Continued pre-training (CPT) - Fills knowledge gaps. General models have broad but shallow knowledge and often cannot meet the depth and accuracy requirements of specialized domains.
- Financial model:
Learns financial terminology - Medical model:
Memorizes drugs and pathologies - Legal model:
Understands legal articles and case law
- Financial model:
-
Supervised fine-tuning (SFT) - Learns to perform tasks
- Customer service bot:
Learns customer service procedures - Code assistant:
Learns programming paradigms - tool calling (agent):
Learns to use Model Context Protocol (MCP)
- Customer service bot:
-
Direct preference optimization (DPO) - Improves performance
- Safety and responsibility:
Rejects harmful suggestions - Conciseness and effectiveness:
Provides crisp and clear answers - Objectivity and neutrality:
Gives fair and unbiased evaluations
- Safety and responsibility:
-
Reinforcement learning (RL) - Learns to reason. The model autonomously explores optimal strategies guided by a reward signal, without needing a standard answer.
- Mathematical reasoning:
Solves problems more accurately - tool calling (agent):
Makes more reliable calls - Code generation:
Writes executable code
- Mathematical reasoning:
RL training workflow
The RL training process consists of five steps, from environment setup to model deployment:
- Set up the environment — Install the offline SDK, get an API key, and complete RL service authorization.
- Prepare data and code — Download the demo package to understand the data format and project structure.
- Submit the training job — Run the demo to deploy functions, upload data, and submit the job in one step.
- Monitor training status — View the training status, logs, and reward trends.
- Publish and deploy the model — Publish a checkpoint to "My Models" and deploy it for API access.
How RL training works
RL training continuously improves the model's capabilities through a "generate-score-optimize" loop. The data flow for each training round is as follows:
Supported models
Model name | Model code | MoE | Recommended MTUs |
|---|---|---|---|
Qwen3.5-9B | qwen3.5-9b | No | Type IV training unit * 24 |
Qwen3.6-flash-2026-04-16 | qwen3.6-flash-2026-04-16 | Yes | Type IV training unit * 40 |
Qwen3.5-flash-2026-02-23 | qwen3.5-flash-2026-02-23 | Yes | Type IV training unit * 40 |
Qwen3.6-35B-A3B | qwen3.6-35b-a3b | Yes | Type IV training unit * 40 |
Training unit pricing
For the training unit purchase process, the submission configuration of subscription jobs (how to obtain the instance_id), and the complete usage instructions, see Model training units (invitation-only).
Billing method | Description | Billing formula |
|---|---|---|
Model training unit · subscription | Purchase exclusive model training units on a monthly subscription for faster, queue-free training. The minimum billing unit is one hour. If you cancel your subscription early, you are charged at 1.2 times the hourly rate. To purchase or manage subscription training units, go to the Model Fine-tuning console and click Resource pool management (subscription). |
|
Model training unit · pay-as-you-go | Use exclusive training resources for faster, queue-free training. You are billed for the actual duration of use. This option is enabled automatically when you create a job and does not require a pre-purchase. |
|
Training unit type | Billing method | Unit price | Minimum billing unit |
|---|---|---|---|
Type IV (MTU4) | subscription (monthly) | CNY 19,914.00/month/instance | 1 hour |
pay-as-you-go (per minute) | CNY 41.00/hour/instance | 1 minute |
Environment preparation
Complete the environment configuration by following these steps:
- Obtain an API Key: Obtain a DashScope API Key in the Bailian console.
- Complete RL service authorization: Complete the one-click authorization on the model fine-tuning page of the Bailian console. When you use RL training for the first time, the console will prompt you to authorize three Alibaba Cloud services: Application Real-Time Monitoring Service (ARMS), Function Compute (FC), and Log Service (SLS).
-
Set environment variables: The following variables are read by the local SDK and control packaging, upload, and deployment behavior:
- DASHSCOPE_API_KEY (required): The API key.
- LOG_LEVEL (optional, default
info): Set todebugto output complete request/response information, which helps troubleshoot issues such as submission failures. - FC_ZIP_EXCLUDE_PATTERNS (optional): Directories or files excluded during upload (comma-separated), used to reduce the upload package size. By default,
.git,data,__pycache__, etc. are excluded. The maximum upload package size is 200 MB.
Prepare data and code
Demo overview
This demo implements a math calculation agent:
- Rollout function: Calls the model being trained and uses a calculator tool to answer math questions
- Reward function: Compares the model output with the reference answer to determine whether the answer is correct and assign a score
Data format
Training data uses the JSONL format, with one JSON object per line containing the messages and rollout_extra fields:
messages: The user question, in the same format as ChatMLrollout_extra: Stores the reference answer or other business data, and is passed to the reward function for scoring (rollout_extra supports custom fields)
rollout_extra is passed through to RolloutInput.rollout_extra of the rollout function and RewardInput.agent_output.rollout_extra of the reward function, making it easy to use in scoring logic. This field supports custom keys and is not limited to the solution in the example.
Data volume recommendations
- Getting started: A dataset of no fewer than
batch_size(64 for the demo) samples is enough to verify that the approach works; expand it gradually afterwards. - Formal training: Larger data volumes yield better results, and large-scale datasets also support larger batch_size values, which helps improve training stability
Submit a training task
Complete code and parameter descriptions
Complete code and parameter descriptions
dashscope rl run). For a field-by-field explanation of the three submission methods, see Training Configuration — Submission and Configuration.Getting-started tips
After your first successful run, we recommend following these 4 practices:
- Start with a reduced dataset: Run the demo once with its defaults,
calc_train_min.jsonl+n_epochs=1, confirm the pipeline works end to end, then switch to the full dataset — this avoids burning 24 MTUs on a large dataset only to discover a configuration error. - Leave hyperparameters untouched at first: The 11 hyperparameters above are a low-cost trial-run starting point for qwen3.5-9b (consistent with the low-cost trial-run example in the "Sample Code" section of "Training Configuration — Submission and Configuration", which additionally passes in 4 optional parameters explicitly). Do not tune them on your first training run. When you do tune, change only one variable at a time (lr or batch_size), and run at least
eval_steps × 3evaluation periods and no fewer than 150 steps before judging the trend. - Watch one core metric: On the Metric tab, check
critic/rewards/mean— a steady rise means the model is learning; if it plateaus or drops, stop and troubleshoot instead of letting it run idle. - If FAILED, check logs first: When the task fails → check the error at the end in the Logs tab, or pull logs with the SDK via
AgenticRL.logs(job_id="ft-xxx", lines=100). Configuration and dependency errors can usually be spotted at a glance.
Training monitoring and analysis
After you submit the job, the job_id returned by run() is the unique identifier for querying the training status. Training typically takes from tens of minutes to several hours, depending on the dataset size and model.
In the Model Studio console, go to the Model Fine-tuning page and click a job to open its details page, which contains the following five tabs:
Tab | Purpose | Main content |
|---|---|---|
Details | Job metadata | Job ID, status, base model, training method, start/end times, data configuration |
Trajectory | Agent behavior replay | Complete dialogue process, reward analysis (across step, sample, and trajectory dimensions), and tool calling details |
Metrics | Training health | 7 groups of metric charts (actor / critic / trajectory / trace / timing / perf / fully_async), including user-defined metrics |
Logs | Runtime troubleshooting | stdout/stderr from the training process, used to locate the cause of errors when a job fails |
Output | Model assets | List of checkpoints and their publishing status. You can publish a checkpoint to "My Models" for deployment and use. |

Model publishing and deployment
After training completes, the last checkpoint is automatically published to My Models (the best checkpoint is not necessarily the last one—see Checkpoint retention and selection for selection criteria). To publish an intermediate checkpoint, go to the Model Studio console's Model Fine-tuning > Output page and do it manually. For more information, see Model fine-tuning in the console.
After a model is published, you can deploy it from the My Models page. Once deployed, you can call the model via an API. For details, see Model deployment.
Next steps
- Learn the full details of function development → Reinforcement Learning Development Guide
- Learn about training configuration and hyperparameters → Reinforcement Learning Training Configuration — Submission and Configuration
- Learn about observability configuration, trajectory viewing, and training metrics → Observability Configuration and Metric Reference for Reinforcement Learning