← Back to list

A Practical Guide to Prompt Engineering Techniques and Their Use Cases

A few days ago, I wrote an in-depth piece inspired by Nicola’s post on the topic of Prompt Chaining. The post received a fair amount of…

Fabio Lalli · 2025-05-07 14:35 · 15 claps · 10.9 min read
#ai #prompt-engineering #zero-shot #chain-of-thought #retrieval-augmented-gen
Open on Medium ↗
Wiki topics: RAG · RAG & Retrieval PE · Prompt Engineering AI · AI · General

A Practical Guide to Prompt Engineering Techniques and Their Use Cases

A few days ago, I wrote an in-depth piece inspired by Nicola’s post on the topic of Prompt Chaining. The post received a fair amount of interest and sparked discussions around different prompting approaches and their respective benefits. Among the comments, there was particular interest in exploring various prompting strategies and the contexts in which one is more appropriate than another.

Prompt Engineering — while an often overhyped term in recent narratives — is essentially the “art” of crafting effective instructions to artificial intelligence models (AI) to obtain relevant and valuable outputs. Recently, several advanced techniques have emerged to guide Large Language Models (LLMs) in a more strategic, optimized, and purpose-driven manner.

One of these is Prompt Chaining, which I covered in my article, where the output of one prompt becomes the input of the next. This approach allows complex tasks to be broken down into smaller, manageable steps, improving both the effectiveness and accuracy of the model’s responses. As I noted, prompt chaining is “not just a technique for giving better instructions to AI — it can become a true cognitive architecture,” a way to structure machine reasoning similarly to our own. In other words, it shifts the interaction from a one-off query to a structured, multi-stage conversational strategy.

Prompt Chaining belongs to a broader family of prompt engineering techniques aimed at improving human-AI interaction. In this piece, I dive deeper into key strategies: from zero-shot and few-shot prompting to Chain-of-Thought and the ReAct framework, all the way to more complex methodologies like Self-Consistency, Tree of Thoughts, and RAG (Retrieval-Augmented Generation).

For each, you’ll find an overview of how it works, the most effective use cases, benefits and limitations, and — when useful — practical examples. The goal is to offer a technically grounded yet accessible overview for a wide range of AI users (across various tools), sharing actionable insights and showing how these techniques can foster more informed, effective AI adoption across organizations.

Prompt Chaining

What it is and how it works: Prompt Chaining consists of linking multiple prompts in sequence, with each stage guiding the next. Instead of giving the model a single complex instruction, the task is split into sub-goals: the model generates a partial result, which is then used in the next prompt, and so on. This technique follows the principle of problem decomposition — tackling an “elephant” one bite at a time (to paraphrase the saying). For example, instead of saying “Write a full report on the AI market in 2025,” one could first ask for an outline of key points, then expand each one, and finally request a closing summary. Each prompt focuses on a specific sub-task while maintaining the overall context, and guides the model step by step. This way, the AI internally “plans” the solution, similar to a structured human workflow.

Use cases: Prompt Chaining is effective when the task is complex, lengthy, or involves several logical stages. For content creation (e.g., courses, documentation, white papers), this technique helps ensure coherence and depth without overloading the model with a single monolithic request. In educational or training scenarios, you could use a chained approach to develop a course: first generate module titles, then the details of each, followed by exercises. Strategic analysis or multi-step problem solving also benefits from chaining, as it allows the AI to follow a step-by-step reasoning path. This method is useful whenever you want more control over the reasoning process that the AI uses to produce an answer.

Benefits: By breaking down the task, Prompt Chaining reduces ambiguity and distributes cognitive effort across multiple interactions. The outputs are more accurate and coherent, as the model can focus on one goal at a time. The iterative approach helps maintain context and refine the response progressively. Each intermediate stage also gives the human user the chance to adjust or correct the flow, resulting in greater control over the final output. Another advantage is resource optimization: instead of a potentially unfocused or redundant long output, the AI produces manageable modular content, optimizing context window usage and reducing the risk of incoherence.

