AI Hints
Home›Fine-Tuning LLMs Tutorial›Instruction Data
Fine-Tuning LLMs · Lesson 46 of 120

Instruction Data Formats

How examples are written.

⏱ 2 min read▶ Video at 1:13:51🎓 Free
Watch this lesson in the Fine-Tuning LLMs courseWatch on YouTube ↗Full Fine-Tuning LLMs course

Now we prepare data to teach a language model. Each example must show the model a request, and the exact answer we want. There are a few common ways to write these examples down.

  • Teach a model to write
  • A request and the right answer
  • A few common formats

Common formats

Plain text is one long string per example. It's simple, but the model can't tell the question from the answer. The Alpaca format has three fields. An instruction, an optional input, and the output. The messages format is a list of chat messages, with roles. And the prompt completion format splits the messages into two parts. The prompt, and the completion, which is the answer.

FormatLooks like
Plain text{"text": "..."}
Alpacainstruction, input, output
Messages[{"role": ..., "content": ...}]
Prompt + completionprompt: [messages], completion: [answer]

Which one we use

For chat models, the messages formats are best, because they match the chat template. We'll use prompt and completion. The prompt holds the system and user messages. The completion holds the assistant's answer. This makes it clear which part the model should learn.

keyvalue
Chat modelsuse a messages format
We useprompt + completion
promptsystem + user messages
completionthe assistant's answer

Summary

Let's recap. Training examples can be plain text, Alpaca style, chat messages, or prompt and completion. For chat models, use messages. And prompt and completion makes the answer clear. Next, building our chat dataset.

Key takeaways
  • Several formats
  • Messages for chat models
  • prompt + completion
Next up: Build a Chat Dataset — from rows to conversations