Formatting and validating JSONL datasets
Standard chat-messages JSONL format and split hygiene
Supervised fine-tuning (SFT) expects one JSON object per line with a messages array (system, user, assistant). Always split into train (85–90%) and validation (10–15%) BEFORE training so you can measure generalization honestly.
Run this validator to catch malformed rows, missing assistant turns, or empty content before burning GPU time.
Example
import json
rows = [
{'messages': [
{'role': 'system', 'content': 'Classify support tickets as JSON.'},
{'role': 'user', 'content': 'Charged twice on invoice 88'},
{'role': 'assistant', 'content': '{"queue": "billing"}'},
]},
{'messages': [
{'role': 'system', 'content': 'Classify support tickets as JSON.'},
{'role': 'user', 'content': 'API returns 502'},
{'role': 'assistant', 'content': '{"queue": "infra"}'},
]},
]
errors = []
for idx, row in enumerate(rows):
roles = [m.get('role') for m in row.get('messages', [])]
if 'user' not in roles or 'assistant' not in roles:
errors.append(f'Row {idx}: missing user or assistant turn')
if any(not m.get('content', '').strip() for m in row['messages']):
errors.append(f'Row {idx}: empty message content')
print('Validated rows:', len(rows), '| Errors:', errors)Example explained
- messages array — Universal SFT schema supported across MLX, Unsloth, Axolotl, and praisonai-train.
- roles check — Ensures every example has both a prompt and a non-empty target assistant reply.
Validate and generate synthetic edge cases with the CLI
Use praisonai train data validate to check token lengths, schema consistency, and balance across classes before launching training.
Example
# Validate schema, roles, and token distribution
praisonai train data validate --input clean_train.jsonl
# Optionally synthesize extra edge-case rows to balance rare classes
praisonai train data generate --topic "billing vs security tickets" --count 200 --output synth.jsonlExample explained
- data validate — Fails fast on broken JSON lines, overly long prompts, or empty assistant replies.
- data generate — Bootstraps balanced examples for under-represented categories.
Common pitfall: training on mismatched system prompts
Use the EXACT same system prompt in your training rows that your production Agent will send at inference time. Changing instructions later degrades accuracy.
Reference: documentation