Skills
Get consistent, useful output from language models: prompting patterns, sampling settings and reliability checks.
A path from how language models work to writing prompts you can ship: tokens and context, sampling and output parameters, structured output, prompting techniques like few-shot and chain of thought, automatic prompt optimisation, reliability and red teaming. Resources favour vendor docs and the original research papers.
The subjects follow the roadmap.sh Prompt Engineering roadmap.
Prompt engineering is the craft of getting reliable output from a language model by shaping its input: the instructions, examples, context and format you send. It matters because the same model can be useless or excellent depending on how the task is framed.
A large language model is a transformer trained on huge text corpora to predict the next token. At inference it repeatedly scores every token in its vocabulary, samples one, appends it and repeats. Instruction tuning and RLHF then teach it to follow requests.
Everything the model reads before it answers: a system message, the conversation so far, pasted documents, tool results and your actual request. The model has no other memory, so anything not in the prompt does not exist for it.
An iterative loop: define success criteria, write a prompt, run it on a set of test inputs, inspect failures and revise. Treat prompts like code, with versions, reviews and regression tests, rather than one-off clever phrasing.
A handful of labs ship most frontier models, each with its own API shape, parameter names and prompting quirks. Prompts rarely transfer perfectly between vendors, so re-test whenever you switch model or version.
Maker of the GPT and o-series reasoning models, served through the Responses and Chat Completions APIs. Its docs cover structured outputs, function calling and fine-tuning in detail.
Google DeepMind's Gemini family is available through the Gemini API (AI Studio) and Vertex AI, with very long context windows and native multimodal input; Gemma is its open-weight line.
Builds the Claude models, accessed through the Messages API. Claude responds well to clearly structured prompts, often using XML tags to separate instructions, documents and examples.
Publishes the Llama models with downloadable weights, so you can run them locally or on your own servers, fine-tune them freely and pick a hosting provider. Each Llama version has its own chat template that must be applied exactly.
Develops the Grok models, offered through an API that follows OpenAI-compatible request formats, so existing client libraries work by changing the base URL and key.
A shared vocabulary makes the rest of the field readable: what a token is, why context is limited, why models invent facts, and when to reach for retrieval or fine-tuning instead of a longer prompt.
Short for large language model: a neural network, usually a decoder-only transformer with billions of parameters, that generates text one token at a time. Chat assistants are LLMs wrapped with a conversation format and safety training.
Models read and write sub-word pieces, not characters or words. In English a token averages roughly four characters, but code, numbers and non-Latin scripts use more. Pricing, rate limits and context size are all counted in tokens.
The maximum number of tokens the model can attend to at once, input and output combined. Overflow must be truncated or summarised, and even within the limit, details buried in the middle of very long prompts get less attention.
Fluent, confident output that is false: invented citations, APIs or numbers. Reduce it by supplying source documents, asking for quotes before answers, allowing "I don't know", and verifying anything that matters.
An agent is an LLM in a loop that decides which tools to call, reads the results and keeps going until the task is done. Prompts for agents must describe tools precisely and say when to stop or ask for help.
The billions of learned numbers inside the network, fixed after training. Parameter count hints at capability and cost; these are distinct from the sampling parameters like temperature that you set per request.
Prompting changes the input and costs nothing to iterate; fine-tuning changes the weights with your own examples. Exhaust prompting first, then fine-tune for consistent style, format or a narrow task at lower latency, not to teach new facts.
Retrieval-augmented generation fetches relevant passages from your own data, usually via embedding search, and inserts them into the prompt. It grounds answers in current, citable sources without retraining the model.
Today's systems are narrow tools that can be very capable yet still fail at simple reasoning outside their training. Artificial general intelligence, human-level competence across nearly any task, remains a goal with no agreed definition or test.
After the model scores every possible next token, sampling settings decide which one is picked. Lower randomness suits extraction and code; higher suits brainstorming. Change one knob at a time, and note that some reasoning models ignore or reject these settings.
Divides the logits before softmax: near 0 almost always picks the top token, higher values flatten the distribution. OpenAI accepts 0–2, Anthropic 0–1. Even at 0, outputs are not guaranteed identical across calls.
Restricts sampling to the K most likely tokens, cutting off the long tail of odd choices. Exposed by Anthropic and Gemini as top_k / topK, but not by OpenAI. Usually left at the default unless you are tuning.
Nucleus sampling keeps the smallest set of tokens whose probabilities add up to P, so the candidate pool grows or shrinks with the model's confidence. Vendors generally advise adjusting temperature or top_p, not both.
Request parameters that bound what comes back, independent of the prompt text. They cap cost and latency and give you clean cut-off points, but a hard stop can leave an answer half-written, so check the finish reason.
Caps generated tokens. It does not make the model concise, it just truncates, so ask for brevity in the prompt too. Anthropic requires max_tokens; OpenAI now uses max_completion_tokens, which also covers hidden reasoning tokens.
Strings that end generation as soon as the model emits them, such as a closing </answer> tag or a blank line between records. The stop string itself is not included in the output. Set via stop (OpenAI) or stop_sequences (Anthropic).
Penalties lower the score of tokens that have already appeared, nudging the model away from loops and recycled phrasing. Small values help long creative text; large ones produce odd word choices and can break code or structured output.
Subtracts an amount proportional to how many times a token has already been used, so heavy repetition is punished most. OpenAI's frequency_penalty ranges from -2.0 to 2.0, default 0; modest values around 0.1–0.5 are typical.
A flat penalty for any token that has appeared at least once, regardless of count. It pushes the model toward new words and topics rather than reducing repetition of a single phrase. Not every provider supports it.
When code consumes the answer, ask for JSON, XML or CSV and give the exact schema. Native structured-output modes constrain decoding to a JSON Schema so responses always parse; without them, validate and retry. Leave room for a reasoning field before the answer if quality drops.
Named patterns for framing a task, from giving no examples at all to making the model reason step by step, explore branches or call tools. Most are compositions of a few ideas: show examples, ask for intermediate steps, and sample or check more than once.
Just describe the task and let the model do it, with no examples. Modern instruction-tuned models handle most tasks this way; it is the baseline to try first and the one to beat with anything fancier.
Include one or several input-output examples before the real input. Examples fix format and tone better than descriptions do. Make them varied, wrap them in tags, and watch for the model copying their surface details.
First ask the model a more general question about the principles behind the problem, then feed that answer back in when solving the specific case. It helps on physics, history and multi-hop questions where recalling the right concept is the hard part.
Ask the model to reason through intermediate steps before giving the answer, either with worked examples or simply "think step by step". Put the reasoning in a separate tag so you can strip it. Reasoning models do this internally already.
Sample several chain-of-thought answers at a non-zero temperature and take the majority final answer. It reliably boosts accuracy on math and logic questions, at the cost of multiplying tokens and latency.
Generalises chain of thought into a search: the model proposes several partial solutions, evaluates them, and expands the promising ones with backtracking. Needs orchestration code and many calls, so reserve it for puzzles and planning.
Interleaves reasoning with actions: the model writes a thought, calls a tool such as search, reads the observation and continues. It is the pattern behind most agents, and native tool-calling APIs now implement it directly.
Three layers of framing that sit around the user's request: standing instructions, a persona, and the background facts for this specific task. Keeping them distinct makes prompts easier to maintain and reuse.
The system message holds rules that apply to the whole conversation: purpose, constraints, output format and tone. Models weight it above user turns, which is why it is the main place for product behaviour and guardrails.
Assigning a persona, like "You are a senior tax accountant reviewing a return", shifts vocabulary, depth and what the model pays attention to. Specific roles with an audience work far better than generic "expert" labels.
Give the background the model cannot guess: who the output is for, what it will be used for, relevant documents and what has already been tried. Explaining why a rule exists helps the model apply it sensibly to edge cases.
Instead of hand-tuning wording, let a model or an optimiser search for better prompts against a scored evaluation set. It only works if you have test cases and a metric, which is worth building anyway.
Describe the task and have a strong model draft the prompt, then ask it to critique and rewrite failures from your test runs. Vendor consoles include generators and improvers that produce a solid first draft.
Learns a small set of continuous "soft prompt" embeddings by gradient descent while the model stays frozen. It needs access to the weights, so it applies to open models, and the result is vectors, not readable text.
Production prompts need to be right consistently, not just in a demo. Reliability comes from evaluation sets, reducing bias in examples, combining several outputs, and letting the model check its own work before results reach users.
Few-shot examples skew answers: an unbalanced label mix or a fixed order pushes the model toward the majority or the last label. Balance and shuffle examples, and add explicit instructions to treat groups equally where fairness matters.
Run several differently worded prompts, or different example sets, on the same input and combine the results by voting or a judge model. Errors from any single phrasing tend to cancel out.
Ask the model, or a second call, to grade a draft against explicit criteria and revise it. It catches format slips and obvious mistakes, but models are lenient judges of their own work, so pair it with external checks.
A calibrated model's stated confidence matches how often it is right. Raw outputs are biased toward certain labels; contextual calibration measures the bias on an empty input and corrects for it, and log-probabilities give a better confidence signal than self-reported scores.
Deliberately attacking your own LLM feature to find harmful, leaking or manipulable behaviour before users do. Build a library of adversarial inputs, automate them in CI, and retest after every prompt or model change.
Untrusted text such as a user message, web page or email contains instructions the model obeys instead of yours. There is no complete fix: delimit untrusted content, limit what tools can do, require confirmation for risky actions and never put secrets in prompts.