Tag: CoT

  • 4 Prompt Engineering Techniques Explained: CoT, ToT, ART, RAG

    4 Prompt Engineering Techniques Explained: CoT, ToT, ART, RAG

    Introduction

    Ask an AI a hard question, and it will almost always give you a confident answer. The problem is that “confident” and “correct” are not the same thing. Over the last few years, researchers have developed specific, well-tested prompt engineering techniques that make AI models slow down, explore alternatives, use real tools, and check real sources before answering — instead of just guessing fluently. Four of the most important ones are Chain-of-Thought (CoT), Tree-of-Thoughts (ToT), Automatic Reasoning and Tool-use (ART), and Retrieval-Augmented Generation (RAG). Here’s what each one actually does — illustrated with a short story, and backed by the real data from the papers that introduced them.

    1. Chain-of-Thought (CoT): Making the AI Show Its Work

    Inspector Reya had a reputation: she never announced a suspect’s name until she’d walked the room out loud, step by step, in front of everyone. A young officer once asked her why. “Just tell us who did it,” he said. “You already know.”

    “I don’t know until I’ve said it,” she replied. She stood at the center of a study where a wealthy merchant had been found dead. “First — the door was locked from the inside. That means whoever did this either had a key, or never left.” She paused. “Second — his tea was still warm, so the killer was here recently.” Another pause. “Third — only three people had keys: the wife, the butler, and the merchant himself. The wound is on the back of his skull — impossible to inflict on oneself. So it’s the wife or the butler.” She continued through the alibi of the butler, seen by two witnesses at the market, and finally the widow’s bruised knuckles, consistent with swinging something heavy. The wife confessed before Reya even finished speaking.

    “You probably suspected her from the start,” the officer said. “Why not just say so?”

    “If I say the name first, I stop looking for what proves me wrong,” Reya said. “Walking it out loud is how I catch the moment my own theory doesn’t hold up — before it’s too late to change my mind.”

    This is Chain-of-Thought prompting. Instead of jumping to a final answer, you ask the model to reason step by step — the way Reya walks the room instead of blurting a guess. You trigger it with something as simple as adding “think step by step” or “explain your reasoning before answering” to your prompt.

    Prompt Engineering CoT

    this prompt engineering Technique has been Introduced by Wei et al. (2022), CoT was later strengthened by Wang et al. (2022) with a second, separate step called self-consistency. Here’s the distinction: CoT gets the model to show one reasoning path. Self-consistency asks it to run that same CoT process multiple times independently — typically 5 to 10 times — and then takes whichever final answer shows up most often, the way you’d trust an answer five colleagues independently reached over one hasty guess. In practice, this means sending the same CoT-style prompt several times (or explicitly asking “solve this three separate times with independent reasoning, then tell me the most common final answer”) and comparing the results yourself, rather than accepting the first attempt.

    Tested on PaLM-540B, layering self-consistency on top of CoT consistently beat plain greedy CoT alone, as the chart below shows:

    On problems with multiple steps, reasoning out loud — and checking that reasoning against itself — measurably reduces wrong answers, sometimes by close to 18 percentage points.

    2. Tree-of-Thoughts (ToT): Exploring Multiple Paths Before Committing

    Old Yusuf had been a locksmith for forty years. His apprentice Farid kept grabbing the first key that looked close enough and jamming it in, again and again, hoping. “You’re guessing in a straight line,” Yusuf told him. He laid out five keys instead, and tested each one’s shape against the lock with just a shallow push. “This one’s too thick — dead end, discard it.” The second seated but felt wrong past the first notch — “promising shape, wrong details, I’ll keep it in mind.” The third he pushed further, past where the others failed, until a ridge caught. “This is the one worth committing to.”

    “You could have just tried all five in order,” Farid said.

    “I did try all five,” Yusuf replied. “But I didn’t waste full effort on ones that failed early. If the third key had also failed, I wouldn’t start over — I’d go back to the second, which I hadn’t fully ruled out yet.”

    This is Tree-of-Thoughts, introduced by Yao et al. (2023). Instead of committing to one line of reasoning, the model generates several possible next steps, evaluates which look promising, abandons the weak ones early, and goes deeper only on survivors — backtracking to an unexplored branch, not restarting from zero, if a path fails. The paper tested this on the “Game of 24” — combining four numbers with arithmetic to reach exactly 24 — where one bad first move dooms the whole attempt, as the results below make clear:

    Prompt Engineering ToT

    Concept Source: Yao et Al.. “Tree of Thought, 2023″(figure 1, Section 3)

    Plain CoT actually did worse than a direct guess here (4.0% vs. 7.3%) — a single bad first step doomed the chain with no way to recover. ToT’s ability to explore, prune, and backtrack turned a 7% success rate into 74%.

    3. ART (Automatic Reasoning and Tool-Use): Knowing When to Stop Guessing

    Dr. Amara had performed over two thousand surgeries. Mid-procedure, she paused entirely to check a digital infusion pump instead of estimating a dosage by feel. “I could recite the formula from memory right now,” she told her resident, Priya. “But ‘roughly’ isn’t good enough here — a small math error in my head could mean a patient stops breathing.” She read the pump’s exact number, adjusted the drip, and continued the surgery without missing a beat.

    “Doesn’t that make you look less confident?” Priya asked.

    “I can do the math,” Amara said. “The point is knowing the difference between reasoning I can trust my own head for, and calculations where a wrong guess, delivered confidently, is more dangerous than pausing to check. The surgeons who hurt patients aren’t the ones who don’t know enough — they’re the ones who trust memory in the exact moment a real tool was sitting right there, unused.”

    This is ART, introduced by Paranjape et al. (2023): the model reasons normally most of the way through a task, but at the exact point where precision matters more than fluent guessing, it pauses, calls a real external tool — a calculator, code execution, a search API — and folds the verified result back into its reasoning. Tested across BigBench and MMLU, the gains (and one honest limitation) look like this:

    Prompt Engineering ART

    (Source: Paranjape et al., 2023, Table 2 summary) That last row matters — ART didn’t win everywhere; hand-tuned GPT-3 setups with highly specific demonstrations still beat it on some tasks. But the core finding held: letting a model reach for a real tool instead of estimating silently closed a measurable gap, especially on arithmetic tasks, where tool use alone added over 21 points on average.

    4. RAG (Retrieval-Augmented Generation): Answering From Real Sources, Not Memory

    Professor Adaeze had studied land disputes for thirty years and could recite most of the record from memory. When a court asked her to testify about a 1952 boundary agreement, she asked for a recess instead of speaking. “I know the shape of this history,” she told the judge. “But ‘roughly’ isn’t testimony. If I’m wrong about even one clause, I could cost a family their land based on my own fuzzy recollection dressed up as certainty.”

    She returned with the actual 1952 document. “Everything I say next is still my analysis, my expertise — but it’s built on top of this, not instead of it.” A clerk later asked why she hadn’t just testified from memory, given how well she knew the material.

    “Because knowing a subject well is dangerous in exactly this way,” Adaeze said. “The better your memory, the more convincing your wrong answer sounds — to others, and to yourself.”

    This is RAG, introduced by Lewis et al. (2020): instead of answering from memorized, potentially outdated general knowledge, the model first retrieves actual relevant documents and builds its answer on top of that real material — the same way Adaeze builds her testimony on the real document, not her confident recollection of it. On open-domain question answering, RAG set new state-of-the-art results, as the chart below shows:

    Prompt Engineering RAG

    (Source: Lewis et al., 2020, Table 1)

    The researchers also found RAG’s answers were rated more factual and specific than a comparable model without retrieval — and the model’s knowledge could be updated just by swapping the document index, no retraining needed. Testing this with a 2016 vs. 2018 Wikipedia index on questions about world leaders, accuracy stayed high when the index matched the question’s timeframe (70% and 68%) but collapsed to single digits when it didn’t — direct proof the model was genuinely using the retrieved documents, not just its trained-in memory.

    What, How, Why, Where: Choosing the Right Technique

    Chain-of-Thought

    This Prompt Engineering Technique is the right default whenever a task has multiple dependent steps where an early mistake would silently corrupt everything after it — math word problems, multi-step logic, step-by-step debugging, or breaking down a complex decision. Use it by asking the model to “think step by step” before answering. For anything genuinely important, layer self-consistency on top: run the same request multiple times independently and go with the most common answer, rather than trusting a single pass. It’s overkill for simple factual lookups — “what year did X happen” doesn’t need a reasoning chain.

    Tree-of-Thoughts

    This Prompt Engineering Technique earns its extra complexity specifically when there’s more than one genuinely plausible approach and the “obvious” first idea might not be the best — strategic decisions, creative writing with multiple directions, puzzle-solving, or planning tasks where a wrong early commitment is costly to unwind. Use it by asking for several candidate approaches, a quick evaluation of each, and permission to abandon weak ones and go deeper only on survivors. It’s unnecessary when there’s really only one reasonable path forward — that’s just CoT with extra steps.

    ART

    This Prompt Engineering Technique belongs in the workflow whenever part of a task needs precision, current information, or computation a model can’t reliably produce from memory — financial calculations, unit conversions, live data lookups, or anything with a number that would be costly to get subtly wrong. This makes it especially valuable in technical problem-solving, data analysis, and software development, where “close enough” isn’t good enough. It’s wasted effort on purely creative or judgment-based tasks with nothing concrete to verify.

    RAG

    This Prompt Engineering Technique is essential whenever an answer depends on specific, current, or proprietary facts that general training knowledge can’t reliably contain — company policies, contracts, product documentation, recent news, research literature, or historical records with exact dates and figures. This makes it the backbone technique for research, technical writing, market research, and any customer-facing tool where a wrong fact has real consequences. It’s unnecessary for stable, well-known general knowledge that doesn’t hinge on a specific source.

    In short: reach for CoT as your everyday reasoning habit, ToT when you’re choosing between real alternatives, ART when precision or live data matters more than fluent guessing, and RAG whenever the truth lives in a specific document rather than general knowledge — and often, the strongest results come from combining more than one in the same task.

    Read my previous articles about AI