Vision & Audio Fine-Tuning
Vision / Multimodal
Fine-tune vision-language models (LLaMA-3.2-Vision, Qwen2-VL, Pixtral):
pip install "soup-cli[vision]"
soup init --template visionbase: meta-llama/Llama-3.2-11B-Vision-Instruct
task: sft
modality: vision
data:
train: ./data/vision_train.jsonl
format: llava
image_dir: ./data/images
val_split: 0.1
training:
epochs: 3
lr: 1e-5
quantization: 4bit
lora:
r: 64
alpha: 16The vision and audio SFT setups build their own dataset and model, running neither the SFT formatter nor the resident kernel setup. Since v0.77.2 (#2278, by @abdulwaarith0) a modality: vision or modality: audio config that sets training.reasoning_effort, train_on_eot, use_flash_attn or use_liger is refused at load, naming the field and the fix (soup train exits 1, soup doctor --config exits 2). Leave the key out; the three booleans also load when set to false, and reasoning_effort loads when it is null. Through v0.77.1 such a config loaded and trained without the setting, so removing the line changes nothing about what trained. See Settings Soup refuses at load.
Vision Data Formats
LLaVA:
{"image": "photo.jpg", "conversations": [{"from": "human", "value": "<image>\nDescribe this image."}, {"from": "gpt", "value": "A cat on a mat."}]}ShareGPT4V:
{"image": "chart.png", "conversations": [{"from": "human", "value": "<image>\nWhat does this show?"}, {"from": "gpt", "value": "Quarterly revenue."}]}A relative image path resolves against data.image_dir, or against the directory of the data file when image_dir is unset. A Hub dataset or a remote URI has no data file directory, so set data.image_dir when its rows hold image paths: since v0.76.0 the load stops with a message naming the setting if you set neither (data.image_dir: . resolves them under the working directory), and a row whose file lies outside the directory is skipped with the usual "rows skipped" warning. Before that, rows from a streaming data.interleave, a remote URI or a Hub dataset kept the path as written, so a relative path was opened against the working directory and image_dir had no effect. An image a Hub dataset has already decoded is passed on as before, and Parquet image structs ({"bytes": ..., "path": ...}) are accepted, their path following the same rules. The same holds for audio paths and data.audio_dir.
soup data inspect automatically shows image statistics (count, formats, missing files) for vision datasets, resolving paths the same way (or with --image-dir). The full path rule, including the remote URI, Hub dataset and replay-file cases, is on Data formats.
Vision and audio SFT supervise every sequence token: the multimodal collators do no assistant-only masking, so data.train_on_responses_only and data.mask_history have no effect there (#1156). Since v0.77.0 soup doctor --config lists only data.mask_history as ignored on modality: vision or audio (#1791 dropped the train_on_responses_only row); through v0.76.1 it listed both. On backend: mlx the same setting prints rejected, not ignored (native selective message masks support text SFT only, since v0.78.0, when native MLX text SFT started to honour data.mask_history; vision and audio on MLX refuse it). training.moe_lora, rope_scaling_type, freeze_layers and freeze_ratio are refused at config load on vision and audio SFT.
Three more refusals at config load since v0.77.0:
backend: unslothwithmodality: visionoraudioon SFT (#2015): the vision and audio setup paths load through transformers and never used Unsloth, so such a run silently ran on transformers. The setting loaded and was never applied: usebackend: transformers, which changes nothing about what trains.llavaandsharegpt4vrows on preference tasks (dpo,ipo,simpo,orpo,bco,preference; #2064): they have no vision-preference row path, so use a text preference format. On v0.76 such a run failed after the model had loaded. Thepixtral-dporecipe was retired with it.modality: visionoraudiowithtask: distill(#2014): the distill trainer loads a text-only student and teacher, so the setting was never applied and deleting it changes nothing about what trains.
Audio / Speech
Fine-tune audio-language models (Qwen2-Audio, Whisper):
pip install "soup-cli[audio]"
soup init --template audiobase: Qwen/Qwen2-Audio-7B-Instruct
task: sft
modality: audio
data:
train: ./data/audio_train.jsonl
format: audio
audio_dir: ./data/audio
val_split: 0.1
training:
epochs: 3
lr: 1e-5
quantization: 4bit
lora:
r: 64
alpha: 16Audio Data Format
{"audio": "recording.wav", "messages": [{"role": "user", "content": "Transcribe this audio."}, {"role": "assistant", "content": "Hello world."}]}A relative audio path resolves against data.audio_dir (or the data file's directory) by the same rule as image paths: see Data formats.
Want to fine-tune Whisper itself (speech-to-text, not audio understanding)? That is a dedicated task since v0.71.32: see ASR fine-tuning (
task: asr,format: asr, built-in WER/CER, whisper-tiny/base train on a 4 GB GPU).
Continued Pre-training
Continue training on raw text for domain adaptation:
base: meta-llama/Llama-3.1-8B
task: pretrain
data:
train: ./data/corpus.jsonl # {"text": "..."} or plain .txt files
format: plaintext
max_length: 4096
training:
epochs: 1
lr: 1e-5
quantization: 4bitEmbedding Fine-Tuning
Train sentence embedding models with contrastive learning:
base: sentence-transformers/all-MiniLM-L6-v2
task: embedding
data:
train: ./data/embeddings.jsonl
format: embedding
training:
embedding_loss: contrastive # contrastive, triplet, cosine
embedding_pooling: mean
embedding_margin: 0.5
embedding_temperature: 0.05Embedding Data Format
A contrastive set, where the other rows in the batch are the negatives (rows with anchor and positive only):
{"anchor": "What is Python?", "positive": "Python is a programming language."}
{"anchor": "What is a mammal?", "positive": "A warm-blooded animal that feeds its young milk."}A triplet set, where every row also has a negative (use it with embedding_loss: triplet):
{"anchor": "What is Python?", "positive": "A programming language.", "negative": "A type of snake."}
{"anchor": "What is a mammal?", "positive": "A warm-blooded animal.", "negative": "A cold-blooded reptile."}Do not mix the two in one file. Since 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 names how many rows have one and how many lack one (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); soup train --dry-run does not make this check). Through v0.77.2 the first row decided, so such a set trained without any negative or crashed in the collator. Give every row a non-blank negative, or remove it from every row.
embedding_loss: contrastive (the default) needs other rows in the batch as negatives, so since v0.76.0 batch_size: 1 is refused at config load (#1234): with one row the loss and gradient are exactly 0 and the adapter never moves. batch_size: auto resolves to at least 2, the last partial batch of an epoch is dropped, and a batch larger than the training set is lowered to its size. Use triplet (with negative rows) or cosine for a batch of 1.
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.