Limitations: Prompt Chaining requires planning and skill in designing the sequence of prompts. It is more time-consuming and resource-intensive than using a single prompt — each step is a separate interaction (with associated latency or cost if using a paid API). The user must also ensure that relevant context is properly carried from one prompt to the next (e.g., briefly summarizing key points if the model’s memory is limited). One risk is error propagation: if one step introduces a mistake, it could affect the rest of the chain. Mitigating this requires human oversight or fallback strategies. Like all iterative techniques, chaining can produce verbose outputs if each step isn’t clearly defined — clear goals for each sub-prompt are essential.

Practical example: A straightforward example is generating a long-form article. Instead of asking for the entire article at once:

  • Prompt 1: “List key trends in the AI market for 2025 to cover in an article.” → Output: trend list (e.g., enterprise LLM adoption, AI regulation, open-source models).
  • Prompt 2: “Provide a short paragraph explaining each trend.” → Output: explanations.
  • Prompt 3: “Write a general introduction for the article mentioning the topics discussed.” → Output: cohesive intro.
  • Prompt 4: “Combine everything into a full article with structured flow and a conclusion.” → Output: completed article.

At each step, the user can review and refine the output before proceeding. This ensures a more structured and accurate result than a single one-shot generation.

Zero-Shot Prompting

What it is and how it works: Zero-Shot Prompting refers to a model’s ability to perform a task without being given explicit examples in the prompt. The model receives only an instruction or question and must rely on its internal knowledge (acquired during training) to produce an appropriate response. The term “zero-shot” means that no demonstrations or cases are included. For instance, asking “Translate into English: Oggi piove a dirotto” is a zero-shot request. The model attempts the task based solely on its prior understanding.

Use cases:

  • When the task is simple or common (e.g., translation, general knowledge Q&A, text summarization, sentiment classification).
  • When little to no contextual data or examples are available to include.
  • When quick answers are needed without crafting complex prompts — ideal for rapid prototyping or real-time interactions.

Benefits:

  • Simplicity and efficiency — no need to prepare or insert examples.
  • Broad versatility — one trained model can perform many tasks without further fine-tuning.
  • Avoids unintended bias from specific examples.

Limitations:

  • Typically less accurate or specific than approaches using examples.
  • Strong dependence on prompt phrasing — ambiguity may lead to misinterpretation.
  • Weaker performance on complex or niche tasks that require guided structure.

Practical example: Prompt: “Explain the difference between renewable and non-renewable energy.”

In a zero-shot setup, the model should explain that renewables include solar and wind, while non-renewables include fossil fuels, emphasizing pros and cons — without any reference examples. If the prompt were vague (e.g., “Talk about energy”), the model might respond too generally. Thus, even in zero-shot, specificity improves results: e.g., “Explain concisely, focusing on environmental impact.”

Few-Shot Prompting

What it is and how it works: Few-Shot Prompting involves providing the model with one or more examples of the task within the prompt itself. The prompt includes both the instruction and sample input-output pairs — typically 1 to 5 examples. The model then extrapolates from these patterns to generate a response for a new input.

Use cases:

  • When the task is uncommon or requires a specific format or tone.
  • When historical examples are available (e.g., FAQs or chat transcripts).
  • When response accuracy and stylistic consistency are critical (e.g., customer support bots).

Benefits:

  • Higher precision — model aligns with provided patterns.
  • Greater contextual understanding — especially useful when examples define structure, tone, or reasoning.
  • Avoids full re-training — examples act as “on-the-fly calibration.”

Limitations:

  • Requires high-quality examples.
  • Consumes prompt space — reduces room for new input/output.
  • Poorly chosen examples may mislead the model or limit generalization.

Practical example: Prompt: Review: “This gadget is fantastic! It exceeded my expectations.” Sentiment: Positive. Review: “Unfortunately, it broke after one day. Total waste of money.” Sentiment: Negative. Review: “This product doesn’t work. I’m really disappointed.” Sentiment: ___

Based on the few-shot context, the model should infer the correct answer: “Negative.”

Chain-of-Thought (CoT) Prompting

What it is and how it works: Chain-of-Thought prompting is an advanced technique where the model is encouraged to explicitly reason through a task step-by-step before giving a final answer. Instead of jumping directly to the conclusion, the model is prompted to “think aloud,” outlining a sequence of logical deductions or calculations. This can be done through instructions like “explain your reasoning” or by showing examples with intermediate steps.

