Skip to content

Commit 453b200

Browse files
committed
docs(regen): update response regeneration docs for multi-turn support
Brings docs in line with shipped code from PRs #693 (multi-turn), --reasoning-parser). Adds gsm8k to supported datasets, documents --subset arg, and adds a multi-turn output example. Signed-off-by: Sawyer Bowerman <sbowerma@redhat.com>
1 parent 42a6bee commit 453b200

2 files changed

Lines changed: 37 additions & 6 deletions

File tree

docs/cli/response_regeneration.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# response_regeneration
22

3-
Regenerates assistant responses in existing datasets using a vLLM-served model. Given a dataset containing user prompts (e.g., Magpie, UltraChat), this pipeline extracts the prompts, sends them to a vLLM server, and produces a new dataset with the original prompts paired with freshly generated responses from the target model. This is useful for creating training data where you want a specific model's outputs in place of the original assistant responses.
3+
Regenerates assistant responses in existing datasets using a vLLM-served model. Given a dataset containing conversations (e.g., Magpie, UltraChat, GSM8K), this pipeline extracts conversation turns, regenerates each assistant response turn-by-turn against the model's own prior outputs, and produces pre-tokenized training samples. For multi-turn conversations, each turn conditions on the regenerated history, producing on-policy training data.
44

55
The pipeline consists of two scripts:
66

@@ -33,6 +33,10 @@ Orchestrates the entire pipeline: starts a vLLM server (with optional data/tenso
3333

3434
- **`--tp-size`** (int) Tensor parallel size per replica (maps to vLLM's `--tensor-parallel-size`).
3535

36+
- **`--max-model-len`** (int) Maximum model context length (passed to `vllm serve --max-model-len`).
37+
38+
- **`--reasoning-parser`** (str) Reasoning parser for the vLLM server (passed to `vllm serve --reasoning-parser`).
39+
3640
- **`--keep-server`** (flag) Don't stop the vLLM server after processing completes.
3741

3842
All other arguments are passed through to `script.py`.
@@ -51,13 +55,15 @@ All other arguments are passed through to `script.py`.
5155

5256
## script.py
5357

54-
Extracts user prompts from a dataset, sends them to a vLLM chat completion endpoint, and writes out new prompt-response pairs with the target model's generated responses.
58+
Extracts conversation turns from a dataset, regenerates each assistant response turn-by-turn via a vLLM chat completion endpoint, and writes out pre-tokenized training samples with generation boundaries marked in the loss mask.
5559

5660
### Features
5761

62+
- **Multi-turn support** — detects `messages`/`conversations` fields and regenerates each assistant turn against the model's own prior responses
5863
- **Auto-detects model** from vLLM server (no need to specify `--model`)
59-
- **Resume capability** to skip already-processed rows
64+
- **Resume capability** to skip already-processed conversations
6065
- **Async processing** with configurable concurrency
66+
- **Automatic retries** with exponential backoff on transient failures
6167

6268
### Basic Usage
6369

@@ -93,6 +99,8 @@ python scripts/response_regeneration/script.py --dataset magpie
9399

94100
- **`--sampling-params`** (str, default: `None`) JSON object merged into each chat-completion request, e.g. `'{"temperature": 0.6, "top_p": 0.95, "seed": 0}'`. Unset keys use the server defaults.
95101

102+
- **`--max-retries`** (int, default: `3`) Max retry attempts per request on transient HTTP failures (408, 409, 425, 429, 5xx) with exponential backoff. Permanent errors (e.g., 400, 404) fail immediately.
103+
96104
#### Output Arguments
97105

98106
- **`--outfile`** (str, default: auto-generated) Output JSONL path. If not specified, auto-generated as `{dataset}_{model}.jsonl`.

docs/user_guide/tutorials/response_regeneration.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Response Regeneration
22

3-
This tutorial walks you through regenerating assistant responses in an existing dataset using a target model served by vLLM. The resulting dataset pairs the original user prompts with freshly generated responses, which can be used as training data for speculator models with improved alignment to your target model.
3+
This tutorial walks you through regenerating assistant responses in an existing dataset using a target model served by vLLM. For multi-turn conversations, the script regenerates each assistant turn sequentially against the model's own prior responses, producing on-policy training data with improved alignment to your target model.
44

55
## Overview
66

@@ -26,8 +26,8 @@ The simplest way to regenerate responses is using the `run_all.sh` script, which
2626
This will:
2727

2828
1. Start a vLLM server with the specified model
29-
2. Extract prompts from the dataset and generate new responses
30-
3. Save results to a JSONL file (e.g., `magpie_Llama-3.3-70B-Instruct.jsonl`)
29+
2. Extract conversation turns from the dataset and regenerate assistant responses turn-by-turn
30+
3. Save pre-tokenized results to a JSONL file (e.g., `magpie_Llama-3.3-70B-Instruct.jsonl`)
3131
4. Stop the server
3232

3333
### Multi-GPU Configurations
@@ -71,6 +71,29 @@ The output is a JSONL file with one pre-tokenized row per assistant turn. `loss_
7171
}
7272
```
7373

74+
For multi-turn datasets, later turns include the regenerated history as context. For example, the second turn of the same conversation would be:
75+
76+
```json
77+
{
78+
"id": "conv-abc_turn1",
79+
"primary_id": "conv-abc",
80+
"input_ids": [151644, 872, ...],
81+
"loss_mask": [0, 0, ..., 1, 1],
82+
"conversations": [
83+
{"role": "user", "content": "What is the capital of France?"},
84+
{"role": "assistant", "content": "The capital of France is Paris."},
85+
{"role": "user", "content": "What about Germany?"},
86+
{"role": "assistant", "content": "The capital of Germany is Berlin."}
87+
],
88+
"metadata": {
89+
"idx": 0,
90+
"finish_reason": "stop",
91+
"usage": {...},
92+
"endpoint": "http://127.0.0.1:8000/v1/chat/completions"
93+
}
94+
}
95+
```
96+
7497
A conversation with N assistant turns produces N rows, so expect more lines than input conversations. `conversations` is a review-only twin of `input_ids`; training drops it.
7598

7699
Check that the output looks correct:

0 commit comments

Comments
 (0)