Prompt engineering is the practice of designing and refining the text input given to a large language model in order to reliably get useful, accurate output. Because LLMs generate responses based on patterns learned from training data, small changes in how a request is phrased - the wording, structure, examples provided, or context included - can significantly change the quality of the result.
An LLM cannot ask clarifying questions unless a system is explicitly designed to let it, so an ambiguous prompt forces the model to guess at intent, often incorrectly. A vague request such as "write about databases" could produce anything from a beginner explanation to an academic paper, while a specific prompt that states the audience, desired length, format, and tone constrains the model toward a much more predictable and useful result.
Most chat-based LLM APIs separate instructions into a system prompt, which sets persistent behavior and context for the whole conversation (for example, "You are a concise technical assistant that always responds in Markdown"), and one or more user prompts, which contain the actual request. Keeping stable instructions in the system prompt and variable content in the user prompt makes an application's behavior easier to reason about and test.
A zero-shot prompt simply asks the model to perform a task with no examples. A few-shot prompt includes a handful of example input-output pairs before the actual request, which helps the model infer the exact format or style expected.
Convert to past tense:
run -> ran
go -> went
eat -> ate
swim ->
Few-shot prompting is particularly effective for tasks with a specific output format that would otherwise be hard to describe precisely in words.
For tasks that involve multiple reasoning steps, such as math word problems or multi-step logic, explicitly asking the model to "think step by step" before giving a final answer - known as chain-of-thought prompting - tends to improve accuracy. This works because the model's own intermediate reasoning tokens become additional context that informs its final answer, rather than forcing it to jump straight to a conclusion.
When a prompt's output needs to be consumed by code rather than read by a human, it helps to explicitly request a specific structure, such as JSON matching a defined schema.
Extract the name and age from the text below and
respond with only valid JSON in the form
{"name": string, "age": number}. Do not include
any other text.
Text: "Maria is 29 years old and works as an engineer."
Many providers also offer a dedicated "structured output" or "JSON mode" API parameter that constrains generation to match a schema, which is generally more reliable than instructions alone.
Prompt engineering can substantially improve results, but it cannot give a model knowledge or capabilities it fundamentally lacks - no amount of clever phrasing will make a model correctly recall a fact it was never trained on. For applications that require up-to-date or proprietary information, prompt engineering is usually combined with other techniques such as retrieval-augmented generation.
By: Tomas Silny
Edited: 2026-08-13 06:49:57