Use cases:

  • Multi-step arithmetic or logic problems (e.g., word problems, number puzzles).
  • Tasks involving logical deduction or causal reasoning.
  • Planning scenarios (e.g., creating structured strategies).

Benefits:

  • Encourages better understanding of the problem.
  • Reduces mistakes by tackling sub-steps sequentially.
  • Increases transparency — users can trace where the model made errors.

Limitations:

  • Prompts must be well-structured to elicit valid reasoning.
  • Generates longer responses, consuming more tokens.
  • Errors in reasoning steps can propagate to the final answer.

Practical example: Problem: “A farm has 3 chickens and 2 cows. How many legs are there in total?”

Chain-of-Thought Prompt: “Answer step-by-step. First calculate the number of legs of the chickens, then the cows, then sum them.”

Model output:

  • Chickens: 3 × 2 = 6 legs.
  • Cows: 2 × 4 = 8 legs.
  • Total: 6 + 8 = 14 legs.

ReAct (Reasoning + Acting)

What it is and how it works: ReAct is a paradigm that combines internal reasoning with external actions, such as web search or calculator use. The model alternates between thoughts (reasoning steps) and actions (function/tool calls), based on observations received after each action. Originally proposed by Yao et al. (2022), this approach empowers LLMs to solve complex problems by combining thought and interaction.

Use cases:

  • Answering real-time questions requiring up-to-date info.
  • Tasks requiring external tools (e.g., code execution, math solvers).
  • Multi-step decision-making in dynamic environments.

Benefits:

  • Allows access to external information.
  • Reduces hallucinations.
  • Enhances factual accuracy and problem-solving.

Limitations:

  • Requires tools/infrastructure to support actions.
  • Increased complexity and latency.
  • Risk of logic bugs and execution loops.

Practical example: Question: “How many astronauts are currently on the ISS?”

Model behavior:

  • Thought: “This requires current data. I’ll search online.”
  • Action: Search query → Observation: page says 7 astronauts.
  • Thought: “Now I know the answer.”
  • Final Answer: “There are currently 7 astronauts on board.”

Self-Consistency

What it is and how it works: Self-Consistency is a technique designed to improve the reliability of reasoning-based outputs. Rather than producing a single reasoning chain to answer a prompt, the model is instructed to generate multiple reasoning paths (e.g., via temperature sampling) and then choose the most common final answer among them. This reduces the influence of random errors or misleading chains by leveraging majority consensus.

Use cases:

  • Arithmetic or logical problems where a correct solution is objectively verifiable.
  • Tasks where chain-of-thought reasoning might diverge across runs.
  • Scenarios where model confidence estimation is valuable.

Benefits:

  • Increases accuracy on multi-step reasoning problems.
  • Filters out spurious reasoning paths through consensus.
  • Provides a form of confidence scoring (if all paths agree or diverge).

Limitations:

  • Computationally expensive — requires generating multiple outputs per prompt.
  • Doesn’t apply well to subjective or open-ended questions.
  • Quality depends on diversity and independence of generated reasoning chains.

Practical example: Prompt: “When I was 8, my brother was half my age. I’m 14 now. How old is he?”

  • Chain 1: 8–4 = 4 → 14–4 = 10 → Answer: 10
  • Chain 2: age gap = 4 → 14–4 = 10 → Answer: 10
  • Chain 3: age difference remains 4 → Answer: 10
  • Chain 4: “Half of 8 is 4. Add 6 years = 10.” → Answer: 10
  • Chain 5: Misinterprets → Answer: 7

Majority answer is 10 → Selected as final answer.

Tree of Thoughts (ToT)

What it is and how it works: Tree of Thoughts extends Chain-of-Thought prompting into a tree-based search paradigm. Rather than a linear sequence of thoughts, the model generates multiple possible reasoning branches at each step. These branches are evaluated, explored, or pruned using heuristics or model-based scoring. This structured search allows the model to explore multiple options and backtrack from dead ends.

Use cases:

  • Puzzle solving, planning tasks, or strategy generation.
  • Tasks with branching decision trees.
  • Situations that benefit from exploratory search.

Benefits:

  • Allows backtracking — recovers from poor intermediate steps.
  • Explores a broader solution space.
  • Mimics human-style trial-and-error reasoning.

