$ sudo teach IT

Imagine you are giving a task to a designer:

“Make it beautiful.”

What exactly needs to be done? What style? Which colors? Format — image, slide, poster? Without context — too many options. The same goes for LLMs. The clearer and more structured you make your prompt, the better the result.

In this lesson you will learn to:

  • build clear, controlled prompts;
  • use standard patterns that LLMs interpret reliably;
  • and avoid mistakes that lead to “vague” or meaningless answers.

📌 Example: you want the model to write an email. But instead of “Write a letter,” you say: “Write a business email to a client informing them of the successful delivery of order #4532. Use a polite tone, mention the delivery date, add the manager’s signature.” The likelihood of getting the desired result increases manyfold — thanks to the proper prompt structure.

What You’ll Learn in This Article

  • What constitutes a good prompt structure
  • Why it’s important to provide context, not just a command
  • How zero-shot, few-shot, and chain-of-thought prompts work
  • When the self-reflection strategy is helpful
  • Which mistakes are most common and how to avoid them

🧩 Key Terms

  • Context — additional information that helps the model “understand” the situation or role.
  • Instruction — a clear command describing what needs to be done.
  • Examples (few-shot) — samples of input and desired output.
  • Output format — the expected style, structure, or data type.
  • Zero-shot — a prompt without examples.
  • Few-shot — a prompt with 1–3 examples.
  • Chain-of-thought — an approach in which the model generates step-by-step reasoning.
  • Self-reflection — a technique where the model evaluates and refines its own answer.

📐 The Formula for a Good Prompt — Detailed and with Analogies

1. Context — “where we are and who we are”

Analogy: GPS coordinates for a taxi driver If you simply say “Take me home,” the driver will guess which area that is and how to get there. Provide the exact address — and the route is set correctly on the first try.

What context gives the LLM:

  • sets the model’s role (“you are an SMM specialist,” “you are an SQL mentor”);
  • describes the audience and goal (youth brand, HR report for management);
  • narrows the “universe” of facts to reduce hallucinations.

2. Instruction — “what exactly needs to be done”

Analogy: the “mode” button on a microwave By specifying power and time, you tell the appliance how to heat the food. Without this, it will choose a random mode.

A good instruction:

  • starts with an action verb (“write,” “compare,” “analyze”);
  • contains the minimum necessary detail (“in 3 paragraphs,” “use a list”);
  • includes caveats like “if there’s no data — say so.”

3. Examples (Few-shot) — “show and repeat”

Analogy: a sample row in a spreadsheet When an accountant sees a filled-in sample, the risk of formatting errors drops immediately.

Why a couple of examples works wonders:

Situation Without examples With examples
Translating terms May choose the wrong nuance Adapts to the provided glossary
Code generation Uses a “favorite” brace style Clones your style and naming
Article headlines Too creative/dry Keeps the right tone

💡 Tip: examples should be short and typical, otherwise they will “eat up” the context window.

4. Output Format — “how to package the result”

Analogy: a box of the right size The courier will ask: “Wrap the gift in paper or put it in a bag?” If you don’t answer — they will decide themselves.

  • Clearly specify the type (JSON, Markdown table, text paragraph).
  • Constrain the length (up to 300 characters, no more than five points).
  • For machine processing, list keys explicitly (“title,” “description,” “cta”).

🔗 The Entire Chain in Action

Step Example for a post about a summer collection
Context “You are an SMM specialist for a youth streetwear brand.”
Instruction “Write a sales post for Instagram highlighting the lightness and brightness of the new collection.”
Example “Summer is already here — are you ready for the heat? Check out our fresh drop!”
Format “Up to 300 characters, energetic style, 2–3 emojis, one hashtag #FreshDrop.”

What does the model get? A clear “brief”: who is speaking, with what purpose, in what manner, and in what form the result should be.

🛑 Typical Missteps and Quick Fixes

Mistake What it looks like How to fix it
No context “Make a presentation.” Add “for FinTech startup investors, 10 slides.”
Vague instruction “Optimize the code.” Specify: “reduce complexity while avoiding external libraries.”
Missing format Expected JSON, got an essay. Explicitly require: {"title": "...", "body": "..."}.
Examples too long Overflow the context window. Keep 1–2 key lines.

🔄 Prompt Types: how to choose how to interact with the model

