Data Formats
Soup supports 20 data formats (raft added for Retrieval-Augmented Fine-Tuning in v0.62, asr added for Whisper fine-tuning in v0.71.32, cross_encoder added for paired-text classification in v0.76.0). Files can be JSONL, JSON, CSV, Parquet, or TXT — local paths or remote URIs (s3 / gs / gcs / az / abfs / abfss / oci). Format is auto-detected from up to the first 100 rows for the twelve formats with a distinctive set of keys; the seven at the end of this page cannot be detected from their keys and must be named in data.format.
Note on the count: 20 is the number of values data.format accepts, and one of them is auto, which asks Soup to detect the shape rather than naming one. Nineteen name a row shape, and those nineteen plus auto are the values soup data validate --format accepts.
A byte-order mark is fine (v0.77.0). Local JSONL, JSON, CSV and TXT files load as UTF-8 with or without a leading byte-order mark, so a CSV saved by Excel as "CSV UTF-8" works; through v0.76.1 only JSONL accepted one (#1954). Only the initial signature is removed: a U+FEFF inside a value stays. The same holds since v0.77.0 for many other files Soup reads from you, among them tokenizer corpora, soup bench prompts, soup draft inputs, soup shrink calibration prompts, soup diagnose evidence and generation context documents (#2155); what Soup writes is still plain UTF-8.
Alpaca
{"instruction": "Explain gravity", "input": "", "output": "Gravity is..."}ShareGPT
{"conversations": [{"from": "human", "value": "Hi"}, {"from": "gpt", "value": "Hello!"}]}ChatML
{"messages": [{"role": "user", "content": "Hi"}, {"role": "assistant", "content": "Hello!"}]}DPO / ORPO / SimPO / IPO (preference pairs)
{"prompt": "Explain gravity", "chosen": "Gravity is a force...", "rejected": "I don't know"}The three fields can also be message lists. This row is conversational, with the prompt turn in prompt only:
{"prompt": [{"role": "user", "content": "What is 2+2?"}], "chosen": [{"role": "assistant", "content": "4"}], "rejected": [{"role": "assistant", "content": "5"}]}The bundled examples/data/dpo_sample.jsonl and examples/data/chat_preferences.jsonl are written a third way, a string prompt beside answers that repeat the user turn:
{"prompt": "What is 2+2?", "chosen": [{"role": "user", "content": "What is 2+2?"}, {"role": "assistant", "content": "4"}], "rejected": [{"role": "user", "content": "What is 2+2?"}, {"role": "assistant", "content": "5"}]}One layout per preference row (v0.76.1)
Since v0.76.1 the dpo and kto converters hand the trainer every preference row in one layout: all strings, or all message lists with the prompt turns in prompt only.
- All strings are used as written.
- A string
promptbeside message-list answers is read as a conversation. When the two answers share leading turns, those turns are the prompt and are taken out of the answers, and the stringpromptis not read, asorpoandsimpoalready read such a row. A question written only in that string therefore has to be in the conversations as well. With no shared turn, the string becomes the user turn. - A message-list
promptstays the prompt. A string answer beside it becomes one assistant turn, and a prompt that both answers repeat and continue is taken out of them; when only one answer repeats it, nothing is taken out. - No
promptat all: withdata.format: dponamed, the turns the two answers share are the prompt, or, when they share none, the row'smessageslist (through v0.76.0 such a row was dropped). Since v0.77.0 a training run ondpo,ipo,simpo,orpo,bco,preferenceorreward_modelresolves an omitteddata.formatorformat: autotodpo, live and under--dry-run, so such a file loads without naming the format, and a split with no pair columns is refused before a trainer is built, naming the format it loaded and suggestingdata.format: dpo(#2093).soup data validatehas no task, so on its own it still needs--format dpofor these layouts. KTO's unpaired layout and SFT detection are unchanged.
A row that cannot be written in one layout is dropped at load, with a reason that names the field:
- one answer a string and the other a message list:
dpo.chosen is a string and dpo.rejected is a message list: give both as strings or both as message lists; - a malformed message, such as a message without a
role(dpo.chosen[0].role must be a non-empty string) or acontentthat is a JSON object (write a JSON tool result as a JSON string); - no prompt to be found: no
prompt, no leading turn the two answers share and nomessageslist.
So a dataset can shrink at load, with a warning, never silently. soup train, --dry-run included, prints Warning: N of M rows dropped: they do not convert as 'dpo'. First: row I: <reason>. and, for a local file, the soup data validate command to run (see Rows that do not convert). soup data validate data.jsonl --format dpo counts every row that fails to convert, prints the reasons for the first three and then ... and N more, and exits 0 while at least one row is valid; add --min-valid-fraction 1.0 to make it exit 2 instead.
A dataset that mixes text rows with conversational ones loads as conversations. Each text row is rewritten as one user turn and one assistant turn per answer, and soup train prints a note that counts them: Note: 2 of 7 train rows are plain-text preference rows in a dataset whose other rows are conversations. Each was rewritten as one user turn and one assistant turn per answer, so the whole split goes through the chat template. The train and validation splits are checked separately.
What this fixed. Through v0.76.0 the rows went to trl as written. On v0.76.0, on a string prompt beside chosen / rejected message lists that repeat the user turn, task: dpo, ipo, bco and preference failed inside trl after the model had loaded, with an error that changed with PYTHONHASHSEED ('list' object has no attribute 'endswith', or a TypeError), while soup train --dry-run passed, because a dry run does not reach the trainer. That is the shape of both bundled examples, and on v0.76.1 they train again (#1849, #1866). orpo and simpo prepare the same tokens as before. task: reward_model no longer trains on a text with the question in it twice. A reward model trained on rows of that shape (the bundled examples/configs/rlhf_step2_reward.yaml trains on one such file) finished on such a text. This was verified on v0.76.0, and the code that produced it is unchanged at every earlier tag this site's audit read, back to v0.40.0, so re-train such a reward model if it matters to you: see Re-run this.
Since v0.77.0 upstream's docs/data.md documents the accepted and refused DPO and KTO layouts as tables that its test suite reads back (#2120); this section follows the converter at the tag.
Vision row formats are refused on preference tasks (v0.77.0). data.format: llava or sharegpt4v on dpo, ipo, simpo, orpo, bco or preference stops the load with task='dpo' with data.format='llava' has no vision-preference row path; use a text preference format instead. (with your task and format); through v0.76.1 such a run failed after the model had loaded. The pixtral-dpo recipe that used that shape was removed (#2064).
KTO (unpaired preferences)
{"prompt": "Explain gravity", "completion": "Gravity is a force...", "label": true}KTO rows follow the same one-layout rule over prompt and completion: both strings, used as written, or both message lists. A string prompt beside a message-list completion becomes the user turn, unless the completion starts with turns of its own before its first assistant turn; then those turns are the prompt and the string is not read. Beside a string prompt, a message-list completion with no assistant turn is dropped, with a reason that says so.
label values (v0.77.0). label accepts a boolean; the strings true, 1, yes, false, 0 and no (case and surrounding spaces ignored); and the integers 1, 0 and -1 (1 desirable, 0 and -1 undesirable). Since v0.77.0 any other value, a null, a float (1.0 included), a list or another integer, is not coerced: the row is dropped at load with KTO label must be a bool, true/false string or -1/0/1 integer, got: ... (a string outside the list gives KTO label must be true/false, got string: ...), and training goes on with the valid rows, or exits 1 when none is left (#2126). This is a data-load drop, not a config refusal. soup data validate data.jsonl --format kto names the first three such rows (then ... and N more), counts every one of them, and still exits 0 while some row is valid; add --min-valid-fraction 1.0 to make it exit 2. Through v0.76.1 a null label trained as undesirable and 0.3, [0] and 2 as desirable, so re-train a KTO model whose labels were outside that list (see the v0.77.0 page).
Rows that were detected as another format (v0.78.0, #2423, by @Pandiaraj-1). With task: kto and the default data.format: auto, a file whose rows are detected as another format, Alpaca for instance, is refused before any model loads: Invalid kto dataset: train row 1 loaded as format 'alpaca' lacks prompt, completion or label. Use data.format: kto with kto rows. (exit 1, soup train --dry-run included; checked on the v0.78.0 binary with ten Alpaca rows). Through v0.77.2 --dry-run printed Data OK on the same kind of file and, in upstream's words, a real run loaded the base model and applied LoRA before failing with KeyError: 'prompt'. Naming data.format: kto on rows that do not convert is the drop-and-stop path described above, not this refusal.
LLaVA (vision)
{"image": "photo.jpg", "conversations": [{"from": "human", "value": "<image>\nDescribe this."}, {"from": "gpt", "value": "A cat."}]}ShareGPT4V (vision)
{"image": "chart.png", "conversations": [{"from": "human", "value": "<image>\nExplain this chart."}, {"from": "gpt", "value": "Revenue growth."}]}Plaintext (pre-training)
{"text": "Raw text document for continued pre-training..."}Or use .txt files directly (one document per line).
Embedding
Contrastive rows carry an anchor and a positive only:
{"anchor": "What is Python?", "positive": "Python is a programming language."}
{"anchor": "What is a snake?", "positive": "A legless reptile."}Triplet rows carry a negative as well, on every row:
{"anchor": "What is Python?", "positive": "A programming language.", "negative": "A type of snake."}
{"anchor": "What is a snake?", "positive": "A legless reptile.", "negative": "A programming language."}A file must not mix the two (v0.78.0, #2556, by @ybai08). A train or validation set in which only some rows have a non-blank negative is refused when the trainer is set up, before the model loads, and the message says how many rows have one and how many do not (embedding train set: 2 of 3 rows have a 'negative' and 1 do not; negatives must be on every row (triplet) or on none (contrastive); validation replaces train for the validation split). Give every row a non-blank negative, or remove it from every row. soup train --dry-run does not make this check: a three-row file with one row missing negative passed it on the v0.78.0 binary. Through v0.77.2 the first row decided the loss, so a mixed set trained without any negative or crashed in the collator, and the page's earlier example here was itself such a set.
With embedding_loss: contrastive (the default), each row's negatives are the other rows' positives in the same batch, so a batch needs at least two rows. batch_size: 1 is refused at config load, batch_size: auto resolves to at least 2, and the last partial batch of each epoch is dropped. The same applies when triplet falls back to contrastive because the rows have no negative. Use triplet with a negative on every row, or cosine, to train at batch size 1 (v0.76.0).
Audio
{"audio": "recording.wav", "messages": [{"role": "user", "content": "Transcribe."}, {"role": "assistant", "content": "Hello world."}]}ASR (new in v0.71.32)
{"audio": "clip.wav", "text": "the transcript"}For Whisper fine-tuning (task: asr): the clip becomes 16 kHz log-mel input features, the text becomes the decoder labels. Paths resolve against data.audio_dir (containment-checked).
Tool-calling (new in v0.25.0)
{"messages": [{"role": "user", "content": "Weather in Tokyo?"}], "tools": [{"type": "function", "function": {"name": "get_weather", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}}}}], "tool_calls": [{"function": {"name": "get_weather", "arguments": "{\"city\": \"Tokyo\"}"}}]}Tool definitions are embedded in a leading system message during normalization. The converter reads calls where agent data puts them: an assistant turn keeps its own tool_calls and a tool turn its tool_call_id, in source order (the OpenAI fine-tuning shape, and what soup agent synth writes). A top-level tool_calls list, as in the row above, still works as the single-call form: it becomes one assistant turn appended after messages, and only when no assistant turn already carries calls. tools is optional for conversion, but format: auto recognises a row by messages plus tools. A call's arguments must be a JSON string that parses. See the Tool-calling guide for the full pipeline.
{"messages": [{"role": "user", "content": "Weather in Tokyo?"}, {"role": "assistant", "content": "", "tool_calls": [{"function": {"name": "get_weather", "arguments": "{\"city\": \"Tokyo\"}"}}]}, {"role": "tool", "tool_call_id": "call_1", "content": "18C, clear"}, {"role": "assistant", "content": "It is 18C and clear in Tokyo."}], "tools": [{"type": "function", "function": {"name": "get_weather", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}}}}]}Through v0.75.2 the detector wanted a top-level tool_calls as well, so every row soup agent synth wrote was dropped. A dry run of soup train then still said it was ready to train, on zero rows (#1217; see "Rows that do not convert" below).
The seven the page above does not show a row for
Twenty values are declared for data.format (auto is one of them), and the twelve above are the ones you will meet first. These are the rest, one row each.
// prm — process reward, stepwise supervision
{"prompt": "Solve 2+2", "completions": ["First, add", "Result is 4"], "labels": [true, true]}
// pre_tokenized — skip the tokenize stage entirely
{"input_ids": [1, 2, 3], "labels": [-100, 2, 3], "attention_mask": [1, 1, 1]}
// input_output — template-free, per-segment loss control
{"segments": [{"text": "Q: hi", "label": false}, {"text": "A: hello", "label": true}]}
// video — the path string is kept as written; data.video_dir is not applied
{"video": "clip.mp4", "messages": [{"role": "user", "content": "Describe this clip."}]}
// multimodal — typed content parts, text / image / audio / video in one message
{"messages": [{"role": "user", "content": [{"type": "text", "text": "What's in this?"}, {"type": "image", "url": "x.png"}]}]}
// raft — Retrieval-Augmented Fine-Tuning, v0.62
{"query": "...", "golden_doc": "...", "distractor_docs": ["...", "..."], "answer": "..."}
// cross_encoder — paired text classification, v0.76.0
{"text_a": "how do I reset my password", "text_b": "Open Settings, then Security.", "label": 1}pre_tokenized pairs with data.tokenized_path after soup data preprocess; see Data pipeline pro for the cache key, the labels column and what is refused. For raft, query, golden_doc and answer are required and distractor_docs is optional; a row with other key names is dropped.
cross_encoder rows are two strings and a label. {"question": "...", "answer": "...", "label": 1} is accepted in place of text_a and text_b, and label is kept when present. The format is valid only with task: cross_encoder: data.format: cross_encoder on any other task is refused at config load, and with that task format: auto resolves to it, since {question, answer} is also the shape of plain Q&A data. It is not detected from the keys of an arbitrary file; soup data validate on a text_a/text_b file needs --format cross_encoder.
query_id groups the candidates of one query (v0.78.0, #2618, #2637, by @AlibekBerik). task: reranker and task: cross_encoder rows take an optional "query_id", a non-empty string of at most 512 characters or an integer: {"query_id": "q17", "text_a": "how do I reset my password", "text_b": "Open Settings, then Security.", "label": 1}. When the validation rows carry it, evaluation also reports ranking metrics; the metrics and their conditions are under Classifier / Reranker / Cross-Encoder. Rows without a query_id are unchanged. A query_id that is a boolean, a float, a list, an empty string or longer than 512 characters, or ids that mix integers and strings across the training and validation rows, loaded on v0.77.2 and is refused now, with the row that differs (train row 3: query_id must not be bool, got True; val row 0: query_id type int differs from type str used at train row 0; use one type (all str or all int) for query_id in the training and validation rows). Give every query_id one type. The check runs when soup train loads the data, --dry-run included (exit 1 on the v0.78.0 binary); soup data validate does not make it and calls such a file valid.
And auto, the default, is the twentieth value. It reads up to the first 100 rows, not only the first, and only for the twelve formats with a section of their own higher up this page. The seven in the block above must be named in data.format. prm, pre_tokenized, input_output and raft rows fail auto-detection with "Cannot detect format". video and multimodal rows carry messages, so auto-detection reads them as chatml: for video that drops the video path, and for multimodal it skips the content-part validation. One more pair to know: a sharegpt4v row has exactly the keys of a llava row, so auto-detection reads it as llava; name sharegpt4v if you mean it.
How a mixed file is read (v0.76.0). Each of the sampled rows resolves to the richest format its keys fit. If every row agrees, that format is used. A file that mixes a richer and a poorer shape of the same family (llava with sharegpt, tool-calling with chatml, audio with chatml, asr with plaintext) loads as the richer one only when that converter accepts the poorer rows and yields the same messages for them. Any other mix is refused naming both shapes and the row where each first appears, for example Cannot detect format: this dataset mixes unrelated shapes 'chatml' (row 0) and 'llava' (row 1). ... Set data.format explicitly. Set data.format to choose. Rows after the first 100 are not inspected, and soup data validate counts every row the chosen format drops and prints the reasons for the first three. Before v0.76.0 only the first row decided, so a first row that lacked an optional key (a text-only LLaVA row, say) picked the poorer converter for the whole file and silently dropped that key from every row that had it. Re-run a training that auto-detected a file like that.
Rows that do not convert
A row the converter rejects is still dropped, so one bad line cannot abort a load. Since v0.76.0 it is no longer silent. A line that is not a JSON object, or not valid JSON, never reaches a converter: the loader skips it with a warning naming the line (the first three of each kind, then ... and N more), and since v0.77.0 soup data validate counts it as an invalid row (see Data tools). soup train, --dry-run included, prints Warning: N of M rows dropped: they do not convert as '<format>'. First: row <i>: <reason>. and, for a local file, the hint List them all with: soup data validate <file> --format <format>. That command counts every dropped row and prints the reasons for the first three, then ... and N more. If the load ends with zero training rows, soup train exits 1 before loading the model, naming the format and the first drop reason; a dry run used to print "Ready to train!" on zero rows.
Nested lists and dicts in a Parquet file (a messages column, tool calls) load as Python values. Before v0.76.0 they were turned into NumPy arrays and the rows were dropped by validation, so check a Parquet dataset that trained on fewer rows than it held.
Image and audio paths
A relative path in a llava, sharegpt4v, audio or asr row resolves against data.image_dir or data.audio_dir when it is set, and otherwise against the directory of the local file the row came from. Since v0.76.0 that holds on every load path: a local file, a local or streaming interleave, a remote URI, a Hub dataset and the data.replay file. A row whose file lies outside that directory is skipped with a warning. A remote URI or a Hub dataset has no local directory, so when its rows hold file paths data.image_dir or data.audio_dir is required, and the load stops naming it; data.image_dir: . resolves them under the working directory. A path that names a network share, a device or an extended-length path (\\host\share\..., //host/share/..., \\?\..., \\.\...), or that holds a NUL byte, is skipped without being looked up. Write such rows relative to the media directory instead. Through v0.75.2 the streaming, remote and Hub paths kept a relative path as written, so data.image_dir did nothing there. Before a media file is read, vision and audio SFT and the ASR and TTS audio loaders check that it is a regular file: on the SFT paths a directory, FIFO or device gives the usual cannot open warning and the row is skipped, while the ASR and TTS loaders stop with an error, as they do for a symlink. The check runs before the file is opened, so a file swapped in between the check and the read is not caught. See Vision and audio for the training side.
All data normalizes internally to {"messages": [...]} structure (+ "image" for vision, "audio" for audio, + "tools" for tool-calling).
Soup is free and Apache-2.0. If it saved you a training run, starring the repo costs nothing and helps most. You can also fund the GPU time behind the work a 4 GB laptop cannot reach.