Concepts / Preparing Data for Model Training

Preparing Data for Model Training

A finetuned model works best when the prompts you send match the format of its finetuning data, including small details such as punctuation and spacing.

  • Programming

A Clear Request Can Still Be a Mismatch

It is tempting to assume that once a model has been finetuned, any clearly worded request will work. But a finetuned model learns from examples with a particular arrangement of words, punctuation, and spacing. A prompt can make sense to a person and still differ from the format the model was trained to expect. The practical goal is not just to write a clear request; it is to write one that fits the format used in finetuning.

What do you think happens?

Suppose the finetuning examples use the input pattern burger -->. Which later prompt most closely matches that pattern: burger, Item: burger -->, or burger --> with a trailing space?

Reveal answer
Answer:

burger --> without an added prefix or trailing space most closely matches the stated pattern.

The other two prompts differ from the training format: one omits the arrow, and the other adds a prefix or a trailing space. Such near-miss prompts can cause issues, even when their meaning seems clear.

burger -->burgerItem: burger -->burger -->
How do these prompts compare with the training pattern burger -->? The exact match preserves the pattern, while the other examples change its text or spacing.

What the Training Format Teaches

Finetuning teaches a model from examples, and each example has a shape: an arrangement of words, punctuation, and spacing. That shape becomes part of what the model has learned to expect. When you later send a prompt that follows the same format, you are giving it input that resembles those examples. When you change the format, you are asking it to handle input that differs from what it was trained to expect. A difference does not guarantee failure, but near-miss prompts can cause problems.

Finetuning examplesLearned formatMatching promptPossible issuesDifferent promptformatteachresemblesdiffers frommay cause
How does the format used in training connect to a later prompt? A matching prompt follows the learned pattern; a different format may cause issues.
Worked example

Check a Prompt Against Its Training Pattern

Training examples use the pattern burger -->. Decide whether each candidate preserves that pattern.

  1. 1
    Compare the words and punctuation

    The candidate burger omits the arrow shown in the training pattern.

  2. 2
    Check for added text

    Item: burger --> adds a prefix that is not part of the stated pattern.

  3. 3
    Check spacing too

    burger --> with a trailing space adds a formatting difference, even though the visible words and arrow are present.

Result

burger -->, with no added prefix or trailing space, is the closest match to the training pattern. The other variants are near misses that may cause issues.

How Finetuning Can Shorten Prompts

A base model may need a longer prompt to spell out the instructions for a task. After finetuning, the model may have learned the desired behavior from its examples, so a request can often be much shorter. The instructions have not vanished from the model's behavior; rather, the source explains that the full set of instructions no longer needs to be written into every request.

Task instructionsLearned behaviorRequest detailsShorter requestincluded withcan reduce length of
What changes after finetuning? The base-model prompt spells out the task instructions, while a finetuned model may need a shorter request because it has learned the desired behavior.
Best practice

If input token use matters for your task, consider whether finetuning could reduce the instructions you send repeatedly. Measure the actual token use for your own prompts rather than assuming a particular saving: the source gives no token counts or pricing.

Choose a Format by Testing It

There is no single format identified here as best for every task. Different finetuning data formats can affect performance, so treat the format as a choice to test rather than a mere bookkeeping detail. Prepare the examples in more than one format, finetune a model on each version, and compare the results on the task you care about. A format that looks tidy on paper is not necessarily the one that produces the best behavior. After choosing a format, keep later prompts consistent with it.

Format AModel trained on ATask resultsFormat BModel trained on Bfinetunefinetunecompare on taskcompare on task
How can you choose between finetuning data layouts? Train on alternative formats and compare their results on the task you care about.
InstructionTask wordingSeparatorFormat detailInputTask material
This generic schematic highlights parts of a format that can matter when preparing examples and sending prompts. It is not a prescribed syntax: use the particular arrangement, punctuation, and spacing of the format you chose.

Common Prompt-Preparation Mistakes

  • Common mistake

    Assuming any reasonable wording will work after finetuning.

    Why it fails

    The model learned from examples with a particular format, and a clear request can still differ from that format.

    Do this instead

    Compare the prompt's words, punctuation, and spacing with the examples used for finetuning.

  • Common mistake

    Ignoring small differences such as a missing arrow or an added prefix.

    What it looks like

    The training pattern is burger -->, but the prompt is burger or Item: burger -->.

    Why it fails

    These are near misses rather than exact matches to the stated pattern, and near misses can cause issues.

    Do this instead

    Keep the prompt aligned with the training format unless you have tested a different format.

  • Common mistake

    Treating an appended space as irrelevant.

    What it looks like

    The prompt is burger --> with a trailing space.

    Why it fails

    Spacing is one of the small formatting details that can distinguish a prompt from the training pattern.

    Do this instead

    Check spacing as well as words and punctuation.

  • Common mistake

    Choosing a data format only because it looks tidy.

    Why it fails

    Different formats can affect performance, and appearance alone does not establish which works best for a task.

    Do this instead

    Test alternatives and compare their results on the task you care about.

Apply the Format-Matching Check

EASY

A set of finetuning examples uses the input pattern burger -->. A new prompt is Item: burger --> with a trailing space. Identify two differences from the pattern and explain why the prompt could cause problems.

Hints
  • Compare the beginning of the prompt with the training pattern.
  • Check the spacing at the end as well as the visible words and punctuation.

A strong answer identifies the added prefix and trailing space. Both make the prompt differ from the stated training pattern, so the prompt is a near miss that may cause issues. The practical response is to match the training format or test the alternative rather than assume the model will treat the formats as interchangeable.

Key Takeaways

  • Finetuned models learn from examples with a particular arrangement of words, punctuation, and spacing.
  • Prompts that differ by a missing symbol, an added prefix, or extra spacing can be near misses and may cause problems.
  • Finetuning can allow shorter prompts by reducing the need to repeat full instructions, which can help manage input token costs.
  • Different finetuning data formats can affect performance; test alternatives on the task you care about.
  • Once you choose a format, make later prompts resemble that format.

More concepts starting with P