You already know how to write a simple prompt and get a response from the model. But what if the task is more complex? What if you need not just to generate text, but to set a structure, mimic a style, or connect external logic? In this lesson, you’ll learn how to use two important techniques: Few-shot prompting and Tool Use.
Imagine you’re learning to write letters — it’s easier when you have examples in front of you. The model also “learns” from examples. And if the letter needs to be generated based on data or after calculations, the model can use external tools (from Python to APIs).
❓ What you’ll learn in this article
- What few-shot prompting is and why examples are needed
- How to use templates and demonstrations in prompts
- What tool use is and how it extends a model’s capabilities
- How to connect external actions: code, APIs, calculator
- How to write agnostic prompts (independent of the model and tool)
📓 Key terms
- Few-shot Prompt — A prompt containing 1–3 examples of correct input/output
- Tool Use — Using external tools (e.g., Python, API, calculator)
- Agnostic Prompt — A prompt independent of a specific model or interface
- Function calling — An API mechanism that allows LLMs to call predefined functions
🔹 Few-shot prompting: learning from examples
In a regular situation, you just phrase the task and hope the model understands what and how it needs to do. But large language models are not magicians. They act based on probability and learned patterns. This means the clearer you show the format, the more accurate the result.
Few-shot prompting is a way to give the model 1–3 good examples before asking it to generate something new. It’s like showing a sample so it’s clear what style and structure to follow.
📌 Practical example
Imagine you want the model to translate phrases from Russian to English.
If you simply write:
Translate: «Мы готовим обед»
The model may get it right — or it may guess the wrong tense, style, or start explaining the translation instead of just giving it.
But if you use few-shot:
User: Translate: "Я иду в школу"
Bot: I am going to school.
User: Translate: "Она читает книгу"
Bot: She is reading a book.
User: Translate: "Мы готовим обед"
Bot:
Now it has context and structure. It sees the format, the tenses used, how the answers are built — and is much more likely to continue in the same way.
📎 Analogy: student learning by example
It’s like giving a student homework. In one case, you just give the task. In another, you provide two solved examples and one new problem to solve.
Without examples:
Solve: 3 × (2 + 5)
With examples:
1. 2 × (1 + 4) = 10
2. 5 × (3 + 2) = 25
3. 3 × (2 + 5) = ?
In the second case, the student will understand the logic faster — and solve it correctly.
🛠 Where it’s especially useful
Few-shot prompting works great:
- for generating uniform structures like emails, notifications, posts;
- for translation — especially between different styles (formal ↔ casual);
- for data analysis — e.g., extracting entities, classification, summaries;
- for code generation — when you need to follow a template (React component, SQL query with explanation);
- for forms, scripts, and cards generation.
💡 Key reminders
Few-shot is not just showing a couple of examples. You need to:
- Make them as close as possible in style to the expected result,
- Choose representative (best) cases,
- Ensure the structure is clear and logically continues.
📎 Analogy: It’s not just giving someone a resume template, but showing them a great resume example that matches their profile. Then they’ll write their own much better.
🔹 Tool Use: think first, then act
Usually, language models answer “from memory” — i.e., based on stored knowledge. But what if you need to calculate, query a database, call an API, or run code? That’s where Tool Use comes in — combining external tools with reasoning.
🧠 What it is
Tool Use is when the model first reasons, then takes action: calls a function, sends an API request, executes Python code, or looks up data. After that, it analyzes the result and gives the final answer.
📎 Analogy: You ask an assistant:
“How much is this in euros?”
He doesn’t just guess a number — he checks the exchange rate online, calculates, and then tells you the result.
📌 Examples
Simple reasoning (just thinking):
Question: How many seconds are in 3 hours?
Model:
- 1 hour = 3600 seconds
- 3 hours = 3 × 3600 = 10,800
Answer: 10,800 seconds
Here the model did the math itself. But if the task is more complex — it’s better to use a tool.
Reasoning + tool:
Reason: Need to calculate
Act: run_python("3 * 3600") → 10800
Answer: 10,800 seconds
Now we have an explanation, a real function call, and a reliable result.
🧪 Where it’s useful
Tool Use is especially helpful:
- when accuracy matters (finance, time, distance),
- when data can change (exchange rates, weather),
- when interacting with the real world: APIs, databases, services,
- when executing code — in Python or SQL.
📎 Analogy: It’s like having an analyst who doesn’t just give an opinion but also runs calculations in Excel, checks data, or queries CRM.
🔧 Under the hood
Depends on the platform:
- In ChatGPT — built-in Tools (Python, Browser, etc.),
- In LangChain — chains of actions with function calls,
- In Prompt Engineering UI — action-hints that trigger calls.
💡 Why it matters
Tool Use combines the flexibility of LLMs with the reliability of tools:
- The model doesn’t hallucinate, it verifies data
- You can track every step: reasoning → action → result
- Errors are easier to find and fix
📎 Analogy: It’s like the model first thinks, then “goes to check,” and only then returns with the answer — explaining everything along the way.
🔹 Agnostic prompts: writing independent of the model
If you create a prompt for one specific model (e.g., ChatGPT), you can address it directly: “You are ChatGPT, answer like an expert.” But in real work, especially if you want to reuse the same template across different systems (Gemini, Claude, Mistral, LLaMA, etc.), it’s important to write agnostically — i.e., independent of a particular implementation.
🧠 What’s an agnostic prompt
An agnostic prompt is a universal request that doesn’t depend on the model’s name, interface, or platform specifics. It focuses on the task, not the environment.
📎 Analogy: Asking someone to cut an apple. Agnostic: “Please slice the apple into wedges.” Non-agnostic: “Take the knife from the third shelf on the left, stand by the sink, turn toward the stove, and start cutting.” The second one is context-bound, the first works anywhere.
📌 How to write agnostically
-
Don’t mention the model
❌ Bad: “You are ChatGPT. Answer as a marketing expert.”
✅ Better: “Give a brief expert marketing tip for a B2C product.”
-
Avoid interface references
❌ Bad: “Click continue and generate the next message.”
✅ Better: “Continue the message in the same style, starting with the phrase…”
-
Set the task directly
❌ Bad: “You are working in Google Sheets, show the formula…”
✅ Better: “Build a formula to calculate average order value per channel.”
🧪 When it matters
Agnostic prompts are especially needed:
- 🛠 In systems where one task is sent to multiple LLMs
- 🧩 When building templates, bots, or UI assistants
- 🔁 When moving workflows across platforms (Notion AI → ChatGPT)
- 📦 In no-code/low-code tools, where models are interchangeable
💡 Why it’s useful
When you write prompts agnostically:
- You’re not tied to one provider
- Your workflows scale more easily
- You reduce technical debt: no need to rewrite for a new model
- The prompt is simpler and clearer: the focus is on the task, not the environment
📎 Analogy: Instead of saying “brew Lipton in this specific mug,” you say “brew black tea” — and it works in a café, at home, or in the office.
❌ Common mistakes
- Too few examples → model doesn’t capture the format
- Examples contradict the instruction
- Model “hallucinates” actions if tool use isn’t defined
- Mixing styles and formats in one prompt
- Referencing UI elements that don’t exist in the target environment
🤔 FAQ
Do I always need to give examples? No. But for complex formats, it greatly improves accuracy.
Can I use tool use without code? Yes, you can simulate: “Imagine you ran…” — the model will still build reasoning.
How do I do tool use in ChatGPT? Enable Code Interpreter or use function calling in the API.
✅ Summary
Today you learned about two powerful techniques:
- Few-shot prompting — helps the model “understand by example”
- Tool Use — gives the model access to calculations, databases, and APIs
They expand standard LLM interactions, making generation more accurate, explainable, and controllable. You can use these techniques in your own prompts, templates, and pipelines — making your solutions far more flexible.