Privacy note: We capture your IP address to provide customised and focused services. See our Privacy Policy.

Generative AI & Large Language Models — Alpha School

Lesson 10: Giving a Model Structure: Roles, Examples and Output Formats

In the last lesson you learned the basics of prompting. This lesson goes further: how to give a model a clear structure so its output is not just good but usable — in the exact form you need, every time. The difference between a casual chat and a working tool is usually structure: a role that sets the model's stance, a format that sets its output, and constraints that keep it inside the lines. Once you can do that reliably, you can build things with a model rather than merely chatting with it.

Start with the role. A model asked to 'act as a patient tutor for a 12-year-old' will explain slowly, check understanding and avoid jargon; the same model asked to 'act as a strict editor' will cut, criticise and tighten. The role is not magic — the model has no real role, it is simply continuing text in the style that role suggests — but it is a powerful steering device, because style and stance are exactly what next-token prediction is good at. Choose a role that matches the job, and state it plainly at the start of the prompt.

Format is a contract

Next, the output format. If you need a list, say so: 'Answer as a numbered list of five points, each one sentence long.' If you need data, ask for a table with named columns, or for a structured format that a program can read. Being explicit about format does two things: it makes the output immediately usable without reformatting, and it forces the model to organise its thinking. A model asked to fill a table with columns for name, price and rating must decide each cell separately, which is often more reliable than asking for a free paragraph and hoping the details are in there.

Constraints and checks

Then add constraints: what the model must do, and what it must not do. 'Use only the information in the passage below. If the answer is not in the passage, say so.' 'Do not invent dates, names or numbers.' 'Keep the answer under 100 words.' Constraints are how you protect yourself from the model's worst habits — invention, waffle, and confident guessing. A useful trick is to ask the model to quote its evidence: 'Give the answer, then quote the sentence from the passage that supports it.' If it cannot quote anything, that itself is information.

Chaining prompts: breaking a big job into steps

Some jobs are too big for one prompt. Asking a model to research a topic, judge the evidence and write a polished report in a single step usually produces a report that is fluent and unreliable, because each part of the job is being done at once, with no chance to check the earlier parts. The remedy is chaining: break the job into steps, each with its own prompt, and pass the output of one step into the next. First, ask the model to list the questions that need answering. Then, for each question, ask it to find the answer in the documents. Then ask it to check each answer against its source. Only then ask it to write the report. Each step is small enough to check, and a failure in one step is visible before it poisons the rest. Chaining costs more — several model calls instead of one — but for any job where correctness matters, it is the difference between a draft you can trust and one you cannot.

Finally, build in a check. After the model answers, ask it to review its own answer against the instructions: 'Check your answer against the passage. Is every claim supported? List any claim you cannot support.' Self-checking is not foolproof — a model can confidently approve its own mistakes — but it catches a surprising amount, and it teaches you the habit that matters most when working with these models: never accept the first answer as the final answer. Structure the prompt, check the output, and only then use it.

Key Terms

Role
A part assigned to the model in the prompt, such as a patient tutor or a strict editor, which steers its tone and approach.
Output format
The shape the answer must take, such as a numbered list, a table, or a structured format a program can read.
Constraint
A rule in the prompt about what the model must or must not do, such as using only the passage given, or not inventing dates.
Structured output
An answer in a fixed, machine-readable form, such as a table with named columns.
Self-check
Asking the model to review its own answer against the instructions or the evidence, to catch unsupported claims.
System prompt
The background instruction given to a model before the user's message, setting its role and rules for the whole conversation.

Discussion Questions

  1. Why does asking for a table with named columns often give a more reliable answer than asking for a free paragraph?
  2. A model is told 'use only the information in the passage'. Why is that constraint so useful, and what should the model do if the answer is not there?
  3. When would you want a model to act as a patient tutor, and when as a strict editor? What changes in its answers?

Practice Questions

  1. What does giving a model a role do?
  2. Why is the output format important?
  3. Give one example of a useful constraint.
  4. Why ask a model to quote its evidence?
  5. Why should you never accept the first answer as the final answer?
Show answers
  1. It steers its tone, style and approach towards the job. A patient tutor explains slowly and checks understanding; a strict editor cuts and criticises.
  2. It makes the answer immediately usable and forces the model to organise its thinking. A table with named columns makes the model decide each cell separately.
  3. Use only the information in the passage below, and say so if the answer is not there. Other examples: do not invent dates or numbers, or keep the answer under 100 words.
  4. So you can check whether each claim is supported. If it cannot quote anything, that itself tells you the claim is unsupported.
  5. Because the model can be confidently wrong, and a self-check catches many mistakes. Structure the prompt, check the output, and only then use it.
Keep reading to complete this lesson