Datasets
What the model learns from. The format is simple; the quality of the examples is what decides how good the model gets.
Chat format
For SFT, use JSONL with one conversation per line in the OpenAI chat format. The model learns to write the assistant turns. Conversations can have several turns.
python
1{"messages": [{"role": "user", "content": "What's your return window?"}, {"role": "assistant", "content": "30 days from delivery."}]}2{"messages": [{"role": "system", "content": "Answer in one sentence."}, {"role": "user", "content": "Do you ship to Canada?"}, {"role": "assistant", "content": "Yes, in 5 to 8 business days."}]}
Preference format
For preference tuning, DPO, ORPO and SimPO read prompt, chosen and rejected; KTO reads prompt, completion and a true / false label.
python
1{"prompt": "Do you ship to Canada?", "chosen": "Yes, in 5 to 8 business days.", "rejected": "Shipping depends on many factors."}
Load it
Load a local file with Hugging Face datasets, or pass the name of a dataset on the Hub.
python
1from datasets import load_dataset23train = load_dataset("json", data_files="train.jsonl", split="train")4split = train.train_test_split(test_size=0.1, seed=42) # keep 10% back for evaluation
Check it before training
DatasetIntelligence reads JSONL, JSON, CSV, TSV or Parquet and reports the task it looks like, the number of examples, average length, duplicates, a health score and suggestions. Without an API key set, it runs on your machine.
python
1from langtrain import DatasetIntelligence23report = DatasetIntelligence.analyze("train.jsonl")4print(report.sample_count, report.avg_tokens, report.dedup_ratio, report.health_score)5for tip in report.enhancement_suggestions:6 print("-", tip)
What makes a good example
- Consistent - the same kind of question gets the same kind of answer. Contradictions teach the model to guess
- Real - drawn from the questions your users actually ask
- Exactly what you want back - the model copies length, tone and format, mistakes included
- No duplicates - repeated examples get memorised
- No secrets - a model can repeat what it was trained on; strip keys, passwords and personal data