Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions docs/user_guide/tutorials/response_regeneration.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,19 @@ The output is a JSONL file with one pre-tokenized row per target generation. `lo
"primary_id": "conv-abc",
"input_ids": [151644, 872, ...],
"loss_mask": [0, 0, ..., 1, 1],
"conversations": [
{"role": "user", "content": "What is the capital of France?"},
{"role": "assistant", "content": "The capital of France is Paris."}
],
"text": "<|im_start|>user\nWhat is the capital of France?<|im_end|>\n<|im_start|>assistant\nThe capital of France is Paris.<|im_end|>",
"metadata": {
"idx": 0,
"finish_reason": "stop",
"is_tool_call": false,
"usage": {...},
"endpoint": "http://127.0.0.1:8000/v1/chat/completions"
"endpoint": "http://127.0.0.1:8000/v1/chat/completions",
"sampling_params": {...}
}
}
```

Each assistant turn produces at least one row — and more when the target calls a tool, since every call is its own generation — so expect more lines than input conversations. `conversations` is a review-only twin of `input_ids`; training drops it.
Each assistant turn produces at least one row — and more when the target calls a tool, since every call is its own generation — so expect more lines than input conversations. `text` is the same tokens decoded back to a string (`tokenizer.decode`, special tokens kept), so reading it tells you exactly what `input_ids` holds. Training drops it.

For multi-turn datasets, later turns include the regenerated history as context. For example, the second turn of the same conversation would be:

Expand All @@ -110,18 +108,14 @@ For multi-turn datasets, later turns include the regenerated history as context.
"primary_id": "conv-abc",
"input_ids": [151644, 872, ...],
"loss_mask": [0, 0, ..., 1, 1],
"conversations": [
{"role": "user", "content": "What is the capital of France?"},
{"role": "assistant", "content": "The capital of France is Paris."},
{"role": "user", "content": "What about Germany?"},
{"role": "assistant", "content": "The capital of Germany is Berlin."}
],
"text": "<|im_start|>user\nWhat is the capital of France?<|im_end|>\n<|im_start|>assistant\nThe capital of France is Paris.<|im_end|>\n<|im_start|>user\nWhat about Germany?<|im_end|>\n<|im_start|>assistant\nThe capital of Germany is Berlin.<|im_end|>",
"metadata": {
"idx": 0,
"finish_reason": "stop",
"is_tool_call": false,
"usage": {...},
"endpoint": "http://127.0.0.1:8000/v1/chat/completions"
"endpoint": "http://127.0.0.1:8000/v1/chat/completions",
"sampling_params": {...}
}
}
```
Expand Down
4 changes: 4 additions & 0 deletions scripts/prepare_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
2. Produces a loss/assistant mask for each sample
3. Records token frequency statistics

Rows that already carry input_ids and loss_mask, as on-policy response
regeneration emits, skip steps 1 and 2. They are truncated to --seq-length and
filtered, but never re-tokenized or re-masked.

The output of this script is:
1. Processed dataset ready for online training or offline datagen in output_dir
2. Token frequency statistics file at token_freq_path
Expand Down