Model OPD Development: pure distillation requires no function components; stacking Reward (advanced usage) involves scoring function development, with data formats and FAQs
Model OPD development only requires preparing data and submitting configuration to start training (pure distillation, no need to write function components) — student model output generation is completed by Bailian, no need to write. When online optimization by business goals is required, write a Reward scoring function to add to the training process (advanced usage). The differences between the two usages are as follows. For training overview see Online Policy Distillation Training Overview.
Dimension
No Reward (Pure Distillation)
With Reward
Development Work
Only prepare data and submit configuration, no need to write function components
Additionally write a Reward scoring function
Training Signal
Teacher model per-token probability distribution (sole supervision)
Teacher distribution + task reward (by standard answer or multi-dimensional scoring)
Applicable Scenario
The teacher model is already the task upper limit and does not need to be optimized online according to the task target
Need to be optimized online according to business goals, pulling toward the standard answer
In messages, system holds the task description, and user is the User Input. rollout_extra.solution stores the ground truth (standard answer) for Reward to read. Pure distillation does not register a Reward; rollout_extra serves only as a data marker and is not consumed. When Reward is enabled, the Reward reads the scoring basis from solution.
functions=None makes the control plane (scheduling layer) execute the native Rollout (Bailian's built-in sampling generation, where the student model directly generates output without passing the tools parameter; as opposed to Agentic OPD's multi-turn/custom interaction and custom Rollout). Teacher model distillation is the sole supervision signal. Pure distillation must pass None rather than an empty list [] (the control plane does not guarantee identical handling of the two).
After registering the Reward Component, the control plane invokes it to score after each Rollout, Outputting per-dimension metrics to participate in training.
Inherit AbstractRewardProcessor, implement async process(input: RewardInput) -> RewardOutput, key conventions are as follows:
Decorator automatically connects to Tracing: process uses the @observe_processor decorator; the trace client is implicitly injected by the decorator and is not explicitly called within the process method
In the native Rollout output, besides the student's answer, the thinking process and tool call format text are also mixed in. If not cleaned, they will interfere with Reward scoring; you need to first strip these out and leave only the answer before scoring. Cleanup steps:
reward_score as the main reward scalar,reward_metrics as the additional dimension dictionary (each value float).reward_score assigned separately to Reward.reward_score, not duplicated into reward_metrics (metrics.pop("reward_score")). Dimension division and weights are determined by the task, implement according to business needs.Below is the minimal runnable implementation: content containing ground_truth gets 1.0, otherwise 0.0, convenient for first running through the pipeline then expanding dimensions.
After writing MyRewardProcessor after, use RewardFunctionComponent register it to functions list.run() One step to complete registration → Upload Data → submit task.
classpath points to the module path where MyRewardProcessor is located; zipdir="." packages and uploads the entire workspace. For complete field descriptions, see Training Configuration.
Before submitting for training, first locally verify the Reward scoring logic to avoid discovering scoring errors only within the training task (wasting compute power). For your_scoring_function, input sample content and ground_truth, asserting that each dimension's value meets expectations. Place the following test and your_scoring_function and strip_reasoning into the same file (e.g. test_reward.py), and it can run locally.
Check reward_score whether it is taken out via pop and assigned separately to Reward.reward_score, and whether the rest of the dimension values are all float.
Show Score is 0 (coverage not hit)
The native Rollout parser does not execute, content retains thinking and tool call text; you need to first strip_reasoning clean it, then according to the dimensions you defined (such as coverage) to judge, rather than directly judging the original content.
Show teacher_model error
Common causes: teacher_model filled in a model ID not registered in Bailian (such as a HuggingFace repository name). Troubleshooting: switch to a model ID supported by Bailian, for the complete list and more reasons see Training Configuration FAQ.
Show ground_truth not available (empty)
Check each JSONL entry in the data rollout_extra.solution whether it has a value. Reward is first taken from input.ground_truth , falling back to input.agent_output.rollout_extra.solution when missing; if both are empty, the score is 0.
Show Local test reports ModuleNotFoundError
Confirm functions/ directory contains __init__.py(making the directory an importable Python package); classpath aligns with the file path, e.g. functions.reward.my_reward.MyRewardProcessor corresponds to functions/reward/my_reward.py inside MyRewardProcessor Class.