# Instruction tuning

Instruction tuning is fine-tuning a model on pairs of an instruction and the response it should give, across many tasks, so that it follows requests instead of only continuing text.

## How it works

A base model straight from [pre-training](/glossary/pre-training) continues text. Ask it a question and it may answer, or it may write more questions. Instruction tuning fixes that with [supervised fine-tuning](/glossary/supervised-fine-tuning) (SFT) on examples that pair a request with the response to give.

The loss is the usual next-token loss, often counted on the response only. The data spans many tasks (summarizing, translating, classifying, writing code), so the model learns the general habit of doing what it is asked, including on tasks it never saw in training.

## Instruction tuning and chat models

A chat model is an instruction-tuned model whose examples are conversations: system, user and assistant turns wrapped in a [chat template](/glossary/chat-template). Model names often show the difference. A "base" checkpoint is pretrained only, and an "instruct" or "chat" checkpoint has been tuned.

For a chat task, start from the instruct checkpoint. It already follows requests, so your data only has to teach the task.

## In Halo

Instruction data is ordinary `sft` data. One record is one conversation:

```jsonl
{"prompt": [{"role": "user", "content": "Explain gravity."}, {"role": "assistant", "content": "Gravity is ..."}]}
```

Completion-only masking (`train_on_completions_only`, on by default) trains on assistant turns only and masks the prompt. See the [SFT guide](/halo/docs/training-methods/sft).

