Datasets:
File size: 8,195 Bytes
0b95c2d c409b97 0b95c2d c409b97 0b95c2d c409b97 0b95c2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | ---
pretty_name: CapySFT
task_categories:
- text-generation
size_categories:
- 100K<n<1M
tags:
- sft
- reasoning
- tool-use
- synthetic
source_datasets:
- allenai/tulu-3-sft-mixture
- HuggingFaceTB/smoltalk
configs:
- config_name: 500M
data_files:
- split: train
path: data/train-00000-of-00004.jsonl.gz
- config_name: 1B
default: true
data_files:
- split: train
path:
- data/train-00000-of-00004.jsonl.gz
- data/train-00001-of-00004.jsonl.gz
- config_name: 2B
data_files:
- split: train
path: data/train-*.jsonl.gz
---
# CapySFT
CapySFT is a dataset for supervised fine tuning of assistants that can reason,
answer questions, and use terminal tools. User requests come from Tulu 3 and
SmolTalk. New assistant responses were generated with DeepSeek-V4-Flash-0731.
## Dataset sizes
Choose `500M`, `1B`, or `2B` supervised response tokens. Token counts use
our LLM course's truncated Qwen3.5 tokenizer (32,768 base tokens plus 33
special tokens), included under `tokenizer/`. Counts vary with the tokenizer
and chat formatting.
| Configuration | Source conversations | Training records | Supervised response tokens | Files |
| --- | ---: | ---: | ---: | ---: |
| `500M` | 199,455 | 217,998 | 500,024,135 | first 1 |
| `1B` (default) | 399,746 | 436,342 | 1,000,019,252 | first 2 |
| `2B` | 785,488 | 862,479 | 1,999,896,726 | all 4 |
The configurations share four compressed JSONL files, each with approximately
500 million supervised response tokens. Smaller configurations are subsets
of the larger ones. Related records from the same source conversation stay
in one file. Each configuration contains only a `train` split.
One record is a complete training segment. Long source conversations can
produce several records when their history is summarized and generation
continues. Retained segments are not truncated and fit within 16,384 tokens.
Supervised counts include selected assistant reasoning, answers, tool calls,
summaries, and the end marker of each selected message. Context messages and
tool results do not contribute to these counts.
## Load with Hugging Face
Use the standard `datasets` interface:
~~~python
from datasets import load_dataset
data = load_dataset("vfleaking/capysft", "1B", split="train", token=True)
example = data[0]
print(example["messages"])
print(example["supervised_message_indices"])
~~~
Change `"1B"` to `"500M"` or `"2B"` to choose a size. Add `streaming=True`
to iterate without building a complete local Arrow cache. While the
repository is private, log in with an account that has access.
## Record format
The three fields needed for training are:
| Field | Type | Meaning |
| --- | --- | --- |
| `messages` | list of message dictionaries | All messages in conversation order, including those used only as context. |
| `tools` | JSON string or null | Available tool definitions. Decode with `json.loads` before applying a chat template. |
| `supervised_message_indices` | list of integers | Indices into `messages` identifying assistant messages to supervise. |
Messages have `role` and `content`, and may have `reasoning_content`,
`tool_calls`, or `tool_call_id`. Each tool call has `id`, `type`, and
`function`. Its `function.arguments` field is a JSON string.
Missing optional message fields load as `None`. Remove only those null
fields, preserving empty strings and lists:
~~~python
import copy
import json
messages = [
{key: value for key, value in message.items() if value is not None}
for message in copy.deepcopy(example["messages"])
]
for message in messages:
for call in message.get("tool_calls", []):
call["function"]["arguments"] = json.loads(call["function"]["arguments"])
tools = json.loads(example["tools"]) if example["tools"] is not None else None
~~~
Each row also has `id`, a unique record identifier, and `conversation_id`,
shared by records from the same source conversation. Group by
`conversation_id` when making a validation split to keep related records
together.
The `metadata` dictionary retains source, generation, segmentation, and
token statistics:
| Metadata field | Meaning |
| --- | --- |
| `source` | Prompt mixture: `tulu3` or `smoltalk`. |
| `subset` | Original subset label within the mixture. |
| `original_global_index` | Source conversation's index in the prepared prompt collection. |
| `original_conversation_id` | Original generation identifier, retained for tracing a record to its source. |
| `generation_status` | Recorded generation outcome. Completed segments are retained even when later generation did not complete. |
| `segment_index` | Segment order within the source conversation. |
| `segment_type` | `initial`, `compaction` (summary generation), or `continuation` (generation after a summary). |
| `segment_end_reason` | Recorded reason this segment ended. |
| `generated_responses` | Number of newly generated assistant messages; equals the length of `supervised_message_indices`. |
| `response_tokens` | Number of supervised response tokens. |
| `full_tokens` | Number of input tokens, including context and the final message's end marker. |
Other source metadata, when present, is also retained.
## Tokenization and supervision
The supplied chat template preserves reasoning on every assistant turn.
After preparing `messages` and `tools` as above, render and tokenize with:
~~~python
from huggingface_hub import snapshot_download
from transformers import AutoTokenizer
snapshot = snapshot_download(
"vfleaking/capysft", repo_type="dataset", allow_patterns="tokenizer/*", token=True
)
tokenizer = AutoTokenizer.from_pretrained(f"{snapshot}/tokenizer")
text = tokenizer.apply_chat_template(
messages, tools=tools, tokenize=False, add_generation_prompt=False
)
text = text.removesuffix("\n")
tokens = tokenizer.encode(text, add_special_tokens=False)
~~~
Supervise only assistant messages selected by `supervised_message_indices`.
For each selected message, include its opening `<think>`, reasoning,
closing `</think>`, answer or complete tool call, and closing `<|im_end|>`.
Include newlines within that body. Mask the assistant role header,
the newline after its end marker, all other messages, and padding.
Earlier assistant messages can be context only. For example, a generated
summary is supervised when first produced, then appears as masked history
in a later record. Keep these earlier messages as input.
The final `<|im_end|>` ends the segment. Remove only the following template
newline and do not append another end token. When packing records together,
keep attention and target shifting within each record.
## How the data was generated
We used a small agent harness developed for our LLM course assignments,
which we call MiniCapyCode. It runs the conversation loop between the model
and a sandboxed Linux environment. The model may use bash, read, edit, and
write tools, receive their results, and continue its response. Tool use is
optional.
Generation used thinking enabled, low reasoning effort, `temperature=1`,
and `top_p=1`. Later user questions could be rewritten in conversation context.
When a conversation approached the context limit, the harness could ask
the model to summarize its history and continue from that summary.
Summary requests and responses are included as separate training records.
The generated responses can contain errors. Some source conversations ended
before all turns completed, but their completed training segments are
retained. There is no validation or test split, and the data has not been
checked for overlap with every benchmark.
## Sources and terms
The source prompts come from
[Tulu 3 SFT Mixture](https://huggingface.co/datasets/allenai/tulu-3-sft-mixture)
and [SmolTalk](https://huggingface.co/datasets/HuggingFaceTB/smoltalk).
Each record retains the source and subset labels in `metadata`.
Upstream terms differ by subset, and some Tulu 3 subsets restrict commercial
use. Regenerating responses does not remove conditions on the source
prompts. See [LICENSE.md](LICENSE.md) and the upstream dataset cards for
licenses, attribution, and terms governing generated outputs. No single
permissive license is asserted for the entire mixture.
|