Skip to content
IT glossary
Data and MLUpdated December 3, 2026

Prompt engineering

Промпт-инжиниринг

It’s the practice of writing and testing instructions for an AI model so it performs a task more reliably. The instructions can include examples, rules to follow, and a description of what the answer should look like.

Also known as: промпт

What it is

A prompt is the input you give a model to guide its response. Prompt engineering is the work of designing that input and checking how well it holds up across real cases. In an app, you might write a reusable template for extracting fields from receipts. The instructions stay the same across requests; the receipt text changes. Revising the template changes what the model sees for that request, not what it has learned during training.

Design around the output

Start with the decision your app needs to make or the fields it needs to read. Define terms that could be ambiguous and tell the model what to do when the input is incomplete. Keep the instructions distinct from the source text. If the task is clear from the instructions alone, a zero-shot prompt may be enough. A few-shot prompt adds a handful of input-output examples, which are especially useful for showing what should happen in a borderline case.

Example: extract the total paid

Extract the final amount charged from the receipt below.
Use the final paid total, not the subtotal, tax, or change.
Return a JSON object with one key, amount_paid.
Use a number, or null if no final paid total is stated.

Receipt:
Subtotal: 18.50
Tax: 1.50
Total paid: 20.00
Cash received: 25.00
Change: 5.00

The expected result is {"amount_paid": 20.00}. Now try a receipt that has a subtotal and tax but no final total. The expected value is null: this prompt asks the model to extract a stated total, not calculate one. Testing both cases can reveal whether the model follows the rule or simply returns a plausible amount.

What a prompt can't guarantee

A model can return valid JSON with the wrong amount, or the right amount in a response your app can't parse. Use schema-constrained output when your API supports it, and validate the response in your application. Shape and correctness are separate checks. If a task depends on facts that aren't in the input, retrieval-augmented generation (RAG) can fetch relevant source material and put it in the prompt. That's different from fine-tuning, which updates model weights using training examples.

How it comes up in interviews

You may be asked to fix an unreliable prompt and explain how you'd measure the improvement. For a receipt extractor, build an evaluation set with ordinary receipts, missing totals, and documents that contain several competing amounts. Compare prompt versions on the same examples with the same model and settings. Track extraction accuracy separately from the share of outputs your application can parse, and look at the errors before deciding what to change next.