Skip to content

ReAct and Tree Advanced Techniques | Lecture 15

ReAct and Tree Advanced Techniques

An introduction to advanced prompting techniques like ReAct (Reason and Act) and Tree of Thoughts (ToT). Understand the concepts behind these powerful strategies. Lecture 15

The Frontier of Prompting

Welcome to the final part of our course! You are now ready to learn about the concepts behind some of the most advanced and cutting-edge prompting strategies being researched today. We won’t be able to fully implement these without specialized tools, but understanding the ideas will make you a much more sophisticated prompt engineer.

Today we’ll look at two famous techniques: ReAct and Tree of Thoughts (ToT).

ReAct: Combining Reasoning and Acting

The Core Idea: The ReAct framework allows an AI to do more than just generate text. It gives the AI the ability to take actions, like performing a web search, to gather more information before giving a final answer. It combines Reasoning (like in Chain-of-Thought) with Acting (using tools).

This helps overcome the problem of hallucinations. If the AI doesn’t know something, it can look it up!

How it Works (Conceptually)

Imagine you ask:

"Who is the current president of France, and what is the population of France's capital city?"

A ReAct-enabled AI would work like this:

  1. Thought: I need to find two pieces of information. First, the president of France. Second, the population of the capital. I should search for these separately.
  2. Action (Tool Use): Search Google for “current president of France”.
  3. Observation (Result of Action): The search result says Emmanuel Macron is the president.
  4. Thought: Okay, I have the first part. Now I need the population of the capital, which is Paris.
  5. Action (Tool Use): Search Google for “population of Paris”.
  6. Observation (Result of Action): The search result says the population is about 2.1 million people.
  7. Thought: I have both pieces of information now. I can form the final answer.
  8. Final Answer: The current president of France is Emmanuel Macron, and the population of its capital, Paris, is approximately 2.1 million.

This is a much more reliable process than just trying to recall the information from memory, which might be outdated.

ReAct and Tree Advanced Techniques
ReAct and Tree Advanced Techniques

Tree of Thoughts (ToT): Exploring Different Paths

The Core Idea: For very complex problems where there isn’t one single path to the answer, Tree of Thoughts allows the AI to explore multiple different reasoning paths (like branches on a tree), evaluate how promising each path is, and then choose the best one.

This is like a super-powered version of Chain-of-Thought. Instead of just one chain, it creates many and picks the best one.

How it Works (Conceptually)

Imagine you have a complex creative problem, like:

"Write a short story where the main character is a detective, the clue is a single red feather, and the ending must be a complete surprise."

A ToT system would:

  1. Brainstorm initial ideas (the first branches):
    • Path A: The feather belongs to a rare, exotic bird, leading to an illegal smuggling ring.
    • Path B: The feather is a prop from a theater, and the crime is part of an elaborate play.
    • Path C: The feather is a symbol used by a secret society.
  2. Explore each path a bit further: The AI would write a few sentences for each path to see where it leads.
  3. Evaluate the paths: The AI would then judge which path is most likely to lead to a surprising ending. It might decide Path A is too cliché and Path C is too complicated. Path B seems promising.
  4. Continue down the best path: It would then focus on developing the story about the theater, potentially brainstorming more mini-branches along the way until it reaches a satisfying and surprising conclusion.

Key Takeaways from Lecture 15

  • These are advanced, conceptual frameworks that show the future of AI interaction.
  • ReAct combines reasoning (thinking) with acting (using tools like web search) to get up-to-date, factual information.
  • Tree of Thoughts (ToT) explores multiple reasoning paths simultaneously to find the best solution to a complex problem.
  • Understanding these concepts helps you appreciate the power of structured, multi-step prompting, even if you can’t fully implement them yourself yet.

End of Lecture 15. Your theoretical knowledge is now at the cutting edge! Next, we’ll learn how to put it all together by building complex workflows with multi-step prompts.

Avoiding Common Pitfalls | Lecture 14

Najeeb Alam

Najeeb Alam

Technical writer specializes in developer, Blogging and Online Journalism. I have been working in this field for the last 20 years.