Imagine you’re giving tasks to different people. One only needs to hear “do it,” another needs to see an example, and a third needs the logic explained first. It’s the same with language models: they can operate in different modes, and the way you present the request determines the outcome.

In prompt engineering, several types of prompts are commonly distinguished, each solving its own task:

  • Zero-shot — when you simply state the task without examples;
  • Few-shot — when you add 1–2 samples as guidance;
  • Chain-of-thought — when you ask for step-by-step reasoning;
  • Self-reflection — when the model checks and clarifies its own answer.

These approaches don’t compete — they complement each other. Depending on your goal and the task’s complexity, you can choose the most suitable format. Next, we’ll analyze each in more detail.

🔹 Zero-shot: “Do it without examples”

A Zero-shot prompt is the simplest and fastest way to interact with the model. You simply provide an instruction, without examples, templates, or explanations. The model tries to understand what you want and produces a result based on general knowledge obtained during training.

📌 Example: Prompt: “Translate into Spanish: Welcome to our store!” Answer: “¡Bienvenidos a nuestra tienda!”

📚 Analogy: ask a waiter without clarifications

Imagine that you came to a café and said:

“Bring me something tasty.”

If the chef is experienced, they’ll guess and bring a popular dish. But if you add clarifications (“vegetarian,” “no spices,” “for breakfast”), the chances of getting exactly what you want are higher.

So it is with LLMs: zero-shot is like a general request relying on the model’s intuition. It “guesses” your meaning but doesn’t always match expectations.

🧠 How the model processes zero-shot

The model relies on what it has already “read” during training. It doesn’t know exactly how you want the result, but it draws conclusions from a huge corpus of texts, dialogues, articles, and translations.

💡 Zero-shot works best when:

  • the task is unambiguous (for example, translation, summary, entity extraction);
  • the result has a well-known structure (for example, a list, Q&A, product description);
  • speed of interaction is important (for example, a chatbot for short answers).

✅ Examples of zero-shot prompts

Task Prompt Expected result
Translation Translate into English: "Мне нравится учиться" I like studying
Short description Formulate a short product description — coffee maker. Compact 2-cup coffee maker with auto shut-off
Continuation Continue the text: “Once upon a time in a dark forest…” I heard a rustle, and someone stepped out of the shadows

⚠️ Limitations of zero-shot

Despite its simplicity, zero-shot can:

  • lead to ambiguous wording, especially for complex tasks;
  • ignore the format, if you don’t specify it explicitly;
  • fail to maintain style, if the purpose and audience aren’t stated.

📉 Example of an error: Prompt: “Write a business letter” Answer: too informal or excessively long — the model didn’t know who and for what purpose to write.

🔧 How to strengthen zero-shot without moving to few-shot

To get a more precise answer, you can:

  • Add context:

    “You are a marketing assistant. Create a slogan for the spring collection.”

  • Specify the format:

    “Answer as a list of 5 items.”

  • Set constraints:

    “Use no more than 20 words. No emojis.”

Thus, you remain within zero-shot but make the prompt controllable.

🔸 Few-shot: “Here’s an example — follow the template”

Few-shot prompting is a method in which you not only give the task but also show the model 1–3 examples of how the answer should look. This allows you to more precisely control the format, style, and logic of generation.

📌 Example:

Q: What is the capital of France?

A: Paris

Q: What is the capital of Germany?

A:

The model “sees” the structure and outputs: A: Berlin

 

📚 Analogy: learning through a sample

Imagine you’re training an assistant to prepare reports. Instead of explaining the rules in words, you simply give a ready-made template:

“This is how it should be done. Continue in this style.”

Few-shot works the same way: you don’t describe the rules, you show the result that should be matched.

🧠 How the model perceives few-shot

The LLM doesn’t “memorize” examples as a rule. It looks for patterns:

  • word order,
  • writing style,
  • answer format,
  • data presentation form (table, JSON, bullet list).

And then tries to continue in the same style.

🔧 When few-shot is especially useful

Scenario Why it works
Code generation The model understands what syntax and formatting style is needed
Style imitation The model “absorbs” tone, manner, structure
Form filling You can set a strict template — and receive similarly formatted blocks
Working with JSON/XML The model copies the structure and doesn’t forget commas and quotes

✅ Few-shot prompt examples

💬 Translation:

Translate the following sentences into German:

