Concepts / Instruction Finetuning Data Formats

Instruction Finetuning Data Formats

Structure comes first, generation second. Decide what the dataset must contain, then ask for instructions against that plan.

  • Programming

Why Instruction Data Needs Building

Instruction finetuning teaches a model to follow directions by showing it many examples. Each example pairs a request with an answer. Building a large collection of these pairs by hand is slow, so practitioners often ask an AI model to help produce them. The useful question is therefore not whether AI should be involved at all, but which parts of each pair it should produce.

What do you think happens?

Suppose you ask an AI model for a large batch of instructions and give it no structure at all, such as a topic list or templates. What do you think the batch will look like?

  • A wide, even spread across every part of the intended use case

  • Instructions that cluster around a few themes and leave large parts of the use case unrepresented

Reveal answer
Answer:

The second option. Without structure, the results may cluster around a few themes and leave large parts of the intended use case unrepresented.

This is the main risk when generating instructions, and it is why the rest of this article focuses on imposing structure before generating anything.

Splitting One Example Between AI and People

Definition

Each instruction-finetuning example has an instruction and a response. AI can synthesize either half or both.

A single training example always has two parts, so there are several ways to assign the work. AI can be used to synthesize the instructions, the responses, or both. A team could let AI draft the requests while people write the answers. The reverse arrangement is also possible, with people writing the requests and AI producing the answers. Both halves can also be generated by AI.

Read the diagram column by column. Each column is one possible division of labor for the same two-part record. The choice among them is a design decision about where human judgment is most needed, not a rule that one arrangement is always correct. The source material describes all of these options as valid ways to assign the work.

Why Coverage Needs Structure

The main risk when generating instructions is coverage. If an AI model is simply asked for instructions with no structure, the results may cluster around a few themes and leave large parts of the intended use case unrepresented. The remedy is to impose structure before generating anything. Coverage then becomes a matter of counting: every topic on the list receives its share of instructions.

Key point

Structure comes first, generation second. Decide what the dataset must contain, then ask for instructions against that plan.

Expanding Topics and Templates into Instructions

A common starting point is a list of topics, keywords, or instruction types that the dataset should contain. For each item on that list, you generate a chosen number of instructions. The topic list does not have to be written by a person. Both the topic list and the templates can be generated by AI. A practitioner can ask a model for a broad set of subjects, review them, and then use that reviewed list as the skeleton for instruction generation.

Worked example

Covering a use case with a topic list

A team wants a dataset of cooking and travel help. They have a reviewed list of two topics and decide to generate four instructions for each topic. How many instructions does the dataset receive, and does every topic get a share?

  1. 1
    Start from the reviewed list

    The reviewed topic list is the skeleton. It contains Cooking and Travel.

  2. 2
    Apply the chosen number to each item

    Four instructions are generated for each topic, so Cooking receives four and Travel receives four.

  3. 3
    Count the coverage

    Two topics times four instructions gives eight instructions. Because every topic is generated against the same chosen number, no topic is left out.

Result

The dataset holds eight instructions, four per topic, so both topics are represented. Coverage is a matter of counting.

Generating One or Many Responses

Once instructions exist, each one needs a response. You can generate one or more responses per instruction. Producing more than one response for the same instruction gives the dataset alternative answers to the same request. This follows from the one-to-many arrangement used for response generation: one instruction can lead to several responses.

Tracing UltraChat: From Topics to Pairs

UltraChat is a multi-turn dialogue dataset that follows the topic-first pattern. Its authors first asked ChatGPT to generate 30 topics about various aspects of daily life, including technology, food and drink, fashion, nature, education, finance, and travel. For each topic, they asked the model to produce 30 to 50 subtopics. The same model was then used to generate instructions and corresponding responses for those subtopics.

Trace the flow step by step. The process moves from broad topics, to narrower subtopics, to the instruction-response pairs themselves. Each stage narrows the focus, so that the final pairs are specific enough to cover the range of daily-life subjects that the topic list set out.

Tracing Alpaca: From Seeds to Many Pairs

Alpaca shows the other pattern, starting from examples rather than from topics. Stanford researchers began with 175 instruction-response examples taken from the Self-Instruct seed dataset. Those seed examples were written to cover a diverse and interesting range of uses. The Alpaca authors then used a GPT-3 model, text-davinci-003, to generate 52,000 instruction-response pairs that mirrored the seed examples.

Read the pipeline from left to right. The seed set is small and carefully written. The generation step takes its pattern from those seeds, and the output is a far larger set. The dataset grows from 175 seeds to 52,000 generated pairs, and each generated pair follows the pattern of a seed rather than being a copy of it.

Mistakes When Generating Training Data

  • Common mistake

    Asking for instructions with no structure

    What it looks like

    Requesting several hundred instructions in one unstructured prompt.

    Why it fails

    Results may cluster around a few themes and leave parts of the use case unrepresented.

    Do this instead

    Impose a topic list, keywords, or instruction types first, then generate a chosen number of instructions for each item.

  • Common mistake

    Treating the example as a single unit to generate

    What it looks like

    Asking one prompt to produce a whole instruction-response record without deciding who writes which half.

    Why it fails

    Each example always has two parts, and the assignment of AI and human work should be a deliberate choice.

    Do this instead

    Decide whether AI synthesizes the instructions, the responses, or both, and keep that choice consistent.

  • Common mistake

    Assuming the topic list must be hand-written

  • Common mistake

    Generating a responses-only dataset from one answer per request

    Why it fails

    A single answer leaves no alternative responses for the same request.

    Do this instead

    Generate one or more responses per instruction when the dataset should hold alternative answers.

Practice: Plan a Small Dataset

MEDIUM

A team wants to finetune a model to follow directions about household tasks such as cleaning, cooking, and repairs. Plan the dataset. Name the topic list you would use, state how many instructions you would generate per topic, decide who or what produces the instructions and the responses, and say how many responses you would generate per instruction.

Hints
  • Start with the topic list, because coverage comes from structure before generation.
  • Choose one arrangement for the instruction and the response, such as AI drafting the requests while people write the answers.
  • Remember that one instruction can have more than one response.

Summary

At a glance

  • Each instruction-finetuning example has an instruction and a response, and AI can synthesize either half or both.
  • Coverage comes from structure: start with a topic list, keywords, or instruction types, or with templates, and generate a set number of instructions for each item.
  • Responses can be generated one or more per instruction, which gives a dataset alternative answers to the same request.
  • UltraChat moved from topics to subtopics to pairs, while Alpaca grew 175 seed examples into 52,000 generated pairs that mirror the seeds.

Related concepts

More concepts starting with I