The instruction distillation template starts from a small set of seed instructions and builds a high-quality instruction-following SFT dataset through instruction expansion, refinement, teacher generation, four-dimensional scoring, and filtering.
Template overview
The instruction distillation template is designed for scenarios where you have a small set of high-quality instructions and want to scale up training data in bulk. Starting from a few seed instructions, the template expands them into more instructions of the same style, refines each instruction to better match real user queries, generates responses with the teacher model, and then scores and filters the results across four dimensions — informativeness, helpfulness, generalization, and correctness — to produce an SFT dataset ready for fine-tuning.
This template supports an optional two-stage workflow: Stage 1 is distillation data generation, and Stage 2 is student model training (optional). You can run data generation alone, or run both stages in sequence.
The instruction distillation pipeline consists of the following steps:
-
Instruction expansion: uses the seed instructions as examples to generate new instructions of the same scenario and style, increasing the data volume.
Input example: {"instruction": "Create a two-day travel itinerary for Hangzhou."} Output examples: {"instruction": "Create a three-day travel itinerary for Beijing."} {"instruction": "I want to visit Shanghai. Recommend a travel itinerary."} -
Instruction refinement: rewrites each instruction to remove ambiguity and redundancy, making it closer to how real users phrase their queries.
Input example: {"instruction": "Create a two-day travel itinerary for Hangzhou."} Output example: {"instruction": "Please create a two-day Hangzhou travel plan covering itinerary, food recommendations, accommodation, and best times to visit."} -
Teacher generation: calls the teacher model to generate a response for each instruction, which serves as the target output for the student model to learn.
-
Quality scoring: scores each Q&A pair across four dimensions — informativeness, helpfulness, generalization, and correctness — to provide a basis for filtering.
-
Quality filtering: filters out low-quality samples based on per-dimension score thresholds and retains the highest-scoring portion.
-
Build SFT dataset: removes empty and over-length samples, and outputs a standardized SFT training dataset.
Procedure
-
Log on to PAI console. In the left-side navigation pane, choose Model Application > Model Distillation (ModelDistill).
-
Click Create task to go to the Distillation Template tab, or go to the Distillation Template tab directly.
-
Select Instruction Distillation, click Use Template, and go to the Create Distillation Task page. Configure the key parameters described below and keep the default values for other settings.
-
Complete the Basic Configuration:
-
Task name: pre-filled by the system.
-
Output Path: specify an OSS path that you have access to, such as
oss://mybucket.oss-cn-hangzhou-internal.aliyuncs.com/instruct-distill/.NoteCreate a separate output directory for each distillation task to prevent files from being overwritten. The OSS bucket must be in the same region as the PAI service.
-
-
Click Next to go to the Build distillation data step:
-
Teacher model: Teacher Model Source — select Token Service and choose a model from the drop-down list, such as
qwen3.8-max. -
Dataset: select an OSS directory or file that you have access to. You can download and use the sample dataset directly.
-
Distillation Configuration: default values are provided. Modify them as needed.
-
dataset.input_path: if you selected a specific file for the dataset, the filename configured here is ignored.
-
pipeline: in the instruction expansion stage (
stage: instruction_expansion),num_output_sampledetermines the total number of distillation data items generated. Adjust this value as needed. -
For more instruction distillation template-specific parameters (such as temperature, max_workers, and scoring thresholds for each stage), see Configuration reference below.
-
-
Configure Computing Resource: set Resource Type to General Computing and Source to Public Resources. Then select an appropriate Instance Type in Job Resource, such as
ecs.c6.large.
-
-
Click Next: Student Model Training to continue configuring (you can also select Run Only Distillation Data Build):
-
Student model: select Public Model and choose a smaller model from the drop-down list, such as
Qwen3-4B. -
Training Mode: select LoRA.
-
Compute Resource: set Resource Type to General Computing and Source to Public Resources. Then select an appropriate Instance Type in Job Resource.
-
-
Click Create, and then click OK in the billing prompt. The page redirects to the task details page where you can track the task status.
Configuration reference
This section describes the key configuration parameters specific to the instruction distillation template. Basic configuration and resource configuration are the same as general-purpose distillation. Only template-specific parameter differences are listed here.
Basic configuration
Basic configuration includes the task name and output path. The output path is the root directory for all task artifacts. The distillation dataset is also written under this directory — no separate dataset output path is needed.
Distillation data generation
Teacher model
The instruction distillation template requires only one teacher model, which generates responses for each instruction. The teacher model source supports only PAI Token Service.
Dataset
Select an input directory or file. The data format requirements are as follows:
-
Format: JSONL, one seed instruction per line.
-
Each record must contain the
instructionfield. -
A few dozen seed instructions are sufficient to get started — the template automatically expands the data volume.
Sample data:
{"instruction": "Explain what machine learning is."}
{"instruction": "How to prevent the common cold?"}
Distillation configuration
The distillation configuration is provided in YAML format with recommended defaults from the algorithm team. Adjust parameters as needed. The following table lists key parameters and their descriptions.
|
Section |
Description |
|
dataset |
|
|
backend |
|
|
generation |
|
|
sft |
|
|
eval |
|
|
pipeline |
|