Q: Hello!
A: Hallo!

Q: How are you?
A:

→ A: Wie geht’s dir?

🔠 Dictionary generation:

Q: Define the word "curiosity"
A: A strong desire to know or learn something.

Q: Define the word "resilience"
A:

→ A: The capacity to recover quickly from difficulties; toughness.

🧾 Responses in JSON format:

Input: "I need to book a table for 2 on Friday at 7 PM."
Output:
{
  "action": "book_table",
  "people": 2,
  "day": "Friday",
  "time": "7 PM"
}

Input: "Reserve a spot for 4 people on Saturday at noon."
Output:

→ The model continues the structure in the same format.

⚠️ What can go wrong

  • Examples that are too long → reduce the available context.
  • Mixed styles → the model doesn’t know which one to reproduce.
  • Examples that are too complex without explanations → failures are possible.

💡 Tip: choose short, representative examples and ensure their consistency.

📊 Few-shot versus zero-shot: what’s the difference

Characteristic Zero-shot Few-shot
Simplicity + −
Predictability − +
Flexibility − +
Token usage low higher
Suitable for non-standard tasks not always yes

🧠 Chain-of-thought: “Think step by step”

Sometimes, to get the correct answer from the model, simply asking a question is not enough. You need to ask it to think out loud — break the task into steps, articulate the reasoning, and only then give the result. This approach is called Chain-of-thought (CoT) — “a chain of reasoning.”

📌 Example: Prompt: “Solve step by step: if Petya had 12 apples, gave 3 to Masha, and then divided the remainder among 3 friends, how many did each get?”

Model’s answer with CoT:

Petya had 12 apples.

He gave 3 to Masha → 9 left.

9 / 3 = 3 apples each.

Answer: 3

📚 Analogy: solving a problem in a draft

Remember school math. If you just write “Answer: 3,” the teacher may lower your grade. Why? Because it’s not clear how you reached the conclusion. But if you write out:

12 - 3 = 9
9 / 3 = 3
Answer: 3

—it’s clear that you understand, not guessed.

Chain-of-thought does the same: the model explains to itself before answering.

🧠 How it works

The LLM can “reason,” but by default it strives for brevity. If you don’t ask, it may jump straight to the final answer — and be wrong.

By adding the phrase “Solve step by step”, “Think before you answer”, or “Explain your conclusion”, you activate the model’s internal dialogue. This sharply increases accuracy in complex tasks.

✅ Where CoT is especially useful

  • Logic and deduction:

    “If A is greater than B, and B is greater than C, who is the smallest?”

  • Math and percentages:

    “The store had a 25% discount on an item priced at 800 rubles. How much does it cost with the discount?”

  • Step-by-step text analysis:

    “Read the review and highlight three reasons for customer dissatisfaction.”

  • Instructions with multiple conditions:

    “If the client hasn’t subscribed but left an email, offer a discount. If they have subscribed — send thanks.”

🔁 Comparison: ordinary prompt vs Chain-of-thought

Prompt Result
“What is (8 + 2) × 3?” Answer: 30 (error)
“Solve step by step: (8 + 2) × 3” Reasoning: 8 + 2 = 10 → 10 × 3 = 30 → Answer: 30 ✅

🔍 Even simple calculations become more reliable if the model “thinks.”

🛠 Examples of CoT prompts

Example 1:

“Think step by step: 5 friends share 2 pizzas. If each pizza is cut into 8 slices, how many slices does each get?”

Answer:

2 pizzas × 8 = 16 slices
16 / 5 = 3.2
Each gets 3 slices, and 1 slice remains.
Answer: 3 slices, 1 remaining

Example 2:

“Solve step by step. The text says: ‘Maria arrived at 8:00, and Alexei 15 minutes later.’ What time did Alexei arrive?”

Answer:

Maria arrived at 8:00
Alexei — 15 minutes later → 8:15
Answer: 8:15

💡 Tips for applying CoT

  • Explicitly add phrases:

    “Explain step by step” “Solve step by step and justify” “Reason first, then the conclusion”

  • You can combine with few-shot: first give a couple of examples with step-by-step solutions.

  • It’s appropriate for tasks where an “on-the-fly” mistake can ruin everything — for example, in calculations, logic, and handling conditions.

🔁 Self-reflection: “Evaluate your answer”