Limitations:

  • High computational complexity — can grow exponentially.
  • Requires orchestration and control (e.g., through external scripts).
  • May be excessive for simple or linear tasks.

Practical example: In a maze-like game, the model can explore multiple paths:

  • Step 1: “Go left,” “Go right,” “Go forward.”
  • One branch leads to dead end, others lead to success.
  • Model uses heuristics (e.g., “do I see the exit?”) to score paths.

Retrieval-Augmented Generation (RAG)

What it is and how it works: RAG combines generative models with a retrieval component that fetches relevant documents or context before the model produces its response. Instead of relying only on internal knowledge, the model uses retrieved text as grounding to reduce hallucination and improve factuality.

Use cases:

  • Answering questions about recent events or specialized domains.
  • Chatbots requiring up-to-date or organization-specific content.
  • Scenarios where accuracy and source citation are key.

Benefits:

  • Access to external data without retraining the model.
  • Reduces hallucinated facts.
  • Transparent and verifiable responses with cited sources.

Limitations:

  • Requires well-maintained and indexed knowledge base.
  • Risk of irrelevant or conflicting document retrieval.
  • Integration quality depends on retrieval accuracy and prompt design.

Practical example: Prompt: “What is the population of Tokyo?”

  • Step 1: Retrieve data from Wikipedia or official datasets.
  • Step 2: Inject into prompt: “Based on the retrieved info…”
  • Step 3: Generate response: “Tokyo’s metro area population is approximately 37 million.”

Final Reflections

There are prompts for everything, but no single prompt for everything.

The techniques explored in this article — from Prompt Chaining to Zero-Shot and Few-Shot, through Chain-of-Thought, ReAct, Self-Consistency, Tree of Thoughts, and RAG — constitute a comprehensive toolbox for working effectively with modern language models.

Each method has its strengths and best-use scenarios, but they all share one core principle: guiding and structuring the interaction with the AI so that the outputs align with the user’s objectives. In that sense, prompt engineering is as much about formulating the right question in the right way as it is about harnessing the power of the underlying model.

Strategically, prompt engineering is becoming a critical pillar in the responsible and effective adoption of AI.

Without structured methods, a generative model may feel like a black box, producing unpredictable responses — undermining user trust and utility. Techniques like prompt chaining and CoT turn AI into a collaborative reasoning partner — transparent, controllable, and improvable. They enhance output quality and enable progressive refinement.

Prompt engineering thus blends the structured, goal-oriented mindset of human problem-solving with the flexibility and speed of AI.

To fully unlock this synergy, we need to develop two complementary skillsets:

  • Conversational skills, to interact with AI using precise, contextualized, and structured instructions.
  • Design skills, to orchestrate prompt workflows and logic structures similar to how we build software solutions — modular, iterative, and user-centered.

The rise of roles like “Prompt Engineer” reflects this need, but the underlying competencies should ideally be widespread — relevant not just for technical specialists, but also for business leaders, educators, content creators, and more.

Understanding when and how to use AI effectively requires awareness of its limitations (e.g., bias, hallucination, context dependence) as well as its strengths (e.g., speed, scale, generative diversity).

Prompt engineering becomes the interface layer between strategic intention and machine execution. It is the framework through which we can shape machine responses into real, useful, and meaningful outcomes.

As models evolve, so too will prompting practices — potentially aided by meta-AI that suggests optimal prompts or automates chaining — but human insight will remain key.

In short: investing time in prompt experimentation is investing in AI literacy. Just like learning to use spreadsheets or write code became essential in previous technological waves, mastering prompt design will be foundational in the era of generative AI.

The future belongs to those who can collaborate with machines — not blindly, but with clarity, purpose, and strategy.


메타데이터
post_id
5f8574e2cd9a
slug
a-practical-guide-to-prompt-engineering-techniques-and-their-use-cases-5f8574e2cd9a
url
https://medium.com/@fabiolalli/a-practical-guide-to-prompt-engineering-techniques-and-their-use-cases-5f8574e2cd9a
canonical_url
https://medium.com/@fabiolalli/a-practical-guide-to-prompt-engineering-techniques-and-their-use-cases-5f8574e2cd9a
author_url
https://medium.com/@fabiolalli
status
ok
fetched_at
2026-07-25 18:10:40