Bailian OPD Distillation Training (OPD) training overview — basic concepts, training method selection, end-to-end flow, environment preparation, and job submission
Docs | Content |
|---|---|
Pure distillation and Reward function development, data format, function testing | |
Custom Rollout (passing the tools parameter to produce structured tool_call), Agentic Reward development | |
Submission Method, teacher model configuration, hyperparameters, environment variables, tuning tips and pitfalls | |
Tracing integration, custom metrics, metric dictionary, effect evaluation, troubleshooting decision tree |
Basic concepts of OPD distillation training and its differences from fine-tuning and traditional distillation
Basic concepts of OPD distillation training and its differences from fine-tuning and traditional distillation
- Student generation: the student model generates a segment of output
- Teacher provides distribution: the teacher model provides a probability distribution for every token position of the output (that is, how likely the teacher considers each token to appear at that position)
- Compute divergence: the student model compares its own probability distribution with the teacher's distribution and computes the divergence at every token position (KL divergence, a metric that measures the difference between two probability distributions)
- Update toward the teacher: the parameters are updated using this as the loss, so that every token moves closer to the teacher model
dimension | Fine-tuning (SFT) | Traditional model distillation | OPD distillation training |
|---|---|---|---|
Training Data | Manual Annotation | Teacher model pre-generated output | Student model generation |
Guidance method | Fixed labels | Complete teacher model output | Teacher model per-token probability distribution |
Student model participates in generation | No | No | Yes |
Error correction | None | None | Per-token correction |
End-to-End Overview
OPD training involves 5 steps, from environment preparation to model deployment:
- Environment preparation — Install the SDK, obtain an API Key, and complete authorization
- Prepare data and code — JSONL data; pure distillation requires no function code
- Submit the training task — Pass
teacher_modelto trigger distillation; pure distillation is zero-code - Monitor training status — Check the distillation loss, whether the teacher model signal is healthy, and validation set metrics
- Publish and deploy the model — The final Checkpoint is published automatically; after deployment, call the model via API
How It Works
The data flow of each training round is as follows:
Models and Training Units
The teacher model must be a model activated in Model Studio, and its capability must be stronger than that of the student model.
- China (Beijing)
- Singapore
Teacher model | Student model | Beta status | Recommended training units |
|---|---|---|---|
qwen3.5-122b-a10b | qwen3.5-27b | Beta | Type IV (MTU4) × 28 |
qwen3.5-397b-a17b | qwen3.5-27b | Beta | Type IV (MTU4) × 28 |
qwen3.5-122b-a10b | qwen3.5-2b | Beta | Type IV (MTU4) × 11 |
qwen3.5-27b | qwen3.5-2b | Beta | Type IV (MTU4) × 7 |
qwen3.5-35b-a3b | qwen3.5-2b | Beta | Type IV (MTU4) × 7 |
qwen3.5-397b-a17b | qwen3.5-2b | Beta | Type IV (MTU4) × 11 |
qwen3.5-122b-a10b | qwen3.5-35b-a3b | Beta by invitation | Type IV (MTU4) × 20 |
qwen3.5-397b-a17b | qwen3.5-35b-a3b | Beta by invitation | Type IV (MTU4) × 20 |
qwen3.5-122b-a10b | qwen3.5-4b | Beta by invitation | Type IV (MTU4) × 11 |
qwen3.5-27b | qwen3.5-4b | Beta by invitation | Type IV (MTU4) × 7 |
qwen3.5-35b-a3b | qwen3.5-4b | Beta by invitation | Type IV (MTU4) × 7 |
qwen3.5-397b-a17b | qwen3.5-4b | Beta by invitation | Type IV (MTU4) × 11 |
qwen3.5-122b-a10b | qwen3.5-9b | Beta by invitation | Type IV (MTU4) × 24 |
qwen3.5-27b | qwen3.5-9b | Beta by invitation | Type IV (MTU4) × 20 |
qwen3.5-35b-a3b | qwen3.5-9b | Beta by invitation | Type IV (MTU4) × 20 |
qwen3.5-397b-a17b | qwen3.5-9b | Beta by invitation | Type IV (MTU4) × 24 |
qwen3.8-flash | qwen3.5-9b | Beta by invitation | Type IV (MTU4) × 16 |
qwen3.8-max | qwen3.5-9b | Beta by invitation | Type IV (MTU4) × 72 |
QuickStart
Complete the full 5-step workflow with the pure-distillation basic sample—training can start with zero code. Pure distillation requires no functions to write; the teacher model simply guides the student model's training token by token.
The OPD distillation training entry is now available as a training method in the console's Create Training Task page. Task submission, metric monitoring, and output management take place in the model fine-tuning console. The complete configuration and submission workflows in this section and the following ones are based on the DashScope SDK (the demo includes an OPD-capable wheel).
Environment preparation
Environment preparation covers the following items: API Key, service access authorization, SDK installation, workspace directory, and core environment variables.
API Key: Obtain it from the Model Studio console API-KEY page and set it as the environment variable DASHSCOPE_API_KEY.
Service access authorization: On first use, grant one-click authorization in the model fine-tuning console for three cloud services: ARMS (Application Real-Time Monitoring Service, which handles OpenTelemetry metric reporting), Function Compute (FC), and Log Service (SLS). OpenTelemetry is an open-source observability data standard; ARMS hosts and visualizes it. The three services are used respectively for metric reporting, function execution, and log collection.
SDK: Install from the wheel file bundled in the sample directory (the version updates with the sample; currently 1.27.5):
DASHSCOPE_API_KEY(required): authentication.FC_PYPI_LIB(required): the SDK package installed in the function runtime; set it to the wheel's relative path (resolved remotely—an absolute local path will not match). Pure distillation (functions=None) does not involve a function runtime, so you can skip this item.FC_LAYER_USED(optional, defaults to true): when true, a layer is built from requirements.txt at registration, skipping pip installation during cold start; when false, the remote runtime installs it during cold start.
FC_PYPI_LIB to the actual wheel file name (the version number updates with the sample).
Before submission, the sample script verifies that the installed SDK's AgenticRL.run accepts the teacher_model parameter; if it does not, the script exits with an error directly. For other environment variables (control-plane endpoint, inference endpoint, log level, etc.), see Training Configuration.
Prepare data and code
Each line in a JSONL file is one sample containing the messages and rollout_extra fields. messages is the conversation input (ChatML format), and rollout_extra holds reference answers or other business data to be consumed when Reward/custom Rollout is enabled.
rollout_extra is just passed through and not consumed.
Submit a training task
The entry point is AgenticRL().run(...): passing teacher_model triggers distillation. run() completes everything in one step: register functions to FC → upload training data → submit the training task. Pure distillation registers no functions.
Minimal submission code example
Minimal submission code example
dashscope rl run). For an item-by-item explanation of the three submission methods and their fields, see Training Configuration.Getting started tips
- Start with the examples: for plain text output tasks, start from the Model OPD examples; when output relies on API-level tool calls or multi-turn/custom interactions, start from the Agentic OPD examples.
- Start with a small dataset: validate the pipeline with a few dozen samples +
n_epochs=1before switching to the full dataset, to avoid discovering configuration errors only after burning MTU on the full dataset. - Keep hyperparameters at defaults: start
learning_rateat1e-6(distillation fine-tunes existing model capabilities rather than rebuilding them, and an overly large learning rate easily breaks the output format) and usecosineforlr_scheduler_type; when tuning, change only one variable at a time and train at leasteval_steps × 3steps before judging the trend. - On FAILED, check logs first: task failed → check the error at the end in the Logs tab, or call
AgenticRL.logs(job_id="ft-xxx", lines=100)from the SDK.
Post-training workflow
Observing and evaluating results
The job_id returned by run() is the unique identifier for querying training status. Open the task detail page in the model fine-tuning console, which has four tabs: metrics, trajectories, output, and logs.
Key metrics to watch:
trace/distillation/valid_token_rateclose to 1.0 (the teacher model signal is complete).actor/distillation/lossdecreasing or stabilizing (the student model is converging toward the teacher model).- When Reward is enabled, also check that
validation/data/reward/mean@1and each dimension oftrace/reward_metricsrise relative to the baseline.
Release and deployment
After training completes, the last Checkpoint is automatically published to My Models. To publish an intermediate Checkpoint, go to the output page of the model fine-tuning console and do it manually. Published models can be deployed on the My Models page, and once deployed they can be called via API.
Applicable Scenario
Applicable scenarios expand step by step with capability complexity: pure distillation is the basic capability, while Reward and custom Rollout are advanced capabilities layered on top as needed (introducing extra components and more complex training/generation pipelines).
- Pure distillation (basic): teacher model + data only, no function components to write → Model OPD Development
- +Reward (advanced): add a scoring function to layer task rewards on top of the teacher model's token-by-token guidance (scoring against reference answers or multi-dimensional metrics) → Model OPD Development
- +Custom Rollout (advanced, Agentic OPD): customize the generation process when output relies on tool calls/multi-turn interactions; can be combined with Reward or used alone → Agentic OPD Development
Next steps
- Model OPD Development: full details of function development (Rollout/Reward functions, Tracing integration).
- Agentic OPD Development: custom Rollout (passing the tools parameter, structured output) and Agentic Reward development.
- Training Configuration: submission methods, item-by-item field explanations, hyperparameters and environment variables.
- Observability Configuration: metric definitions, trajectory viewing, acceptance criteria, and a troubleshooting decision tree.
FAQ
When to choose OPD over SFT
If you need token-by-token error correction and the student model to learn from its own generations → OPD; if you only have fixed annotations, are budget-sensitive, and do not require online error correction → SFT.
Can training effectiveness be judged without a reward
Yes. Pure distillation relies on valid_token_rate approaching 1.0 and loss decreasing and stabilizing to judge whether the teacher model's signal has been absorbed; final effectiveness is judged by independent post-training evaluation (keep a baseline and compare under the same conditions). If you need to optimize online against the task objective during training, layer Reward on top (the advanced usage of Model OPD), at the cost of providing a computable Reward function.