Sometimes the model answers quickly and confidently… and incorrectly. But what if you ask it to check itself?

Self-reflection prompting is a technique in which the model first generates a draft answer, and then reviews it, identifies possible errors, and corrects them.

📚 Analogy: a second attempt after a draft

Imagine a student taking a test. First they solve the problem, then they review the solution:

“Wait. I made a mistake in the second step. I’ll rewrite it correctly now.”

The model does the same if you say:

“Answer the question. Then evaluate your answer and correct it if needed.”

🧠 How it works

By default, an LLM generates text linearly: from start to finish without looking back. But if you ask it to:

  • split the process into two stages, and
  • ask itself a clarifying question or perform a check,

the model can revisit its own conclusion — and improve it.

✅ Example of a self-reflection prompt

Prompt:

Question: Which countries are in the EU?

First give a quick answer. Then analyze whether it contains errors. If it does — provide a corrected version.

Model’s answer:

Answer: France, Germany, Norway, Spain.

Check: Norway is not in the EU. The others are.

Corrected answer: France, Germany, Spain.

🔍 When self-reflection is especially useful

Situation Why it works
❗ The answer must be precise The model double-checks itself, reducing the risk of “hallucination”
📋 Long lists Helps catch stray items
🧠 Complex reasoning The model can find a logical error in the chain
📄 Structured data Ensures compliance with format or requirements

🛠 Formulas to trigger self-reflection

You can enable self-check with phrases like:

  • “Evaluate your answer. Find possible errors.”
  • “Check the result and refine if necessary.”
  • “Provide a draft answer, then improve it.”
  • “Imagine you’re reviewing yourself. Do you see any inaccuracies?”

🧾 More usage examples

📦 Example 1: List verification

Prompt:

Name 5 countries where Spanish is an official language. Then assess whether they all truly meet the condition.

Answer:

Spain, Mexico, Brazil, Argentina, Chile.

Reflection: Brazil is Portuguese-speaking, not Spanish-speaking.

Corrected list: Spain, Mexico, Argentina, Chile, Colombia.

💬 Example 2: Wording check

Prompt:

Write a business email to a client informing them of a refund denial. Then evaluate the tone: is it polite? Does it sound harsh?

Answer:

... (email) ...

Reflection: The phrase "You will not get your money back" sounds harsh. Better to rephrase.

Improved version: "Unfortunately, according to the terms, a refund is not possible in this case..."

⚠️ What to keep in mind

  • The model may “overthink,” if the first version is already good — sometimes it invents “errors just in case.”

  • It’s better to explicitly state:

    “Make corrections only in case of an obvious error.”

  • Additional generation consumes tokens — self-reflection is slightly more expensive in output volume.

❌ Typical Mistakes and How to Avoid Them

1. Prompt too short

“Write a text.” The result is abstract or banal.

Solution: add role, goal, style, and constraints.

2. Inconsistency

First we ask for “casual you,” then “business style.”

Solution: specify the communication style explicitly in advance.

3. Expecting a specific form but not specifying it

You expect JSON — you get a paragraph.

Solution: explicitly write:

“Return the answer as JSON with fields: name, age, city.”

4. Prompt without “if unsure — say so”

The model begins to hallucinate.

Solution: add instructions like:

“If there is no information — say so directly.”

5. Formulations that are too general or abstract

“Make it beautiful,” “write brilliantly,” “make it impactful.”

Solution: replace the metaphor with concrete criteria: style, length, audience, format.

❓ Frequently Asked Questions

Q: Do I always need to use examples?

A: No. For simple tasks, zero-shot is sufficient. But few-shot stabilizes results.

Q: What’s more important — style or structure?

A: Structure: even a dry text in the right form is more useful than a “beautiful but wrong” one.

Q: Can I combine approaches?

A: Yes, and it’s even recommended: context + instruction + examples + format is the foundation.

📌 Conclusions

Today you learned:

  • How to build reliable prompts with a clear structure
  • Why it’s important to specify context, instruction, examples, and output format
  • What types of prompts exist and when to apply them
  • Which mistakes are most common — and how to avoid them

This topic is the foundation of all prompt engineering. The better you communicate with the model, the more it can work for you. In the next lesson, we’ll analyze how models interpret tables, lists, JSON, and Markdown — and how to present data so that an LLM understands it.

На следующий урок