Sub topic 1
How a Language Model Turns a Prompt into a Response
Prerequisites
Assume you can use a chat-based AI assistant, read short Python examples, and recognize basic JSON. This chapter focuses on the model’s working behavior, not on a specific model API.
How a Language Model Turns a Prompt into a Response
A language model receives text as a sequence of tokens. A token is a word, part of a word, or punctuation. The model uses patterns learned during training to predict the next token, then repeats that process until it reaches a stopping point.
The prompt affects the prediction because it supplies the immediate context. Wording, order, examples, and constraints change which continuations seem likely. The model does not execute an instruction like a traditional program. It generates a response that statistically fits the prompt.
A common error is treating fluent text as proof that the model understands or verified the answer. The model can produce a confident but unsupported claim. Prompts should therefore state the task and its evidence requirements clearly.
The Parts of a Prompt
A useful prompt separates four parts:
| Part | Purpose | Example |
|---|---|---|
| Instruction | Says what to do | Summarize the ticket |
| Context | Provides background | The audience is an engineering manager |
| Input data | Supplies material to process | The ticket text |
| Output specification | Defines the result | Use three bullet points |
Delimiters such as triple quotes help mark input data. They reduce confusion between instructions and text that the model should analyze.
Summarize the support ticket for an engineering manager.
Use at most three bullet points.
Ticket:
"""
{ticket_text}
"""Writing Clear, Specific Instructions
Replace vague requests with a task, audience, constraints, and output format. For example, “Summarize this” leaves important choices open. A stronger version says what information matters and how the answer should look.
When improving a prompt, remove hidden assumptions. State whether the model may infer missing facts, what it should do when information is absent, and which limits matter most.
Exercise
What is the main weakness of the request “Explain this report”?
Show answer
It does not specify the audience, desired focus, length, or output format, so several reasonable responses are possible.