Bailian Online Policy Distillation (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 tools parameter to produce structured tool_call), Agentic Reward Development | |
Submission Method, teacher model configuration, hyperparameters, Environment Variable, tuning and pitfalls | |
Tracing integration, Custom metrics, metric dictionary, effect evaluation, troubleshooting decision tree |
Basic concepts of Online Policy Distillation and differences from fine-tuning and traditional distillation
Basic concepts of Online Policy Distillation and differences from fine-tuning and traditional distillation
- Student generation: student model generates a segment of Output
- Teacher gives distribution: teacher model provides a probability distribution for each token position in the Output (i.e., the teacher's belief of the probability of each token appearing at that position)
- Compute difference: student model compares its own probability distribution with the teacher's distribution, computing the difference at each token position (KL divergence, a metric measuring the difference between two probability distributions)
- Update toward: use this as loss to update parameters, making each token move toward the teacher model
Dimension | Fine-tuning (SFT) | Traditional model distillation | Online Policy Distillation (OPD) |
|---|---|---|---|
Training Data | Manual Annotation | Teacher model pre-generates Output | Student model generates |
Guidance method | Fixed labels | Teacher model complete Output | Teacher model token-by-token probability distribution |
Student model participates in generation | No | No | Yes |
Error correction | None | None | Token-by-token correction |
Full Process Overview
OPD Training from environment preparation to model deployment, Total 5 steps:
- Environment preparation — Install SDK, Obtain API Key, complete authorization
- Prepare data and code — JSONL data, pure distillation does not need to write functions
- Submit Training Task — Pass
teacher_modelto trigger distillation, pure distillation with zero code - Training Status Observation — Check distillation loss, teacher model signal health, validation set metrics
- Publish and Deploy Model — Final Checkpoint auto-published, called via API after deployment
Working Mechanism
The data flow for each training round is as follows:
Model and Training Unit
The teacher model must be a model already enabled in Model Studio, in the same series as and stronger than the student model.
- China (Beijing)
- Singapore
Teacher Model | Student Model | Invite | Recommended Training Unit |
|---|---|---|---|
qwen3.5-122b-a10b | qwen3.5-27b | Preview | IV Type (MTU4) × 24 |
qwen3.5-397b-a17b | qwen3.5-27b | Preview | IV Type (MTU4) × 24 |
qwen3.5-122b-a10b | qwen3.5-2b | Preview | IV Type (MTU4) × 24 |
qwen3.5-27b | qwen3.5-2b | Preview | IV Type (MTU4) × 24 |
qwen3.5-35b-a3b | qwen3.5-2b | Preview | IV Type (MTU4) × 24 |
qwen3.5-397b-a17b | qwen3.5-2b | Preview | IV Type (MTU4) × 24 |
qwen3.5-122b-a10b | qwen3.5-35b-a3b | Preview | IV Type (MTU4) × 24 |
qwen3.5-397b-a17b | qwen3.5-35b-a3b | Preview | IV Type (MTU4) × 24 |
qwen3.5-122b-a10b | qwen3.5-4b | Preview | IV Type (MTU4) × 24 |
qwen3.5-27b | qwen3.5-4b | Preview | IV Type (MTU4) × 24 |
qwen3.5-35b-a3b | qwen3.5-4b | Preview | IV Type (MTU4) × 24 |
qwen3.5-397b-a17b | qwen3.5-4b | Preview | IV Type (MTU4) × 24 |
qwen3.5-122b-a10b | qwen3.5-9b | Preview | IV Type (MTU4) × 24 |
qwen3.5-27b | qwen3.5-9b | Preview | IV Type (MTU4) × 24 |
qwen3.5-35b-a3b | qwen3.5-9b | Preview | IV Type (MTU4) × 24 |
qwen3.5-397b-a17b | qwen3.5-9b | Preview | IV Type (MTU4) × 24 |
Quick Start
Complete the 5-step full flow with a pure distillation basic example; zero code is enough to start training. Pure distillation requires no function writing and is solely guided token by token by the teacher model in training the student model.
Environment Preparation
Environment preparation requires completing the following: Obtain Sample Code Package, API Key, service authorization, SDK installation, and core Environment Variable.
Workspace Directory Obtain from theSample Code Package, containing wheel (Python packaged install File), function code, Data, dependencies, and submission script, structured as follows; the complete implementation of obtaining and submission script is inTraining Configuration:
DASHSCOPE_API_KEY。
Service Authorization On first use, in theModel Fine-tuning ConsoleOne-Click Authorization for three cloud services: ARMS (Application Real-time Monitoring Service, hosting OpenTelemetry metric reporting), FC, and SLS (Log Service). OpenTelemetry is an open-source observability data standard, with ARMS providing hosting and visualization, used respectively for metric reporting, function running, and log collection.
SDK Install using the wheel file bundled in the example directory (version updates with the example, current 1.27.5):
DASHSCOPE_API_KEY(required): Authentication.FC_PYPI_LIB(required): specifies the SDK package installed in the function runtime, fill in the wheel relative path (resolved remotely, local absolute path cannot hit); pure distillation (functions=None) does not involve function runtime, this item can be skipped.FC_LAYER_USED(Optional, Default true): when true, builds layer based on requirements.txt during registration phase, skipping cold-start pip install; when false, installed by remote runtime cold-start.
FC_PYPI_LIB Fill in the actual wheel File name (version number updates with the example).
Before submission, the example script validates whether the installed SDK's AgenticRL.run accepts the teacher_model Parameter, and directly errors out if not accepted. Other Environment Variable (control plane endpoint, inference endpoint, log level, etc.) seeTraining Configuration。
Prepare Data and Code
JSONL one sample per line, containing messages and rollout_extra two fields.messages is the dialogue input (ChatML Format),rollout_extra stores the Reference Answer Or other business Data, consumed when Reward/Custom Rollout is enabled.
rollout_extra is only data pass-through and not consumed.
Submit Training Task
Entry AgenticRL().run(...),pass teacher_model then triggers distillation.run() Done in one step: register function to FC → Upload Training Data → Submit training task. Pure distillation does not register a function.
Minimal submission code example
Minimal submission code example
dashscope rl run) Submit; three methods with field-by-field explanation seeTraining Configuration。Getting Started Tips
- First choose an example: for plain text output tasks start from the Model OPD example; when output depends on API-level tool call Or multi-turn/custom interaction, start from the Agentic OPD example.
- Use streamlined data first: dozens of items +
n_epochs=1to verify the pipeline before switching to the full dataset, avoiding consuming MTU on the full dataset only to discover config errors later. - Keep hyperparameters Default:
learning_rateas starting point1e-6(distillation fine-tunes the model's existing capabilities rather than rebuilding, too large a learning rate easily breaks output Format),lr_scheduler_typeusecosine; when tuning, only change one variable at a time, at least traineval_steps × 3steps before judging the trend. - FAILED check logs first: Task Failed → log tab to view the error at the end, Or SDK Calling
AgenticRL.logs(job_id="ft-xxx", lines=100)。
Post-training Process
Observation and Evaluation
run() returned job_id is the unique identifier for querying training status.Model Fine-tuning ConsoleEnter the task detail page, containing four tabs: metrics, Trajectory, Output, and logs.
Observation focus:
trace/distillation/valid_token_rateclose to 1.0 (teacher model signal complete).actor/distillation/lossdecreases Or stabilizes (student model converges toward teacher model).- When Enable Reward, additionally watch
validation/data/reward/mean@1andtrace/reward_metricsrise relative to baseline across all dimensions.
Publish and Deploy
After training completes, the last Checkpoint is automatically published toMy Models. To publish an intermediate Checkpoint, Go to Model Fine-tuning ConsoleOutput page for manual operation. Published models can be deployed on the My Models page, and after deployment completes, can be called via API.
Applicable Scenario
Applicable Scenario expands progressively by capability complexity: pure distillation is the Basic capability, Reward and Custom Rollout are advanced capabilities layered on top on demand (introducing extra components and more complex training/generation pipelines).
- Pure distillation (Basic): only teacher model + data, no function components written → Model OPD Development
- +Reward (advanced): add a scoring function, layering task reward on top of teacher model's per-token guidance (score by standard answer, score by multi-dimensional metrics) → Model OPD Development
- +Custom Rollout (advanced, Agentic OPD): when output depends on tool Calling/multi-turn interaction, customize the generation process; can be layered with Reward, or used alone → Agentic OPD Development
Next Steps
- Model OPD Development: complete details of function development (Rollout/Reward functions, Tracing integration).
- Agentic OPD Development: Custom Rollout (passing in the tools parameter, structured output), Agentic Reward development.
- Training Configuration: Submission Method, field-by-field descriptions, hyperparameters and Environment Variable.
- Observability Configuration: metric meanings, Trajectory viewing, acceptance criteria and troubleshooting decision tree.
FAQ
When to choose OPD over SFT
Need per-token error correction, student model learns from its own generations → OPD; only have fixed annotations, budget-sensitive and no online correction required → SFT.
Can training effectiveness be judged without reward
Yes. Pure distillation relies on valid_token_rate approaching 1.0 and loss declining and stabilizing to determine whether the teacher model's signal has been absorbed; the final effect is judged by a post-training independent evaluation (retain the baseline, compare under the same criteria). If you need to optimize online during training according to task objectives, then add Reward (an advanced usage of Model OPD), at the cost of needing to provide a computable Reward function.