Overview
Qwen fine-tuning expects training data in JSON format with a specific conversation structure. The data format follows a message-based approach compatible with the ChatML template.File Structure
Training data should be a JSON file containing an array of conversation examples:Conversation Format
Each training example is an object with aconversations key:
array
required
Array of message objects representing a multi-turn conversation
Message Object
Each message in the conversation has two fields:string
required
Role of the message sender:
"user": User/human message"assistant": Model response
string
required
Content of the message
Simple Example
Single-turn conversation:Multi-turn Example
Conversation with context:Complete Dataset Example
Token Processing
During preprocessing, conversations are converted to the ChatML format:Training Targets
The model is trained to predict only the assistant’s responses:- User messages: Masked with
IGNORE_TOKEN_ID(not included in loss) - Assistant messages: Used for loss calculation
- System message: Masked (not predicted)
preprocess() function in finetune.py.