Format, task execution, style, or domain decision patterns.
Supervised fine-tuning · explained end to end
Prepare examples for supervised fine-tuning—without hiding the machinery.
Upload a dataset in the browser, inspect the prepared result, then explore how a real run would apply completion-only masking, NF4 QLoRA, evaluation gates, and adapter deployment.
text + labelsystem → user → assistant-100 · -100 · target tokensadapter + measured metricsStored in memory-efficient 4-bit NF4 during QLoRA training.
Low-rank matrices learn the task-specific update.
Lower training loss alone is never enough.
Live dataset lab
Upload a file. Prepare an inspectable SFT dataset.
Run ingestion, schema mapping, validation, deduplication, deterministic splitting and prompt formatting in your browser. Your file is never sent to a server.
Choose a dataset
Map your columns
Columns are suggested automatically when names match common patterns. Review every selection before preparing.
This demo uses a seeded row split. In production, group related customers, documents, sources or templates before splitting to prevent leakage.
Your prepared result appears here
Upload a file or load the sample, map its columns, then run validation.
- Schema and row checks
- Deterministic row split
- Messages + split metadata export
Browser-prepared JSONL
Intended completion-only policy: context would be excluded from loss; the assistant response would contribute. No optimization occurs here.
What happens next: the combined JSONL carries a split field and is an inspectable handoff artifact. Before training, adapt its prompt/completion contract to your trainer, apply the selected model’s exact tokenizer and chat template, and enforce completion-only masking in the collator. This page does not claim training occurred.
One record · eight transformations
Inspect the complete SFT journey
Select a stage. The same synthetic record stays in view so you can see exactly what changes, why it changes, and what can go wrong.
01
Ingest semi-structured data
Load CSV, Excel, JSON, or JSONL. Map one or more text columns, optional metadata, labels, and an optional response column through configuration—not hard-coded schema assumptions.
The same pipeline can support social posts, support tickets, or evaluation logs by changing column mappings in one YAML file.
Missing columns or silent type coercion. The implementation validates required columns and stops with an explicit error.
The most important training detail
The prompt gives context. The completion carries the loss.
Completion-only masking prevents the model from being rewarded for copying system and user text. Only the intended assistant response contributes to cross-entropy loss.
labels[token] = -100 for prompt · labels[token] = token_id for assistant completion
CrossEntropyLoss ignores −100
Find the assistant marker
ChatML uses <|im_start|>assistant; Llama 3 uses its assistant header token sequence.
Mask every earlier token
System instructions, user context and padding become label -100.
Verify before training
Render one example and inspect labels. A wrong boundary can train on the prompt—or hide the answer.
Illustrative QLoRA profile
Memory-efficient by design
This reference profile pairs Qwen2.5-7B-Instruct with 4-bit NF4 and LoRA adapters. It explains a configuration; it is not a launched or benchmarked run.
q_projk_projv_projo_projgate_projup_projdown_projInteractive controls preview configuration relationships only. They do not launch training or estimate memory, quality, time, or cost.
Reference architecture
Six responsibilities. One reproducibility contract.
A production implementation can separate configuration, data preparation, model loading, training, evaluation, and inference while versioning them together.
config.yamlModel, data contract, LoRA, training, generation and evaluation settings.
dataset.pyLoad, clean, split, template, tokenize and diagnose length distribution.
model.pyTokenizer, quantization, gradient checkpointing and PEFT adapters.
trainer.pySFTTrainer, completion-only labels, logging, checkpoints and safety callbacks.
train.pySeed, orchestrate, train, evaluate and save every artifact.
inference.pyGenerate, score, benchmark, merge adapters and export.
Promotion gate
Measure behavior, not just loss
A real evaluation run should calculate held-out generation metrics and add domain rubrics, safety regression tests, and direct base-versus-adapter comparison before promotion.
Exact match & schema validity
Did the output parse, follow the requested keys, and preserve required value types?
Accuracy · macro / micro F1
For single-label structured outputs, compare predicted and target labels on unseen rows.
Perplexity
Useful for trend diagnosis, but lower perplexity does not prove factuality or safety.
Average generation latency
Measure in the actual serving environment with the chosen quantization and batch shape.
No benchmark result has been fabricated for this demo.
The browser demo passed interaction and synthetic data-flow checks. No model training or benchmark run was executed.
Deployment outputs
Choose the artifact that fits the serving model
Adapters can stay separate for flexibility, or be merged into a compatible base model for a simpler serving artifact. Either route must preserve tokenizer and template identity.
Adapter-only
Small artifact. Load the licensed base model and task adapter together.
- Flexible versioning
- Multiple tasks per base
- Requires PEFT-aware serving
Merged checkpoint
Combine LoRA deltas with a compatible higher-precision base checkpoint.
- Simpler single-model serving
- Larger artifact
- Less adapter flexibility
Export manifest
base checkpointadapter weightstokenizerchat templategeneration configevaluation reportWhat a real project requires
Training starts after the governance work
A clean implementation cannot compensate for ambiguous labels, unauthorized data, weak evaluation, or an unowned production decision.
Data rights & privacy
Document license, consent, retention and sensitive-data removal.
Label contract
Define edge cases, reviewer agreement and the exact output schema.
Leakage-safe split
Group related sources before splitting; keep a final untouched test set.
Base-model license
Confirm intended use, redistribution and deployment obligations.
Evaluation ownership
Set pass/fail thresholds with domain and safety reviewers.
Monitoring & rollback
Version artifacts, observe regressions and retain a tested rollback path.
Plain-language answers
What clients usually ask
What does supervised fine-tuning actually change?
In this QLoRA setup, the quantized base weights remain frozen. Training updates small LoRA matrices attached to selected attention and MLP projections.
Can SFT teach the model new facts?
It can influence outputs, but SFT is strongest for stable behavior, format and task patterns. Frequently changing facts belong in retrieval or tools, not model weights.
Why not train on the full prompt?
The system and user turns provide context. Completion-only masking focuses the gradient on the response the model should learn, reducing waste and prompt memorization.
Does a lower evaluation loss mean the model is ready?
No. Loss is one diagnostic. Promotion also needs task metrics, format validity, human review, safety regressions, latency checks and base-model comparison.
What does the live dataset demo actually run?
It really parses, maps, validates, deduplicates, splits and formats your local file, then creates downloadable JSONL and diagnostics. It does not allocate GPU compute or claim that a model was fine-tuned.