insideout Get Pro
Learn
AI engineering · Module 07

Prompting

Get reliable, well-formed answers out of a model.

Start here · Lesson 01

How a chat request is built

Roles, messages and the template a model actually reads.

Start lesson

LessonsAll lessons

  1. 01 How a chat request is builtRoles, messages and the template a model actually reads. Free
  2. 02 Who outranks whom in a promptHow models weigh system, user and tool instructions when they conflict. Free
  3. 03 Few-shot examplesHow examples in the prompt steer format and behaviour. Free
  4. 04 JSON that always parsesSchemas, JSON mode, and how to recover from bad output. Pro
  5. 05 Grammars that constrain decodingMask invalid tokens at each step so output always fits a grammar. Pro
  6. 06 Letting the model call functionsTool definitions, tool calls, and the loop that runs them. Pro
  7. 07 A budget for the context windowDecide what earns a place in the prompt and what stays out. Pro
  8. 08 Order effects in long promptsWhere you put information changes whether the model uses it. Pro
  9. 09 Fitting more into the windowSummarise, extract or retrieve instead of pasting everything. Pro
  10. 10 Capstone: a prompt pipeline for a support deskTemplates, examples, structured output and tool calls working together. Pro

Build it yourself · on your own machine

A support desk pipeline on a local model

A prompt pipeline that reads customer messages and returns valid JSON with the intent, the order number and a reply, calling a lookup tool when it needs one.
  1. Take 100 messages from the Bitext customer support dataset on Hugging Face (27 intents), swap each {{Order Number}} placeholder for a made-up number, and keep 50 for tuning and 50 for the final score.
  2. Write a system prompt with your rules, and a schema with the intent (one of the 27), the order number or null, and a one-line reply.
  3. Run a small model in Ollama three ways (asking for JSON in words, JSON mode, and your schema passed as format), and validate every reply with Pydantic.
  4. Add three examples, then the same three in another order, and record how intent accuracy moves.
  5. Add one read-only tool, get_order(order_id), backed by a Python dict, and run the tool loop so order questions are answered from its result.
  6. Count the tokens in each part of the prompt, and cut the part that earns least.

How you'll know it worksA table of parse rate and intent accuracy on the 50 held-out messages for each setup, with 100% of schema runs parsing, and the share of order questions whose tool call got the right number.

Python, Pydantic, and Ollama with a small tool-calling model such as qwen2.5:3b or llama3.2:3b (runs on a laptop, no API key). Your own API key works too. Uses lessons 01 to 10.