Multi-Agentic RAG with Hugging Face Code Agents

-

Using Qwen2.5–7B-Instruct powered code agents to create an area, open source, multi-agentic RAG system

Photo by Jaredd Craig on Unsplash

Large Language Models have shown impressive capabilities and so they are still undergoing regular improvements with each latest generation of models released. Applications similar to chatbots and summarisation can directly exploit the language proficiency of LLMs as they’re only required to provide textual outputs, which is their natural setting. Large Language Models have also shown impressive abilities to grasp and solve complex tasks, but so long as their solution stays “on paper”, i.e. in pure textual form, they need an external user to act on their behalf and report back the outcomes of the proposed actions. Agent systems solve this problem by letting the models act on their environment, normally via a set of tools that may perform specific operations. In this fashion, an LLM can find solutions iteratively by trial and error while interacting with the environment.

An interesting situation is when the tools that an LLM agent has access to are agents themselves: that is the core concept of multi-agentic systems. A multi-agentic system solves tasks by distributing and delegating duties to specialized models and putting their output together like puzzle pieces. A standard approach to implement such systems is through the use of a manager agent to orchestrate and coordinate other agents’ workflow.

Agentic systems, and particularly multi-agentic systems, require a strong LLM as a backbone to perform properly, because the underlying model must have the option to grasp the aim and applicability of the assorted tools in addition to break up the unique problem into sub-problems that will be tackled by each tool. For that reason, proprietary models like ChatGpt or Anthropic’s Claude are generally the default go-to solution for agentic systems. Fortunately, open-source LLMs have continued to see huge improvements in performance a lot in order that a few of them now rival proprietary models in some instances. Much more interestingly, modestly-sized open LLMs can now perform complex tasks that were unthinkable a few years ago.

On this blog post, I’ll show how a “small” LLM that may run on consumer hardware is capable enough to power a multi-agentic system with good results. Specifically, I’ll give a tutorial on how you need to use Qwen2.5–7B-Instruct to create a multi-agentic RAG system. Yow will discover the code implementation in the next GitHub repo and an illustrative Colab notebook.

Before diving into the small print of the system architecture, I’ll recall some basic notions regarding LLM agents that can be useful to raised understand the framework.

ReAct, proposed in ReAct: Synergizing Reasoning and Acting in Language Models, is a well-liked framework for constructing LLM agents. The principal idea of the strategy is to include the effectiveness of Chain of Thought prompting into an agent framework. ReACT consists of interleaved reasoning and motion steps: the Large Language Model is prompted to supply a thought sequence before emitting an motion. In this fashion the model can create dynamic reasoning traces to steer actions and update the high-level plan while incorporating information coming from the interaction with the environment. This enables for an iterative and incremental approach to solving the given task. In practice, the workflow of a ReAct agent is made up of Thought, Motion, and Remark sequences: the model produces reasoning for a general plan and specific tool usage within the Thought step, then invokes the relevant tool within the Motion step, and eventually receives feedback from the environment within the Remark.

Below is an example of what the ReACT framework looks like.

Comparison between the ReACT, Chain-of-Thought, and Act-Only frameworks for a Query Answering task. Image from ReAct: Synergizing Reasoning and Acting in Language Models.

Code agents are a selected sort of LLM agents that use executable Python code to interact with the environment. They’re based on the CodeAct framework proposed within the paper Executable Code Actions Elicit Higher LLM Agents. CodeAct could be very just like the ReAct framework, with the difference that every motion consists of arbitrary executable code that may perform multiple operations. Hand-crafted tools are provided to the agent as regular Python functions that it will probably call within the code.

Code agents include a novel set of benefits over more traditional agents using JSON or other text formats to perform actions:

  • They will leverage existing software packages together with hand-crafted task-specific tools.
  • They will self-debug the generated code through the use of the error messages returned after an error is raised.
  • LLMs are acquainted with writing code because it is mostly widely present of their pre-training data, making it a more natural format to write down their actions.
  • Code naturally allows for the storage of intermediate results and the composition of multiple operations in a single motion, while JSON or other text formats might have multiple actions to perform the identical.

For these reasons, Code Agents can offer improved performance and faster execution speed than agents using JSON or other text formats to execute actions.

Comparison between code agents and agents using JSON or text as actions. Image from Executable Code Actions Elicit Higher LLM Agents.

Below is a concrete example from the unique paper that showcases how code agents can require fewer actions to unravel certain tasks.

Code agents vs agents using JSON/text motion format. Code agents can execute multiple operations in a single motion. Image from Executable Code Actions Elicit Higher LLM Agents. [RIVEDERE]

The Hugging Face transformers library provides useful modules to construct agents and, particularly, code agents. The Hugging Face transformer agents framework focuses on clarity and modularity as core design principles. These are particularly necessary when constructing an agent system: the complexity of the workflow makes it essential to have control over all of the interconnected parts of the architecture. These design selections make Hugging Face agents an important tool for constructing custom and versatile agent systems. When using open-source models to power the agent engine, the Hugging Face agents framework has the further advantage of allowing quick access to the models and utilities present within the Hugging Face ecosystem.

Hugging Face code agents also tackle the problem of insecure code execution. Actually, letting an LLM generate code unrestrained can pose serious risks because it could perform undesired actions. For instance, a hallucination could cause the agent to erase necessary files. To be able to mitigate this risk, Hugging Face code agents implementation uses a ground-up approach to secure code execution: the code interpreter can only execute explicitly authorized operations. That is in contrast to the standard top-down paradigm that starts with a totally functional Python interpreter after which forbids actions which may be dangerous. The Hugging Face implementation includes an inventory of secure, authorized functions that will be executed and provides an inventory of secure modules that will be imported. Anything shouldn’t be executable unless it has been preemptively authorized by the user. You’ll be able to read more about Hugging Face (code) agents of their blog posts:

Retrieval Augmented Generation has turn out to be the de facto standard for information retrieval tasks involving Large Language Models. It may well help keep the LLM information up to this point, give access to specific information, and reduce hallucinations. It may well also enhance human interpretability and supervision by returning the sources the model used to generate its answer. The same old RAG workflow, consisting of a retrieval process based on semantic similarity to a user’s query and a model’s context enhancement with the retrieved information, shouldn’t be adequate to unravel some specific tasks. Some situations that should not fitted to traditional RAG include tasks that need interactions with the knowledge sources, queries needing multiple pieces of data to be answered, and complicated queries requiring non-trivial manipulation to be connected with the actual information contained within the sources.

A concrete difficult example for traditional RAG systems is multi-hop query answering (MHQA). It involves extracting and mixing multiple pieces of data, possibly requiring several iterative reasoning processes over the extracted information and what remains to be missing. As an example, if the model has been asked the query “Does birch plywood float in ethanol?”, even when the sources used for RAG contained information in regards to the density of each materials, the usual RAG framework could fail if these two pieces of data should not directly linked.

A well-liked approach to enhance RAG to avoid the abovementioned shortcomings is to make use of agentic systems. An LLM agent can break down the unique query right into a series of sub-queries after which use semantic search as a tool to retrieve passages for these generated sub-queries, changing and adjusting its plan as more information is collected. It may well autonomously resolve whether it has collected enough information to reply each query or if it should proceed the search. The agentic RAG framework will be further enhanced by extending it to a multi-agentic system wherein each agent has its own defined tasks and duties. This enables, for instance, the separation between the high-level task planning and the interaction with the document sources. In the following section, I’ll describe a practical implementation of such a system.

On this section, I’ll discuss the overall architectural selections I used to implement a Multi-Agentic RAG system based on code agents following the ReAct framework. Yow will discover the remaining details in the total code implementation in the next GitHub repo.

The goal of the multi-agentic system is to reply a matter by searching the mandatory information on Wikipedia. It’s made up of three agents:

  • A manager agent whose job is to interrupt down the duty into sub-tasks and use their output to supply a final answer.
  • A Wikipedia search agent that finds relevant pages on Wikipedia and combines the knowledge extracted from them.
  • A page search agent to retrieve and summarize information relevant to a given query from the provided Wikipedia page.

These three agents are organized in a hierarchical fashion: each agent can use the agent immediately below within the hierarchy as a tool. Specifically, the manager agent can call the Wikipedia search agent to seek out details about a question which, in turn, can use the page search agent to extract particular information from Wikipedia pages.

Below is the diagram of the architecture, specifying which hand-crafted tools (including tools wrapping other agents) each agent can call. Notice that since code agents act using code execution, these should not actually the one tools they’ll use as any native Python operation and performance (so long as it is allowed) will be used as well.

Architecture diagram showing agents and hand-crafted tools. Image by the creator.

Let’s dive into the small print of the workings of the agents involved within the architecture.

Manager agent

That is the top-level agent, it receives the user’s query and it’s tasked to return a solution. It may well use the Wikipedia search agent as a tool by prompting it with a question and receiving the ultimate results of the search. Its purpose is to gather the mandatory pieces of data from Wikipedia by dividing the user query right into a series of sub-queries and putting together the results of the search.

Below is the system prompt used for this agent. It’s built upon the default Hugging Face default prompt template. Notice that the examples provided within the prompt follow the chat template of the model powering the agent, on this case, Qwen2.5–7B-Instruct.

You might be an authority assistant who can find answer on the web using code blobs and tools. To accomplish that, you will have been given access to an inventory of tools: these tools are principally Python functions which you'll be able to call with code.
You can be given the duty of answering a user query and it's best to answer it by retrieving the mandatory information from Wikipedia. Use and trust only the knowledge you retrieved, don't make up false facts.
To show you how to, you will have been given access to a search agent you need to use as a tool. You should use the search agent to seek out information on Wikipedia. Break down the duty into smaller sub-tasks and use the search agent to seek out the mandatory information for every sub-task.
To unravel the duty, you have to plan forward to proceed in a series of steps, in a cycle of 'Thought:', 'Code:', and 'Remark:' sequences.
At each step, within the 'Thought:' sequence, it's best to first explain your reasoning towards solving the duty and the tools that you wish to use.
Then within the 'Code:' sequence, it's best to write the code in easy Python. The code sequence must end with '' sequence.
During each intermediate step, you need to use 'print()' to avoid wasting whatever necessary information you'll then need. These print outputs can be provided back to you by the user within the 'Remark:' field, which can be available as input for the following steps. All the time print the output of tools, don't process it or attempt to extract information before inspecting it.
If an error rise while executing the code, it can be shown within the 'Remark:' field. In that case, fix the code and take a look at again.

Ultimately you will have to return a final answer using the `final_answer` tool.

Listed here are just a few notional examples:
---
<|im_start|>user
Task: When was the capital of Italy founded?<|im_end|>
<|im_start|>assistant
Thought: Let's break up the duty: I first need to seek out the capital of Italy after which take a look at its foundation date. I'll use the tool `wikipedia_search_agent` to get the capital of Italy. Code:
```py
result = wikipedia_search_agent("Italy capital")
print("Capital of Italy:", result)
```<|im_end|>
<|im_start|>user
[OUTPUT OF STEP 0] -> Remark:
Capital of Italy:In response to the knowledge extracted from the Wikipedia page 'Rome', the capital of Italy is Rome.<|im_end|>
<|im_start|>assistant
Thought: Now that I do know that the capital of Italy is Rome, I can use the `wikipedia_search_agent` tool to search for its foundation date.
Code:
```py
result = wikipedia_search_agent("Rome foundation date")
print("Rome foundation:", result)
```<|im_end|>
<|im_start|>user
[OUTPUT OF STEP 1] -> Remark:
Rome foundation: In response to the knowledge from the Wikipedia page 'Natale di Roma', the normal foundation date of Rome is April 21, 753 BC.<|im_end|>
<|im_start|>assistant
Thought: Now that I even have retrieved the relevant information, I can use the `final_answer` tool to return the reply.
Code:
```py
final_answer("In response to the legend Rome was founded on 21 April 753 BCE, but archaeological evidence dates back its development in the course of the Bronze Age.")
```<|im_end|>
---
<|im_start|>user
Task: "What is the difference in population between Shanghai and Latest York?"<|im_end|>
<|im_start|>assistant
Thought: I want to get the populations for each cities and compare them: I'll use the tool `search_agent` to get the population of each cities.
Code:
```py
population_guangzhou_info = wikipedia_search_agent("Latest York City population")
population_shanghai_info = wikipedia_search_agent("Shanghai population")
print("Population Guangzhou:", population_guangzhou)
print("Population Shanghai:", population_shanghai)
```<|im_end|>
<|im_start|>user
[OUTPUT OF STEP 0] -> Remark:
Population Guangzhou: The population of Latest York City is roughly 8,258,035 as of 2023.
Population Shanghai: In response to the knowledge extracted from the Wikipedia page 'Shanghai', the population of town proper is around 24.87 million inhabitants in 2023.<|im_end|>
<|im_start|>assistant
Thought: Now I do know each the population of Shanghai (24.87 million) and of Latest York City (8.25 million), I'll calculate the difference and return the result.
Code:
```py
population_difference = 24.87*1e6 - 8.25*1e6
answer=f"The difference in population between Shanghai and Latest York is {population_difference} inhabitants."
final_answer(answer)
```<|im_end|>
---

On top of performing computations within the Python code snippets that you simply create, you will have access to those tools (and no other tool):

<>

<>

You should use imports in your code, but exclusively from the next list of modules: <>. Don't attempt to import other modules or else you're going to get an error.
Now start and solve the duty!

Wikipedia search agent

This agent reports to the manager agent, it receives a question from it and it’s tasked to return the knowledge it has retrieved from Wikipedia. It may well access two tools:

  • A Wikipedia search tool, using the built-in search function from the wikipedia package. It receives a question as input and returns an inventory of Wikipedia pages and their summaries.
  • A page search agent that retrieves details about a question from a selected Wikipedia page.

This agent collects the knowledge to reply the query, dividing it into further sub-queries, and mixing information from multiple pages if needed. That is completed through the use of the search tool of the wikipedia package to discover potential pages that may contain the mandatory information to reply the query: the agent can either use the reported page summaries or call the page search agent to extract more information from a selected page. After enough data has been collected, it returns a solution to the manager agent.

The system prompt is again a slight modification of the Hugging Face default prompt with some specific examples following the model’s chat template.

You might be an authority assistant that retrieves information from Wikipedia using code blobs and tools. To accomplish that, you will have been given access to an inventory of tools: these tools are principally Python functions which you'll be able to call with code.
You can be given a general query, your task can be of retrieving and summarising information that's relevant to the query from multiple passages retrieved from the given Wikipedia page. Use and trust only the knowledge you retrieved, don't make up false facts. Attempt to summarize the knowledge in just a few sentences.
To unravel the duty, you have to plan forward to proceed in a series of steps, in a cycle of 'Thought:', 'Code:', and 'Remark:' sequences.
At each step, within the 'Thought:' sequence, it's best to first explain your reasoning towards solving the duty and the tools that you wish to use.
Then within the 'Code:' sequence, it's best to write the code in easy Python. The code sequence must end with '' sequence.
During each intermediate step, you need to use 'print()' to avoid wasting whatever necessary information you'll then need. These print outputs can be provided back to you by the user within the 'Remark:' field, which can be available as input for the following steps. All the time print the output of tools, don't process it or attempt to extract information before inspecting it.
If an error rise while executing the code, it can be shown within the 'Remark:' field. In that case, fix the code and take a look at again.

Ultimately you will have to return a final answer using the `final_answer` tool.

Listed here are just a few notional examples:
---
<|im_start|>user
Task: Retrieve information in regards to the query:"What is the capital of France?" from the Wikipedia page "France".<|im_end|>
<|im_start|>assistant
Thought: I want to seek out the capital of France. I'll use the tool `retrieve_passages` to get the capital of France from the Wikipedia page.
Code:
```py
result = retrieve_passages("France capital")
print("Capital of France:", result)
```<|im_end|>
<|im_start|>user
[OUTPUT OF STEP 0] -> Remark:
Retrieved passages for query "France capital":
Passage 0: ... population of nearly 68.4 million as of January 2024. France is a semi-presidential republic with its capital in Paris, the ...
Passage 1: ... France, officially the French Republic, is a rustic positioned primarily in Western Europe. Its overseas regions and territories ...
Passage 2: ... The overwhelming majority of France's territory and population is situated in Western Europe and is named Metropolitan France. It's ...
Passage 3: ... France is a highly urbanised country, with its largest cities (by way of metropolitan area population in 2021) being Paris ...
Passage 4: ... === Government ===nFrance.fr – official French tourism site (in English)...<|im_end|>
<|im_start|>assistant
Thought: Now that I do know that the capital of France is Paris, I can use the `final_answer` tool to return the reply.
Code:
```py
final_answer("The capital of France is Paris.")
```<|im_end|>
---
<|im_start|>user
Task: Retrieve information in regards to the query:"Tallest mountain within the World" from the Wikipedia page "List of highest mountains on Earth"<|im_end|>
<|im_start|>assistant
Thought: I want to seek out the tallest mountain on this planet. I'll use the tool `retrieve_passages` to search for data on the Wikipedia page.
Code:
```py
result = retrieve_passages("highest mountain")
print(result)
```<|im_end|>
<|im_start|>user
[OUTPUT OF STEP 1] -> Remark:
Retrieved passages for query "highest mountain":
Passage 0: ... above sea level) is the world's tallest mountain and volcano, rising about 10,203 m (33,474 ft) from the Pacific Ocean floor. ...
Passage 1: ... As of December 2018, the very best peaks on 4 of the mountains—Gangkhar Puensum, Labuche Kang III, Karjiang, and Tongshanjiabu, all positioned in Bhutan or China—haven't been ascended. ...
Passage 2: ... The very best mountains above sea level are generally not the very best above the encompassing terrain. ...
Passage 3: ... The very best mountain outside of Asia is Aconcagua (6,961 m or 22,838 ft), the 189th highest on this planet. ...
Passage 4: ... the southern summit of Peru's tallest mountain, Huascarán, is one other contender. Each have elevations above sea level greater than 2 km (1.2 mi) lower than that of Everest....
<|im_end|>
<|im_start|>assistant
Thought: The outcomes don't clearly specify a transparent result for the world's tallest mountain, I'll use the tool `web_results` with a distinct query.
Code:
```py
result = retrieve_passages("world's tallest mountain")
print(result)
```<|im_end|>
<|im_start|>user
Passages retrieved from page List of highest mountains on Earth:
Passage 0: ... The very best mountain outside of Asia is Aconcagua (6,961 m or 22,838 ft), the 189th highest on this planet....
Passage 1: ... above sea level) is the world's tallest mountain and volcano, rising about 10,203 m (33,474 ft) from the Pacific Ocean floor. ...
Passage 2: ... The bases of mountain islands are below sea level, and given this consideration Mauna Kea (4,207 m (13,802 ft) above sea level) is the world's tallest mountain and volcano, rising about 10,203 m (33,474 ft) from the Pacific Ocean floor. ...
Passage 3: ... the southern summit of Peru's tallest mountain, Huascarán, is one other contender. Each have elevations above sea level greater than 2 km (1.2 mi) lower than that of Everest. ...
Passage 4: ... The very best mountains are also not generally essentially the most voluminous. Mauna Loa (4,169 m or 13,678 ft) is the biggest mountain on Earth by way of base area (about 5,200 km2 or 2,000 sq mi) and volume (about 42,000 km3 or 10,000 cu mi)...<|im_end|>
<|im_start|>assistant
Thought: I even have found that Mauna Kea is the world's tallest mountain rising about 10,203 m (33,474 ft) from the Pacific Ocean floor. I can use the `final_answer` tool to return the relevant information.
Code:
```py
final_answer("Mauna Kea is the world's tallest mountain, rising about 10,203 m (33,474 ft) from the Pacific Ocean floor.")
```<|im_end|>
___
On top of performing computations within the Python code snippets that you simply create, you will have access to those tools (and no other tool):

<>

<>

You should use imports in your code, but only from the next list of modules: <>. Don't attempt to import other modules or else you're going to get an error.
Now start and solve the duty!

Page search agent

This agent reports to the Wikipedia search agent, which provides it with a question and the title of a Wikipedia page, and it’s tasked to retrieve the relevant information to reply the query from that page. That is, in essence, a single-agent RAG system. To perform the duty, this agent generates custom queries and uses the semantic search tool to retrieve the passages which are more just like them. The semantic search tool follows a straightforward implementation that splits the page contents into chunks and embeds them using the FAISS vector database provided by LangChain.

Below is the system prompt, still built upon the one provided by default by Hugging Face

You might be an authority assistant that finds answers to questions by consulting Wikipedia, using code blobs and tools. To accomplish that, you will have been given access to an inventory of tools: these tools are principally Python functions which you'll be able to call with code.
You can be given a general query, your task can be of finding a solution to the query using the knowledge you retrieve from Wikipedia. Use and trust only the knowledge you retrieved, don't make up false facts. Cite the page where you found the knowledge.
You'll be able to seek for pages and their summaries from Wikipedia using the `search_wikipedia` tool and search for specific passages from a page using the `search_info` tool. You need to resolve use these tools to seek out an appropriate answer:some queries will be answered by one page summary, others can require specific passages from multiple pages.
To unravel the duty, you have to plan forward to proceed in a series of steps, in a cycle of 'Thought:', 'Code:', and 'Remark:' sequences.
At each step, within the 'Thought:' sequence, it's best to first explain your reasoning towards solving the duty and the tools that you wish to use.
Then within the 'Code:' sequence, it's best to write the code in easy Python. The code sequence must end with '' sequence.
During each intermediate step, you need to use 'print()' to avoid wasting whatever necessary information you'll then need. These print outputs can be provided back to you by the user within the 'Remark:' field, which can be available as input for the following steps. All the time print the output of tools, don't process it or attempt to extract information before inspecting it.
If an error rise while executing the code, it can be shown within the 'Remark:' field. In that case, fix the code and take a look at again.

Ultimately you will have to return a final answer using the `final_answer` tool.

Listed here are just a few notional examples:
---
<|im_start|>user
Task: When was the traditional philosopher Seneca born?<|im_end|>
<|im_start|>assistant
Thought: I'll use the tool `search_wikipedia` to look for Seneca's birth on Wikipedia. I'll specify I'm searching for the philosopher for disambiguation.
Code:
```py
result = search_wikipedia("Seneca philosopher birth")
print("result)
```<|im_end|>
<|im_start|>user
[OUTPUT OF STEP 0] -> Remark:
Pages found for query 'Seneca philosopher birth':
Page: Seneca the Younger
Summary: Lucius Annaeus Seneca the Younger ( SEN-ik-ə; c.4 BC – AD 65), normally known mononymously as Seneca, was a Stoic philosopher of Ancient Rome, a statesman, dramatist, and in a single work, satirist, from the post-Augustan age of Latin literature.
Seneca was born in Colonia Patricia Corduba in Hispania, a
Page: Phaedra (Seneca)
Summary: Phaedra is a Roman tragedy written by philosopher and dramatist Lucius Annaeus Seneca before 54 A.D. Its 1,280 lines of verse tell the story of Phaedra, wife of King Theseus of Athens and her consuming lust for her stepson Hippolytus. Based on Greek mythology and the tragedy Hippolytus by Euripides,
Page: Seneca the Elder
Summary: Lucius Annaeus Seneca the Elder ( SEN-ik-ə; c.54 BC – c. AD 39), also referred to as Seneca the Rhetorician, was a Roman author, born of a wealthy equestrian family of Corduba, Hispania. He wrote a group of reminiscences in regards to the Roman schools of rhetoric, six books of that are extant in a more or
Page: AD 1
Summary: AD 1 (I) or 1 CE was a typical 12 months starting on Saturday or Sunday, a typical 12 months starting on Saturday by the proleptic Julian calendar, and a typical 12 months starting on Monday by the proleptic Gregorian calendar. It's the epoch 12 months for the Anno Domini (AD) Christian calendar era, and the first 12 months of
Page: Seneca Falls Convention
Summary: The Seneca Falls Convention was the primary women's rights convention. It advertised itself as "a convention to debate the social, civil, and non secular condition and rights of woman". Held within the Wesleyan Chapel of the town of Seneca Falls, Latest York, it spanned two days over July 19–20, 1848. Attrac
<|im_start|>assistant
Thought: From the summary of the page "", I can see that Seneca was born in . I can use the `final_answer` tool to return the reply.
Code:
```py
final_answer("In response to the Wikipedia page 'Seneca the Younger', Seneca was born in 4 BC.")
```<|im_end|>
---
<|im_start|>user
Task: Who was Charlemagne predecessor?<|im_end|>
<|im_start|>assistant
Thought: I'll use the tool `search_wikipedia` to look for Charlemagne reign duration.
Code:
```py
result = search_wikipedia("Charlemagne predecessor")
print(result)
```<|im_end|>
<|im_start|>user
[OUTPUT OF STEP 0] -> Remark:
Pages found for query 'Charlemagne predecessor':
Page: Charlemagne
Summary: Charlemagne ( SHAR-lə-mayn; 2 April 748 – 28 January 814) was King of the Franks from 768, King of the Lombards from 774, and Emperor of what's now referred to as the Carolingian Empire from 800, holding these titles until his death in 814. He united most of Western and Central Europe, and was the primary
Page: Pope Leo III
Summary: Pope Leo III (Latin: Leo III; died 12 June 816) was bishop of Rome and ruler of the Papal States from 26 December 795 to his death. Protected by Charlemagne from the supporters of his predecessor, Adrian I, Leo subsequently strengthened Charlemagne's position by crowning him emperor. The coronation
Page: Throne of Charlemagne
Summary: The Throne of Charlemagne (German: Karlsthron or Aachener Königsthron, "Royal Throne of Aachen") is a throne erected within the 790s by Charlemagne, as certainly one of the fittings of his palatine chapel in Aachen (today's Aachen Cathedral) and placed within the Octagon of the church. Until 1531, it served because the co
Page: Louis the Pious
Summary: Louis the Pious (Latin: Hludowicus Pius; French: Louis le Pieux; German: Ludwig der Fromme; 16 April 778 – 20 June 840), also called the Fair and the Debonaire, was King of the Franks and co-emperor along with his father, Charlemagne, from 813. He was also King of Aquitaine from 781. Because the only surviving
Page: Holy Roman Emperor
Summary: The Holy Roman Emperor, originally and officially the Emperor of the Romans (Latin: Imperator Romanorum; German: Kaiser der Römer) in the course of the Middle Ages, and in addition referred to as the Romano-German Emperor because the early modern period (Latin: Imperator Germanorum; German: Römisch-deutscher Kaiser, lit. 'R
<|im_end|>
<|im_start|>assistant
Thought: The outcomes don't contain explicit details about Charlemagne predecessor, I'll seek for more information on the page 'Charlemagne' using the 'search_info' tool.
Code:
```py
result = search_info("Charlemagne predecessor", "Charlemagne")
print(result)
```<|im_end|>
<|im_start|>user
[OUTPUT OF STEP 1] -> Remark:
Information retrieved from the page 'Charlemagne' for the query 'Charlemagne predecessor':
Charlemagne's predecessor was Pepin the Short.
<|im_end|>
<|im_start|>assistant
Thought: I even have found that, in accordance with the Wikipedia page 'Charlemagne', Pepin the Short was Charlemagne predecessor. I'll return the outcomes using the `final_answer` tool.
Code:
```py
final_answer("In response to the knowledge extracted from the Wikipedia page 'Charlemagne', his predecessor was Pepin the Short.")
```<|im_end|>
___
On top of performing computations within the Python code snippets that you simply create, you will have access to those tools (and no other tool):

<>

<>

You should use imports in your code, but only from the next list of modules: <>. Don't attempt to import other modules or else you're going to get an error.
Now start and solve the duty!

Implementation selections

On this subsection, I’ll outline the principal points that differ from what could possibly be a simple implementation of the architecture using Hugging Face agents. These are the outcomes of limited trial and error before obtaining an answer that works reasonably well. I haven’t performed extensive testing and ablations so that they might not be the optimal selections.

  • Prompting: as explained within the previous sections, each agent has its own specialized system prompt that differs from the default one provided by Hugging Face Code Agents. I observed that, perhaps as a consequence of the limited size of the model used, the overall standard system prompt was not giving good results. The model seems to work best with a system prompt that reflects closely the tasks it’s asked to perform, including tailored examples of serious use cases. Since I used a chat model with the aim of improving instruction following behavior, the provided examples follow the model’s chat template to be as close as possible to the format encountered during a run.
  • Summarizing history: long execution histories have detrimental effects on each execution speed and task performance. The latter could possibly be as a consequence of the limited ability of the model to retrieve the mandatory information from an extended context. Furthermore, extremely long execution histories could exceed the utmost context length for the engine model. To mitigate these problems and speed up execution, I selected not to point out all the small print of the previous thought-action-observation steps, but as a substitute collected only the previous observations. More specifically, at each step the model only receives the next chat history: the system message, the primary message containing the duty, its last motion, and all of the history of the previous observations. Moreover, execution errors are present within the statement history only in the event that they occur within the last step, previous errors which have been already solved are discarded.
  • Tools vs managed agents: Hugging Face agents implementation has native support for managed agents but wrapping them as tools allows for higher control of the prompts and a more streamlined implementation. Specifically, Hugging Face implementation adds particular prompts to each the managed agents and their managers. While I haven’t seen substantial differences in the flexibility to unravel the given task, I preferred the second approach because it is more flexible and streamlined for the presented architecture, and it allows for easier control over the agents’ behavior. This also helps with reducing the prompt length, which is helpful for speeding up computations.
  • Limit the utmost variety of trials for the page search agent: sometimes the page search agent keeps searching for information on a given page that doesn’t contain it. Reducing the utmost variety of trials mitigated this issue: after reaching that number the agent execution is stopped and the tool returns the last statement from code execution.
  • Changing tool response to user message: that is more of a technical, implementation-specific point. For the reason that only supported roles for the chat template of Qwen2.5–7B-Instruct are system, user, and assistant, observations are returned as user messages.

On this section, I’ll collect some examples produced with the described architecture. I will even provide the detailed execution of all of the agents involved within the task to showcase how they interact in some real cases. You’ll be able to explore more examples using the illustrative Colab notebook. All of the extracted passages are taken from the Wikipedia page laid out in the execution.

Let’s start exploring a straightforward example that requires combining information from multiple sources and a few basic arithmetic understanding.

Task: What number of years passed between the development of the Eiffel Tower and the development of the Empire State Constructing?

Below are the logs of the execution of the manager agent. It may well appropriately break up the duty into finding the development periods for each buildings and compute the 12 months difference.

Agent:  Thought: First, I want to seek out out when the Eiffel Tower and the Empire State Constructing were constructed. I'll use the `wikipedia_search_agent` tool to seek out this information.
Code:
```py
wikipedia_search_agent(query="Eiffel Tower construction 12 months")
```
Remark: Print outputs:
Last output from code snippet:
In response to the knowledge extracted from the Wikipedia page 'Eiffel Tower', the development of the Eiffel Tower took place from 1887 to 1889.
Agent: Thought: Now I even have the development period of the Eiffel Tower. Next, I want to seek out the development period of the Empire State Constructing. I'll use the `wikipedia_search_agent` tool again.
Code:
```py
wikipedia_search_agent(query="Empire State Constructing construction 12 months")
```
Remark: Print outputs:
Last output from code snippet:
In response to the knowledge extracted from the Wikipedia page 'Empire State Constructing', the development of the Empire State Constructing began in 1930 and resulted in 1931.
Agent: Thought: Now I even have the development periods for each the Eiffel Tower and the Empire State Constructing. I can now calculate the variety of years between their constructions.
Code:
```py
construction_eiffel_tower_start = 1887
construction_eiffel_tower_end = 1889
construction_empire_state_building_start = 1930
construction_empire_state_building_end = 1931

years_passed = construction_empire_state_building_start - construction_eiffel_tower_end
answer = f"The variety of years passed between the development of the Eiffel Tower and the Empire State Constructing is {years_passed} years."
final_answer(answer)
```
Remark: Print outputs:
Last output from code snippet:
The variety of years passed between the development of the Eiffel Tower and the Empire State Constructing is 41 years.

Let’s now visualize the execution of the Wikipedia search agent. It appropriately searches and reports the development periods present in the summary of the pages, while not having to examine the person pages. It’s interesting to notice that despite being asked generically in regards to the “construction 12 months”, it reports your entire construction period because it shouldn’t be clear if the 12 months refers back to the start or the top of the development works.

TASK:  Eiffel Tower construction 12 months
AGENT: Thought: I'll use the `search_wikipedia` tool to seek out information in regards to the Eiffel Tower construction 12 months.
Code:
```py
search_wikipedia('Eiffel Tower construction 12 months')
```
OBSERVATIONS: Print outputs:
Last output from code snippet:
Pages found for query 'Eiffel Tower construction 12 months':
Page: Eiffel Tower
Summary: The Eiffel Tower ( EYE-fəl; French: Tour Eiffel [tuʁ ɛfɛl] ) is a wrought-iron lattice tower on the Champ de Mars in Paris, France. It is known as after the engineer Gustave Eiffel, whose company designed and built the tower from 1887 to 1889.
Locally nicknamed "La dame de fer" (French for "Iron Lady"), it was constructed because the centerpiece of the 1889 World's Fair, and to crown the centennial anniversary of the French Revolution. Although initially criticised by a few of France's leading artists and intellectuals for its design, it has since turn out to be a worldwide cultural icon of France and some of the recognisable structures on this planet. The tower received 5,889,000 visitors in 2022. The Eiffel Tower is essentially the most visited monument with an entrance fee on this planet: 6.91 million people ascended it in 2015. It was designated a monument historique in 1964, and was named a part of a UNESCO World Heritage Site ("Paris, Banks of the Seine") in 1991.
The tower is 330 metres (1,083 ft) tall, about t
Page: Eiffel Tower (Paris, Texas)
Summary: Texas's Eiffel Tower is a landmark in town of Paris, Texas. The tower was constructed in 1993. It's a scale model of the Eiffel Tower in Paris, France; at 65 feet in height, it's roughly one-sixteenth of the peak of the unique.

Page: Gustave Eiffel
Summary: Alexandre Gustave Eiffel ( EYE-fəl, French: [alɛksɑ̃dʁ ɡystav ɛfɛl]; né Bonickhausen dit Eiffel; 15 December 1832 – 27 December 1923) was a French civil engineer. A graduate of École Centrale des Arts et Manufactures, he made his name with various bridges for the French railway network, most famously the Garabit Viaduct. He's best known for the world-famous Eiffel Tower, designed by his company and built for the 1889 Universal Exposition in Paris, and his contribution to constructing the Statue of Liberty in Latest York. After his retirement from engineering, Eiffel focused on research into meteorology and aerodynamics, making significant contributions in each fields.
Page: Watkin's Tower
Summary: Watkin's Tower was a partially accomplished iron lattice tower in Wembley Park, London, England. Its construction was an ambitious project to create a 358-metre (1,175 ft)-high visitor attraction in Wembley Park to the north of town, led by the railway entrepreneur Sir Edward Watkin. Marketed because the "Great Tower of London", it was designed to surpass the peak of the Eiffel Tower in Paris, and it was a part of Wembley Park's emergence as a recreational place. The tower was never accomplished and it was demolished in 1907. The positioning of the tower is now occupied by the English national football ground, Wembley Stadium.
Page: Eiffel Tower (Paris, Tennessee)
Summary: The Eiffel Tower is a landmark in town of Paris, Tennessee. It's a 1:20 scale replica of the unique positioned in Paris, France.

AGENT: Thought: From the summary of the page 'Eiffel Tower', I can see that the development of the Eiffel Tower took place from 1887 to 1889. I'll use the `final_answer` tool to return the reply.
Code:
```py
final_answer("In response to the knowledge extracted from the Wikipedia page 'Eiffel Tower', the development of the Eiffel Tower took place from 1887 to 1889.")
```
OBSERVATIONS: Print outputs:
Last output from code snippet:
In response to the knowledge extracted from the Wikipedia page 'Eiffel Tower', the development of the Eiffel Tower took place from 1887 to 1889.
------------------------------
TASK: Empire State Constructing construction 12 months
AGENT: Thought: I'll use the `search_wikipedia` tool to seek out information in regards to the construction 12 months of the Empire State Constructing.
Code:
```py
search_wikipedia('Empire State Constructing construction 12 months')
```
OBSERVATIONS: Print outputs:
Last output from code snippet:
Pages found for query 'Empire State Constructing construction 12 months':
Page: Empire State Constructing
Summary: The Empire State Constructing is a 102-story Art Deco skyscraper within the Midtown South neighborhood of Manhattan in Latest York City. The constructing was designed by Shreve, Lamb & Harmon and built from 1930 to 1931. Its name is derived from "Empire State", the nickname of the state of Latest York. The constructing has a roof height of 1,250 feet (380 m) and stands a complete of 1,454 feet (443.2 m) tall, including its antenna. The Empire State Constructing was the world's tallest constructing until the primary tower of the World Trade Center was topped out in 1970; following the September 11 attacks in 2001, the Empire State Constructing was Latest York City's tallest constructing until it was surpassed in 2012 by One World Trade Center. As of 2024, the constructing is the seventh-tallest constructing in Latest York City, the ninth-tallest accomplished skyscraper in the US, and the 57th-tallest accomplished skyscraper on this planet.
The positioning of the Empire State Constructing, on the west side of Fifth Avenue between West thirty third and thirty fourth St
Page: British Empire Constructing
Summary: The British Empire Constructing, also known by its address 620 Fifth Avenue, is a business constructing at Rockefeller Center within the Midtown Manhattan neighborhood of Latest York City. Accomplished in 1933, the six-story structure was designed within the Art Deco style by Raymond Hood, Rockefeller Center's lead architect. The British Empire Constructing, together with the nearly an identical La Maison Francaise to the south and the high-rise International Constructing to the north, comprise a gaggle of retail-and-office structures referred to as the International Complex. La Maison Francaise and the British Empire Constructing are separated by Channel Gardens, a planted pedestrian esplanade running west to the complex's Lower Plaza.
The facade is product of limestone, with a principal entrance along Fifth Avenue and secondary entrances on fiftieth Street and Channel Gardens. The highest of the British Empire Constructing comprises setbacks, a rooftop garden, and a partial seventh-story penthouse. The constructing's entrances contain ornate decoration
Page: 2012 Empire State Constructing shooting
Summary: On August 24, 2012, a gunman shot and killed a former co-worker outside the Empire State Constructing in Latest York City. Following the initial shooting, the gunman, 58-year-old Jeffrey T. Johnson, was fatally shot by law enforcement officials after raising his weapon at them. Nine bystanders were wounded by stray bullets fired by the officers and ricocheting debris, but none suffered life-threatening injuries.
Page: Empire State Constructing in popular culture
Summary: The Empire State Constructing is a 102-story skyscraper on Fifth Avenue between West thirty third and thirty fourth Streets in Midtown, Manhattan, Latest York City. It has a roof height of 1,250 feet (381 m), and with its antenna included, it stands a complete of 1,454 feet (443.2 m) tall. The Empire State Constructing stood because the world's tallest constructing for nearly 40 years, from its completion in early 1931 until the topping out of the unique World Trade Center's North Tower in late 1970. It has been featured in quite a few movies, TV shows, songs, video games, books, photographs, and artwork.
Page: Empire State Plaza
Summary: The Governor Nelson A. Rockefeller Empire State Plaza (known commonly because the Empire State Plaza, and in addition because the South Mall) is a posh of several state government buildings in downtown Albany, Latest York.
The complex was built between 1965 and 1976 at an estimated total cost of $2 billion. It houses several departments of the Latest York State administration and is integrated with the Latest York State Capitol, accomplished in 1899, which houses the state legislature. Among the many offices on the plaza are the Department of Health and the Biggs Laboratory of the Wadsworth Center. The Empire State Art Collection, a serious public collection of Nineteen Sixties and Seventies monumental abstract artworks, is on everlasting display throughout the location. The Latest York State Office of General Services maintains the plaza. The Nelson A. Rockefeller Empire State Plaza Performing Arts Center Corporation is a Latest York state public-benefit corporation that was created in 1979 to administer the performing arts facility within the plaza.

AGENT: Thought: From the summary of the page "Empire State Constructing", I can see that the constructing was designed and built from 1930 to 1931. I'll use the `final_answer` tool to return the reply.
Code:
```py
final_answer("In response to the knowledge extracted from the Wikipedia page 'Empire State Constructing', the development of the Empire State Constructing began in 1930 and resulted in 1931.")
```
OBSERVATIONS: Print outputs:
Last output from code snippet:
In response to the knowledge extracted from the Wikipedia page 'Empire State Constructing', the development of the Empire State Constructing began in 1930 and resulted in 1931.

The passage retrieval agent was not used as all the knowledge was already present in the summaries of the pages.

Let’s now try a more complicated example asking if birch plywood floats in alcohol. This query requires basic physics understanding and arithmetic abilities, combined with non-trivial retrieval tasks.

Task: Does birch plywood float in ethanol?

Let’s first visualize the logs of the assorted agents.

Manager agent logs

AGENT:  Thought: To find out if birch plywood floats in ethanol, we want to know the density of each birch plywood and ethanol. If the density of birch plywood is lower than the density of ethanol, it can float. I'll use the `wikipedia_search_agent` tool to seek out the densities of birch plywood and ethanol.
Code:
```py
birch_plywood_density_info = wikipedia_search_agent("density of birch plywood")
ethanol_density_info = wikipedia_search_agent("density of ethanol")
print(birch_plywood_density_info)
print(ethanol_density_info)
```
OBSERVATION: Print outputs:
The density of birch plywood is roughly 680 kg/m³.
The density of ethanol at 20°C is roughly 0.7894 g/cm³.

AGENT: Thought: Now that I even have the densities, I can compare them. Birch plywood has a density of 680 kg/m³ and ethanol has a density of 0.7894 g/cm³. Since 1 g/cm³ is the same as 1000 kg/m³, the density of ethanol is 789.4 kg/m³. For the reason that density of birch plywood (680 kg/m³) is lower than the density of ethanol (789.4 kg/m³), birch plywood will float in ethanol. I'll now provide this conclusion using the `final_answer` function.
Code:
```py
final_answer("Birch plywood will float in ethanol because its density (680 kg/m³) is lower than the density of ethanol (789.4 kg/m³).")
```
OBSERVATION: Print outputs:
Last output from code snippet:
Birch plywood will float in ethanol because its density (680 kg/m³) is lower than the density of ethanol (789.4 kg/m³).

Wikipedia search agent logs

TASK:  density of birch plywood
AGENT: Thought: I'll use the `search_wikipedia` tool to seek out information in regards to the density of birch plywood.
Code:
```py
search_wikipedia('birch plywood')
```
OBSERVATION: Print outputs:
Last output from code snippet:
Pages found for query 'birch plywood':
Page: Plywood
Summary: Plywood is a composite material manufactured from thin layers, or "plies", of wood veneer which have been stacked and glued together. It's an engineered wood from the family of manufactured boards, which include plywood, medium-density fibreboard (MDF), oriented strand board (OSB), and particle board (or chipboard).
All plywoods bind resin and wood fibre sheets (cellulose cells are long, strong and thin) to form a composite material. The sheets of wood are stacked such that every layer has its grain set typically (see below) perpendicular to its adjoining layers. This alternation of the grain is named cross-graining and has several necessary advantages: it reduces the tendency of wood to separate when nailed at the sides; it reduces thickness swelling and shrinkage, providing improved dimensional stability; and it makes the strength of the panel consistent across all directions. There will likely be an odd variety of plies, in order that the sheet is balanced, that's, the surface layers have their gr
Page: Birch
Summary: A birch is a thin-leaved deciduous hardwood tree of the genus Betula (), within the family Betulaceae, which also includes alders, hazels, and hornbeams. It's closely related to the beech-oak family Fagaceae. The genus Betula comprises 30 to 60 known taxa of which 11 are on the IUCN 2011 Red List of Threatened Species. They're typically short-lived pioneer species and are widespread within the Northern Hemisphere, particularly in northern areas of temperate climates and in boreal climates. Birch wood is used for a big selection of purposes.
Page: Birch wood
Summary: Birch wood is a sort of wood of the birch. Birch wood is pale yellow-brown wood having a detailed, straight grain and uniform texture that finishes to a smooth surface. Sometimes it's dyed to mimic mahogany. This sort of wood is used for amongst others firewood, turnery, furniture, cabinetry, tools handles, hoops, plywood, flooring and shoe heels.
Page: Falco F8L
Summary: The Falco F8L is an Italian-designed lightweight 2-seater aerobatic aircraft.
Page: Crusader (speedboat)
Summary: Crusader was a jet-powered speed boat piloted by John Cobb.
The mix of an aerodynamically stable hull form and turbojet propulsion was proposed by Reid Railton, Cobb's adviser. A rocket-powered scale model was tested at Haslar. The total size design was by Peter du Cane and built by Vospers of Portsmouth. Technical assistance got here from Saunders-Roe and Vickers-Supermarine. It cost £15,000 in 1949.
It was silver and scarlet in color and 10 m long.
The engine was a de Havilland Ghost Mk 48 centrifugal turbojet provided as a loan by the Ministry of Supply on the request of Major Frank Halford, the engine designer. The engine was rated at 5,000 lb thrust fed by two scoop inlets forward of the cockpit.
The hull was of trimaran form, a principal hull with a planing step, and two smaller rear-mounted outriggers. Construction was of birch plywood frames and stringers. The hull was skinned in birch ply covered in doped fabric with metal skin reinforcement for planing surfaces. Aircraft-sty

AGENT: Thought: The pages returned from the search did indirectly mention the density of birch plywood. Nevertheless, the page on Birch Wood mentions that birch wood is used for plywood. I'll use the `search_info` tool to seek out more specific information in regards to the density of birch plywood from the page 'Plywood'.
Code:
```py
search_info('density of birch plywood', 'Plywood')
```
OBSERVATION: Print outputs:
Last output from code snippet:
Information retrieved from the page 'Plywood' for the query 'density of birch plywood':
The density of birch plywood is roughly 680 kg/m³.
AGENT: Thought: I even have found the density of birch plywood from the Wikipedia page 'Plywood'. The density is roughly 680 kg/m³.
Code:
```py
final_answer("The density of birch plywood is roughly 680 kg/m³.")
```
OBSERVATION: Print outputs:
Last output from code snippet:
The density of birch plywood is roughly 680 kg/m³.
------------------------------
TASK: density of ethanol
AGENT: Thought: I'll use the `search_wikipedia` tool to seek out the density of ethanol from Wikipedia.
Code:
```py
search_wikipedia('density of ethanol')
```
OBSERVATION: Print outputs:
Last output from code snippet:
Pages found for query 'density of ethanol':
Page: Ethanol (data page)
Summary: This page provides supplementary chemical data on ethanol.

Page: Ethanol
Summary: Ethanol (also called ethyl alcohol, grain alcohol, drinking alcohol, or just alcohol) is an organic compound with the chemical formula CH3CH2OH. It's an alcohol, with its formula also written as C2H5OH, C2H6O or EtOH, where Et stands for ethyl. Ethanol is a volatile, flammable, colorless liquid with a characteristic wine-like odor and pungent taste. In nature, grape-sugar breaks up by the motion of fermentation into alcohol or carbonic acid, without anything being added. As a psychoactive depressant, it's the lively ingredient in alcoholic beverages, and the second most consumed drug globally behind caffeine.
Ethanol is of course produced by the fermentation technique of sugars by yeasts or via petrochemical processes similar to ethylene hydration. Historically it was used as a general anesthetic, and has modern medical applications as an antiseptic, disinfectant, solvent for some medications, and antidote for methanol poisoning and ethylene glycol poisoning. It's used as a chemical so
Page: Alcohol by volume
Summary: Alcohol by volume (abbreviated as alc/vol or ABV) is a normal measure of the amount of alcohol contained in a given volume of an alcoholic beverage, expressed as a volume percent. It's defined because the variety of millilitres (mL) of pure ethanol present in 100 mL (3.5 imp fl oz; 3.4 US fl oz) of solution at 20 °C (68 °F). The variety of millilitres of pure ethanol is the mass of the ethanol divided by its density at 20 °C (68 °F), which is 0.78945 g/mL (0.82353 oz/US fl oz; 0.79122 oz/imp fl oz; 0.45633 oz/cu in). The alc/vol standard is used worldwide. The International Organization of Legal Metrology has tables of density of water–ethanol mixtures at different concentrations and temperatures.
In some countries, e.g. France, alcohol by volume is sometimes called degrees Gay-Lussac (after the French chemist Joseph Louis Gay-Lussac), although there may be a slight difference because the Gay-Lussac convention uses the International Standard Atmosphere value for temperature, 15 °C (59 °F).

Page: Alcohol fuel
Summary: Various alcohols are used as fuel for internal combustion engines. The primary 4 aliphatic alcohols (methanol, ethanol, propanol, and butanol)
are of interest as fuels because they will be synthesized chemically or biologically, and so they have characteristics which permit them to be utilized in internal combustion engines. The final chemical formula for alcohol fuel is CnH2n+1OH.
Most methanol is produced from natural gas, although it will probably be produced from biomass using very similar chemical processes. Ethanol is usually produced from biological material through fermentation processes. Biobutanol has the advantage in combustion engines in that its energy density is closer to gasoline than the simpler alcohols (while still retaining over 25% higher octane rating); nonetheless, biobutanol is currently tougher to provide than ethanol or methanol. When obtained from biological materials and/or biological processes, they're referred to as bioalcohols (e.g. "bioethanol"). There isn't any chemical dif
Page: Cellulosic ethanol
Summary: Cellulosic ethanol is ethanol (ethyl alcohol) produced from cellulose (the stringy fiber of a plant) somewhat than from the plant's seeds or fruit. It may well be produced from grasses, wood, algae, or other plants. It is mostly discussed to be used as a biofuel. The carbon dioxide that plants absorb as they grow offsets among the carbon dioxide emitted when ethanol constructed from them is burned, so cellulosic ethanol fuel has the potential to have a lower carbon footprint than fossil fuels.
Interest in cellulosic ethanol is driven by its potential to exchange ethanol constructed from corn or sugarcane. Since these plants are also used for food products, diverting them for ethanol production may cause food prices to rise; cellulose-based sources, alternatively, generally don't compete with food, because the fibrous parts of plants are mostly inedible to humans. One other potential advantage is the high diversity and abundance of cellulose sources; grasses, trees and algae are present in almost every envi

AGENT: Thought: The summary of the page 'Ethanol' mentions that ethanol is an alcohol with a characteristic wine-like odor and pungent taste. Nevertheless, it doesn't provide the density of ethanol. I'll use the `search_info` tool to seek out the density of ethanol from the 'Ethanol (data page)'.
Code:
```py
search_info('density of ethanol', 'Ethanol (data page)')
```
OBSERVATION: Print outputs:
Last output from code snippet:
Information retrieved from the page 'Ethanol (data page)' for the query 'density of ethanol':
The density of ethanol at 20°C is roughly 0.7894 g/cm³.
AGENT: Thought: I even have found the density of ethanol from the Wikipedia page 'Ethanol (data page)'. I'll return the result using the `final_answer` tool.
Code:
```py
final_answer("The density of ethanol at 20°C is roughly 0.7894 g/cm³.")
```
OBSERVATION: Print outputs:
Last output from code snippet:
The density of ethanol at 20°C is roughly 0.7894 g/cm³.

Page search agent logs

TASK:  Retrieve information in regards to the query:"density of birch plywood" from the Wikipedia page "Plywood".
AGENT: Thought: I want to seek out the density of birch plywood. I'll use the tool `retrieve_passages` to search for data on the Wikipedia page.
Code:
```py
result = retrieve_passages("density of birch plywood")
print(result)
```
OBSERVATION: Print outputs:
Retrieved passages for query "density of birch plywood":
Passage 0: ... . Shear stress, against this, is higher in the middle of the panel, and on the outer fibres. Inside Europe basic plywood will be divided into three principal categories: birch plywood (density approx. 680 kg/m3), mixed plywood (density approx. 620 kg/m3) and conifer plywoods (density 460–520 kg/m3). ...
Passage 1: ... . Aircraft grade plywood is constructed from three or more plies of birch, as thin as 0.40 millimetres (1⁄64 in) thick in total, and is incredibly strong and light-weight. ...
Passage 2: ... Baltic Birch plywood is a product of an area across the Baltic Sea. Originally manufactured for European cabinet makers but now popular in the US as well. It is vitally stable composed of an inner void-free core of cross-banded birch plys with an exterior grade adhesive. The face veneers are thicker than traditional cabinet grade ...
Passage 3: ... . In consequence, thicker panels can span greater distances under the identical loads. In bending, the utmost stress occurs within the outermost layers, one in tension, the opposite in compression. Bending stress decreases from the utmost on the face layers to just about zero on the central layer. Shear stress, against this, is higher in the middle of the panel, and on the outer fibres. Inside Europe basic plywood will be divided into three principal categories: birch plywood (density approx ...
Passage 4: ... Wind turbine blades
Insulation boxes for liquefied natural gas (LNG) carriers
Smooth surface and accurate thickness combined with the sturdiness of the fabric makes birch plywood a positive material for a lot of special end uses e.g.:

High-end loud speakers
Die-cutting boards
Supporting structure for parquet
Playground equipment
Furniture
Signs and fences for demanding outdoor promoting
Musical instruments
Sports equipment...

AGENT: Thought: From the passages, I can see that the density of birch plywood is roughly 680 kg/m³. I can use the `final_answer` tool to supply the reply.
Code:
```py
final_answer("The density of birch plywood is roughly 680 kg/m³.")
```
OBSERVATION: Print outputs:
Last output from code snippet:
The density of birch plywood is roughly 680 kg/m³.
------------------------------
TASK: Retrieve information in regards to the query:"density of ethanol" from the Wikipedia page "Ethanol (data page)".
AGENT: Thought: I want to seek out the density of ethanol. I'll use the tool `retrieve_passages` to get the knowledge from the Wikipedia page.
Code:
```py
result = retrieve_passages("density of ethanol")
print(result)
```
OBSERVATION: Print outputs:
Retrieved passages for query "density of ethanol":
Passage 0: ... == Density of ethanol at various temperatures ==
Data obtained from Lange 1967

These data correlate as ρ [g/cm3] = −8.461834×10−4 T [°C] + 0.8063372 with an R2 = 0.99999.

== Properties of aqueous ethanol solutions ==
Data obtained from Lange 1967

== Boiling points of aqueous solutions ==
Data obtained from CRC Handbook of Chemistry (Page 2117): 2391

‡Azeotropic mixture

== Charts ==

== References == ...
Passage 1: ... This page provides supplementary chemical data on ethanol.

== Material Safety Data Sheet ==
External MSDS

== Structure and properties ==

== Thermodynamic properties ==

== Spectral data ==

== Vapor pressure of liquid ==

== Density of ethanol at various temperatures ==
Data obtained from Lange 1967

These data correlate as ρ [g/cm3] = −8.461834×10−4 T [°C] + 0.8063372 with an R2 = 0.99999.

== Properties of aqueous ethanol solutions ==
Data obtained from Lange 1967...

AGENT: Thought: From the passages, I can see that the density of ethanol varies with temperature. I can use the provided linear equation to calculate the density at a selected temperature. I'll use the `math` module to perform the calculation.
Code:
```py
# Extract the coefficients from the equation
a = -8.461834e-4
b = 0.8063372

# Calculate the density at a selected temperature, let's take 20°C for instance
temperature = 20
density = a * temperature + b
print(density)
```
OBSERVATION: Print outputs:
0.789413532

AGENT: Thought: The passage provides a linear equation to calculate the density of ethanol at different temperatures. I can now use this equation to supply the density of ethanol at a selected temperature. I'll use the `final_answer` tool to return the relevant information.
Code:
```py
final_answer(f"The density of ethanol at 20°C is roughly {round(0.789413532, 4)} g/cm³.")
```
OBSERVATION: Print outputs:
Last output from code snippet:
The density of ethanol at 20°C is roughly 0.7894 g/cm³.

The model appropriately identifies density difference because the reason behind floating/sinking, breaks up the duty into finding the density of each substances, and is in a position to draw the right conclusion from the retrieved data despite them being in numerous units of measurement.

The discussed system has impressive capabilities, especially considering the limited size of the engine model used, but in fact, it has its own limitations. The larger one appears to be related to the ability of the engine model itself: while it seems in a position to understand and follow complex and long instructions in addition to to make use of the provided tools appropriately, sometimes it fails to comply with easy guidelines and it tends to repeat unfruitful actions without changes. This is especially outstanding when the knowledge the agent is searching for shouldn’t be present (or not easily extractible using the semantic search tool) from the provided pages.

One other drawback, intrinsic to agentic and much more outstanding in multi-agentic systems, is the computation time needed for the assorted agents’ execution. In some easy cases where the usual RAG workflow would have been enough to reply the query, this might produce an unnecessary computational overhead.

Finally, having multiple agents interacting with one another can amplify the danger of hallucinations, as a hallucination made by one agent could propagate over the execution chain, making it also very difficult to trace.

Let’s visualize an example wherein the system, while still providing the right answer, made excessive use of tool calls (with some repeated actions) unnecessarily extending the execution time.

Task: Which dynasty was ruling China on the time of the autumn of Constantinople?

The duty requires a superb level of abstraction because the two events should not related and the precise 12 months of the autumn of Constantinople might not be reported on the page of the corresponding dynasty.

The manager agent execution remains to be lean and on point, solving the duty appropriately by first retrieving the date of the autumn of Constantinople after which searching for Chinese dynasties in that 12 months. Nevertheless, we are able to already see that the search results, while still containing the required information, seem a bit strange.

Agent:  Thought: To reply this query, I want to seek out out when Constantinople fell and which Chinese dynasty was ruling at the moment. I'll start by finding the autumn date of Constantinople.
Code:
```py
wikipedia_search_agent(query="Fall of Constantinople")
```
Remark: Print outputs:
Last output from code snippet:
The leader of the Ottoman Empire in 1453, in the course of the fall of Constantinople, was Mehmed II, also referred to as Mehmed the Conqueror.
Agent: Thought: From the previous search, we all know that Constantinople fell in 1453, and it was conquered by Mehmed II. Now I want to seek out out which Chinese dynasty was ruling in 1453. I'll seek for the Chinese dynasties around that point.
Code:
```py
wikipedia_search_agent(query="Chinese dynasties 1453")
```
Remark: Print outputs:
Last output from code snippet:
In 1453, the Ming dynasty was in full control of China. No specific events related to 1453 are mentioned in the knowledge provided.
Agent: Thought: Based on the knowledge provided, the Ming dynasty was in full control of China in 1453. Due to this fact, the dynasty ruling China when Constantinople fell could be the Ming dynasty.
Code:
```py
final_answer("The dynasty ruling China when Constantinople fell in 1453 was the Ming dynasty.")
```
Remark: Print outputs:
Last output from code snippet:
The dynasty ruling China when Constantinople fell in 1453 was the Ming dynasty.

Let’s thus inspect the corresponding Wikipedia search agent tasks and their execution. We are able to see that, possibly as a consequence of the broad task “Fall of Constantinople”, the agent looks at other specific information after having found the right date. The identical happens when retrieving information in regards to the Chinese dynasties, with the further problem that some tool calls were repeated identically.

TASK:  Fall of Constantinople
AGENT: Thought: I'll use the `search_wikipedia` tool to seek out information in regards to the fall of Constantinople. This can likely provide me with a summary of the event and possibly links to related pages.
Code:
```py
search_wikipedia("Fall of Constantinople")
```
OBSERVATIONS: Print outputs:
Last output from code snippet:
Pages found for query 'Fall of Constantinople':
Page: Fall of Constantinople
Summary: The autumn of Constantinople, also referred to as the conquest of Constantinople, was the capture of the capital of the Byzantine Empire by the Ottoman Empire. Town was captured on 29 May 1453 as a part of the culmination of a 55-day siege which had begun on 6 April.
The attacking Ottoman Army, which significantly outnumbered Constantinople's defenders, was commanded by the 21-year-old Sultan Mehmed II (later nicknamed "the Conqueror"), while the Byzantine army was led by Emperor Constantine XI Palaiologos. After conquering town, Mehmed II made Constantinople the brand new Ottoman capital, replacing Adrianople.
The autumn of Constantinople and of the Byzantine Empire was a watershed of the Late Middle Ages, marking the effective end of the Roman Empire, a state which began in roughly 27 BC and had lasted nearly 1500 years. For a lot of modern historians, the autumn of Constantinople marks the top of the medieval period and the start of the early modern period. Town's fall also stood as a turni
Page: Sack of Constantinople
Summary: The sack of Constantinople occurred in April 1204 and marked the culmination of the Fourth Crusade. Crusaders sacked and destroyed most of Constantinople, the capital of the Byzantine Empire. After the capture of town, the Latin Empire (known to the Byzantines because the Frankokratia, or the Latin occupation) was established and Baldwin of Flanders crowned as Emperor Baldwin I of Constantinople in Hagia Sophia.
After town's sacking, a lot of the Byzantine Empire's territories were divided up among the many Crusaders. Byzantine aristocrats also established a lot of small independent splinter states—certainly one of them being the Empire of Nicaea, which might eventually recapture Constantinople in 1261 and proclaim the reinstatement of the Empire. Nevertheless, the restored Empire never managed to reclaim all its former territory or attain its earlier economic strength, and it step by step succumbed to the rising Ottoman Empire over the next two centuries.
The Byzantine Empire was left poorer, smal
Page: Constantinople
Summary: Constantinople (see other names) became the capital of the Roman Empire in the course of the reign of Constantine the Great in 330. Following the collapse of the Western Roman Empire within the late fifth century, Constantinople remained the capital of the Eastern Roman Empire (also referred to as the Byzantine Empire; 330–1204 and 1261–1453), the Latin Empire (1204–1261), and the Ottoman Empire (1453–1922). Following the Turkish War of Independence, the Turkish capital then moved to Ankara. Officially renamed Istanbul in 1930, town is today the biggest city in Europe, straddling the Bosporus strait and lying in each Europe and Asia, and the financial center of Turkey.
In 324, following the reunification of the Eastern and Western Roman Empires, the traditional city of Byzantium was chosen to function the brand new capital of the Roman Empire, and town was renamed Nova Roma, or 'Latest Rome', by Emperor Constantine the Great. On 11 May 330, it was renamed Constantinople and dedicated to Constantine. Constantin
Page: Moscow, third Rome
Summary: Moscow, third Rome (Russian: Москва — третий Рим; Moskva, tretiĭ Rim) is a theological and political concept asserting Moscow because the successor to ancient Rome, with the Russian world carrying forward the legacy of the Roman Empire. The term "third Rome" refers to a historical topic of debate in European culture: the query of the successor city to the "first Rome" (Rome, throughout the Western Roman Empire) and the "second Rome" (Constantinople, throughout the Eastern Roman Empire).
Page: Byzantine Empire
Summary: The Byzantine Empire, also known as the Eastern Roman Empire, was the continuation of the Roman Empire centred in Constantinople during late antiquity and the Middle Ages. The eastern half of the Empire survived the conditions that caused the autumn of the West within the fifth century AD, and continued to exist until the autumn of Constantinople to the Ottoman Empire in 1453. During most of its existence, the empire remained essentially the most powerful economic, cultural, and military force within the Mediterranean world. The term "Byzantine Empire" was only coined following the empire's demise; its residents referred to the polity because the "Roman Empire" and to themselves as "Romans". As a result of the imperial seat's move from Rome to Byzantium, the adoption of state Christianity, and the predominance of Greek as a substitute of Latin, modern historians proceed to make a distinction between the sooner Roman Empire and the later Byzantine Empire.
Through the earlier Pax Romana period, the western parts of the empire b

AGENT: Thought: From the summary of the page "Fall of Constantinople", I can see that the event took place in 1453. I'll use the `search_info` tool to seek out more details in regards to the event, specifically who was the leader of the Ottoman Empire at the moment.
Code:
```py
search_info("leader of the Ottoman Empire in 1453", "Fall of Constantinople")
```
OBSERVATIONS: Print outputs:
Last output from code snippet:
Information retrieved from the page 'Fall of Constantinople' for the query 'leader of the Ottoman Empire in 1453':
The leader of the Ottoman Empire in 1453 was Mehmed II, also referred to as Mehmed the Conqueror.
AGENT: Thought: I even have found that the leader of the Ottoman Empire in 1453 was Mehmed II, also referred to as Mehmed the Conqueror. I'll use the `final_answer` tool to supply the reply.
Code:
```py
final_answer("The leader of the Ottoman Empire in 1453, in the course of the fall of Constantinople, was Mehmed II, also referred to as Mehmed the Conqueror.")
```
OBSERVATIONS: Print outputs:
Last output from code snippet:
The leader of the Ottoman Empire in 1453, in the course of the fall of Constantinople, was Mehmed II, also referred to as Mehmed the Conqueror.
------------------------------
TASK: Chinese dynasties 1453
AGENT: Thought: I'll use the `search_wikipedia` tool to seek out details about Chinese dynasties across the 12 months 1453. I'll provide a general query related to Chinese dynasties in that point period.
Code:
```py
search_wikipedia('Chinese dynasties 1453')
```
OBSERVATIONS: Print outputs:
Last output from code snippet:
Pages found for query 'Chinese dynasties 1453':
Page: Chinese Empire
Summary: Chinese Empire (or Empire of China) is a term referring to the realm ruled by the Emperor of China in the course of the era referred to as Imperial China. It was coined by western scholars and used to explain the Ming and Qing dynasties (or imperial Chinese dynasties normally). One other term was "Celestial Empire", in reference to the status of the emperor because the Son of Heaven. In 221 BC, China was unified under an emperor for the primary time, and various dynasties or empires founded by hereditary monarchs ruled China for a complete of two millennia since then, including the Qin, Han, Jin, Sui, Tang, Song, Yuan, Ming, and Qing.

Page: Ming dynasty
Summary: The Ming dynasty, officially the Great Ming, was an imperial dynasty of China, ruling from 1368 to 1644 following the collapse of the Mongol-led Yuan dynasty. The Ming dynasty was the last imperial dynasty of China ruled by the Han people, the bulk ethnic group in China. Although the first capital of Beijing fell in 1644 to a insurrection led by Li Zicheng (who established the short-lived Shun dynasty), quite a few rump regimes ruled by remnants of the Ming imperial family—collectively called the Southern Ming—survived until 1662.
The Ming dynasty's founder, the Hongwu Emperor (r. 1368–1398), attempted to create a society of self-sufficient rural communities ordered in a rigid, immobile system that might guarantee and support a everlasting class of soldiers for his dynasty: the empire's standing army exceeded a million troops and the navy's dockyards in Nanjing were the biggest on this planet. He also took great care breaking the ability of the court eunuchs and unrelated magnates, enfeoff
Page: List of time periods
Summary: The categorisation of the past into discrete, quantified named blocks of time is named periodization. It is a list of such named time periods as defined in various fields of study.
These will be divided broadly into prehistorical periods and historical periods
(when written records began to be kept).
In archaeology and anthropology, prehistory is subdivided into the three-age system, this list includes using the three-age system in addition to a lot of various designation utilized in reference to sub-ages inside the normal three.
The dates for every age can vary by region. On the geologic time scale, the Holocene epoch starts at the top of the last glacial period of the present ice age (c. 10,000 BC) and continues to the current. The start of the Mesolithic will likely be considered to correspond to the start of the Holocene epoch.

Page: Celestial Empire
Summary: Celestial Empire (Chinese: 天朝; pinyin: Tiāncháo; lit. 'heavenly dynasty') is an old name used to consult with China or the Chinese Empire, from a literary and poetic translation of the Chinese term, certainly one of many names for China. The name was utilized in reference to the status of the Emperor of China because the Son of Heaven within the Sinosphere.
Accordingly, within the nineteenth century, the name "Celestial" was used to consult with Chinese people. Each terms were widely utilized in the English-language popular mass media of the day, but fell into disuse in a while. Its usage has turn out to be popular again in the current day (2015), particularly amongst Chinese Web users. It's used to consult with the present Communist regime, to imply either disapproval for its political suppression and arrogance or national pride within the country's emergence as a superpower within the twenty first century, depending on the context.
In modern times it has mostly fallen into disuse, however the name "Celestial Empire" still appears in various media similar to ar
Page: List of dynasties
Summary: It is a list of monarchical dynasties and dynastic regimes organized by geographic region. Extant dynasties are rendered in daring and highlighted.

AGENT: Thought: From the summaries, I can see that the Ming dynasty ruled from 1368 to 1644, which covers the 12 months 1453. I'll use the `search_info` tool to seek out more detailed information in regards to the Ming dynasty in the course of the 12 months 1453.
Code:
```py
search_info('1453', 'Ming dynasty')
```
OBSERVATIONS: Print outputs:
Last output from code snippet:
Information retrieved from the page 'Ming dynasty' for the query '1453':
The 12 months 1453 falls throughout the period of the Ming dynasty, which ruled from 1368 to 1644. During this time, the Ming dynasty was in full control of China and experienced significant developments similar to the development of the Forbidden City and the expansion of the Great Wall of China.
AGENT: Thought: Now that I do know the Ming dynasty ruled during 1453, I can provide a more specific answer in regards to the events that happened in China during that 12 months. Nevertheless, the knowledge provided doesn't give us specific details in regards to the events in 1453. I'll use the `search_info` tool to seek out more detailed information in regards to the Ming dynasty in the course of the 12 months 1453.
Code:
```py
search_info('1453', 'Ming dynasty')
```
OBSERVATIONS: Print outputs:
Last output from code snippet:
Information retrieved from the page 'Ming dynasty' for the query '1453':
The 12 months 1453 falls throughout the period of the Ming dynasty, which ruled from 1368 to 1644. During this time, the Ming dynasty was in full control of China and experienced significant developments similar to the development of the Forbidden City and the expansion of the Great Wall of China.
AGENT: Thought: The data provided doesn't specifically mention the events of 1453. Nevertheless, we are able to infer that in the course of the Ming dynasty, significant developments occurred. I'll use the `search_info` tool to seek out more specific information in regards to the events of 1453 within the Ming dynasty.
Code:
```py
search_info('1453', 'Ming dynasty')
```
OBSERVATIONS: Print outputs:
Last output from code snippet:
Information retrieved from the page 'Ming dynasty' for the query '1453':
The 12 months 1453 falls throughout the period of the Ming dynasty, which ruled from 1368 to 1644. During this time, the Ming dynasty was in full control of China and experienced significant developments similar to the development of the Forbidden City and the expansion of the Great Wall of China.
AGENT: Thought: The data provided indicates that the Ming dynasty was in full control of China in the course of the 12 months 1453. Nevertheless, there is no such thing as a specific mention of events that happened in 1453. I'll use the `search_info` tool to seek out more specific information in regards to the events of 1453 within the Ming dynasty.
Code:
```py
search_info('1453', 'Ming dynasty')
```
OBSERVATIONS: Print outputs:
Last output from code snippet:
Information retrieved from the page 'Ming dynasty' for the query '1453':
The 12 months 1453 falls throughout the period of the Ming dynasty, which ruled from 1368 to 1644. During this time, the Ming dynasty was in full control of China and experienced significant developments similar to the development of the Forbidden City and the expansion of the Great Wall of China.
AGENT: Thought: The data provided doesn't specifically mention any events that occurred in 1453. Nevertheless, we all know that the Ming dynasty was in full control of China during this time. I'll use the `final_answer` tool to supply the reply based on the knowledge now we have.
Code:
```py
final_answer("In 1453, the Ming dynasty was in full control of China. No specific events related to 1453 are mentioned in the knowledge provided.")
```
OBSERVATIONS: Print outputs:
Last output from code snippet:
In 1453, the Ming dynasty was in full control of China. No specific events related to 1453 are mentioned in the knowledge provided.

Diving deeper into the page search agent execution, we see that this also repeated multiple tool calls with the identical parameters.

TASK:  Retrieve information in regards to the query:"leader of the Ottoman Empire in 1453" from the Wikipedia page "Fall of Constantinople".
AGENT: Thought: I want to seek out out who was the leader of the Ottoman Empire in 1453. I'll use the `retrieve_passages` tool to look for this information on the Wikipedia page "Fall of Constantinople".
Code:
```py
result = retrieve_passages("leader of the Ottoman Empire in 1453")
print(result)
```
OBSERVATIONS: Print outputs:
Retrieved passages for query "leader of the Ottoman Empire in 1453":
Passage 0: ... When Mehmed II succeeded his father in 1451, he was 19 years old. Many European courts assumed that the young Ottoman ruler wouldn't seriously challenge Christian hegemony within the Balkans and the Aegean. Actually, Europe celebrated Mehmed coming to the throne and hoped his inexperience would lead the Ottomans astray. This calculation was boosted by Mehmed's friendly overtures to the European envoys at his latest court. But Mehmed's mild words weren't matched by his actions ...
Passage 1: ... The attacking Ottoman Army, which significantly outnumbered Constantinople's defenders, was commanded by the 21-year-old Sultan Mehmed II (later nicknamed "the Conqueror"), while the Byzantine army was led by Emperor Constantine XI Palaiologos. After conquering town, Mehmed II made Constantinople the brand new Ottoman capital, replacing Adrianople. ...
Passage 2: ... . The oldest boy, renamed Murad, became a private favourite of Mehmed and served as Beylerbey (Governor-General) of Rumeli (the Balkans). The younger son, renamed Mesih Pasha, became Admiral of the Ottoman fleet and Sancak Beg (Governor) of the province of Gallipoli. He eventually served twice as Grand Vizier under Mehmed's son, Bayezid II. ...
Passage 3: ... == External links ==

Media related to Fall of Constantinople (1453) at Wikimedia Commons
The Siege of Constantinople As The Islamic World Sees it Archived 22 April 2021 on the Wayback Machine
World History Encyclopedia – 1453: The Fall of Constantinople
Constantinople Siege & Fall, BBC Radio 4 discussion with Roger Crowley, Judith Herrin & Colin Imber (In Our Time, 28 December 2006). ...
Passage 4: ... In the summertime of 1452, when Rumeli Hisarı was accomplished and the specter of the Ottomans had turn out to be imminent, Constantine wrote to the Pope, promising to implement the union, which was declared valid by a half-hearted imperial court on 12 December 1452. Although he was longing for a bonus, Pope Nicholas V didn't have the influence the Byzantines thought he had over the Western kings and princes, a few of whom were wary of accelerating papal control...

AGENT: Thought: From the passages, it appears that evidently the leader of the Ottoman Empire in 1453 was Mehmed II, also referred to as Mehmed the Conqueror. I'll use the `final_answer` tool to supply the reply.
Code:
```py
final_answer("The leader of the Ottoman Empire in 1453 was Mehmed II, also referred to as Mehmed the Conqueror.")
```
OBSERVATIONS: Print outputs:
Last output from code snippet:
The leader of the Ottoman Empire in 1453 was Mehmed II, also referred to as Mehmed the Conqueror.
------------------------------
TASK: Retrieve information in regards to the query:"1453" from the Wikipedia page "Ming dynasty".
AGENT: Thought: I want to seek out information related to the 12 months 1453 from the Wikipedia page "Ming dynasty". I'll use the `retrieve_passages` tool to get relevant passages.
Code:
```py
result = retrieve_passages("1453 Ming dynasty")
print(result)
```
OBSERVATIONS: Print outputs:
Retrieved passages for query "1453 Ming dynasty":
Passage 0: ... The Ming dynasty, officially the Great Ming, was an imperial dynasty of China, ruling from 1368 to 1644 following the collapse of the Mongol-led Yuan dynasty. The Ming dynasty was the last imperial dynasty of China ruled by the Han people, the bulk ethnic group in China ...
Passage 1: ... === Reference works and first sources ===
Farmer, Edward L. ed. Ming History: An Introductory Guide to Research (1994).
Goodrich, Luther Carrington (1976). Dictionary of Ming Biography, 1368–1644. Latest York: Columbia University Press. ISBN 978-0-231-03833-1.
The Ming History English Translation Project, A collaborative project that makes available translations (from Chinese to English) of portions of the 明史 Mingshi (Official History of the Ming Dynasty). ...
Passage 2: ... ==== Reign of the Hongwu Emperor ==== ...
Passage 3: ... . The Ming dynasty was the last imperial dynasty of China ruled by the Han people, the bulk ethnic group in China. Although the first capital of Beijing fell in 1644 to a insurrection led by Li Zicheng (who established the short-lived Shun dynasty), quite a few rump regimes ruled by remnants of the Ming imperial family—collectively called the Southern Ming—survived until 1662. ...
Passage 4: ... . Zhu Di assumed the throne because the Yongle Emperor (r. 1402–24); his reign is universally viewed by scholars as a "second founding" of the Ming dynasty since he reversed a lot of his father's policies....

AGENT: Thought: The passages do indirectly mention the 12 months 1453. Nevertheless, I can infer that the Ming dynasty lasted from 1368 to 1644, and 1453 falls inside this era. I'll use the `final_answer` tool to supply a summary based on the knowledge available.
Code:
```py
final_answer("The 12 months 1453 falls throughout the period of the Ming dynasty, which ruled from 1368 to 1644. During this time, the Ming dynasty was in full control of China and experienced significant developments similar to the development of the Forbidden City and the expansion of the Great Wall of China.")
```
OBSERVATIONS: Print outputs:
Last output from code snippet:
The 12 months 1453 falls throughout the period of the Ming dynasty, which ruled from 1368 to 1644. During this time, the Ming dynasty was in full control of China and experienced significant developments similar to the development of the Forbidden City and the expansion of the Great Wall of China.
------------------------------
TASK: Retrieve information in regards to the query:"1453" from the Wikipedia page "Ming dynasty".
AGENT: Thought: I want to seek out information related to the 12 months 1453 from the Wikipedia page "Ming dynasty". I'll use the `retrieve_passages` tool to get relevant passages.
Code:
```py
result = retrieve_passages("1453 Ming dynasty")
print(result)
```
OBSERVATIONS: Print outputs:
Retrieved passages for query "1453 Ming dynasty":
Passage 0: ... The Ming dynasty, officially the Great Ming, was an imperial dynasty of China, ruling from 1368 to 1644 following the collapse of the Mongol-led Yuan dynasty. The Ming dynasty was the last imperial dynasty of China ruled by the Han people, the bulk ethnic group in China ...
Passage 1: ... === Reference works and first sources ===
Farmer, Edward L. ed. Ming History: An Introductory Guide to Research (1994).
Goodrich, Luther Carrington (1976). Dictionary of Ming Biography, 1368–1644. Latest York: Columbia University Press. ISBN 978-0-231-03833-1.
The Ming History English Translation Project, A collaborative project that makes available translations (from Chinese to English) of portions of the 明史 Mingshi (Official History of the Ming Dynasty). ...
Passage 2: ... ==== Reign of the Hongwu Emperor ==== ...
Passage 3: ... . The Ming dynasty was the last imperial dynasty of China ruled by the Han people, the bulk ethnic group in China. Although the first capital of Beijing fell in 1644 to a insurrection led by Li Zicheng (who established the short-lived Shun dynasty), quite a few rump regimes ruled by remnants of the Ming imperial family—collectively called the Southern Ming—survived until 1662. ...
Passage 4: ... . Zhu Di assumed the throne because the Yongle Emperor (r. 1402–24); his reign is universally viewed by scholars as a "second founding" of the Ming dynasty since he reversed a lot of his father's policies....

AGENT: Thought: The passages do indirectly mention the 12 months 1453. Nevertheless, I can infer that the Ming dynasty lasted from 1368 to 1644, and 1453 falls inside this era. I'll use the `final_answer` tool to supply a summary based on the knowledge available.
Code:
```py
final_answer("The 12 months 1453 falls throughout the period of the Ming dynasty, which ruled from 1368 to 1644. During this time, the Ming dynasty was in full control of China and experienced significant developments similar to the development of the Forbidden City and the expansion of the Great Wall of China.")
```
OBSERVATIONS: Print outputs:
Last output from code snippet:
The 12 months 1453 falls throughout the period of the Ming dynasty, which ruled from 1368 to 1644. During this time, the Ming dynasty was in full control of China and experienced significant developments similar to the development of the Forbidden City and the expansion of the Great Wall of China.
------------------------------
TASK: Retrieve information in regards to the query:"1453" from the Wikipedia page "Ming dynasty".
AGENT: Thought: I want to seek out information related to the 12 months 1453 from the Wikipedia page "Ming dynasty". I'll use the `retrieve_passages` tool to get relevant passages.
Code:
```py
result = retrieve_passages("1453 Ming dynasty")
print(result)
```
OBSERVATIONS: Print outputs:
Retrieved passages for query "1453 Ming dynasty":
Passage 0: ... The Ming dynasty, officially the Great Ming, was an imperial dynasty of China, ruling from 1368 to 1644 following the collapse of the Mongol-led Yuan dynasty. The Ming dynasty was the last imperial dynasty of China ruled by the Han people, the bulk ethnic group in China ...
Passage 1: ... === Reference works and first sources ===
Farmer, Edward L. ed. Ming History: An Introductory Guide to Research (1994).
Goodrich, Luther Carrington (1976). Dictionary of Ming Biography, 1368–1644. Latest York: Columbia University Press. ISBN 978-0-231-03833-1.
The Ming History English Translation Project, A collaborative project that makes available translations (from Chinese to English) of portions of the 明史 Mingshi (Official History of the Ming Dynasty). ...
Passage 2: ... ==== Reign of the Hongwu Emperor ==== ...
Passage 3: ... . The Ming dynasty was the last imperial dynasty of China ruled by the Han people, the bulk ethnic group in China. Although the first capital of Beijing fell in 1644 to a insurrection led by Li Zicheng (who established the short-lived Shun dynasty), quite a few rump regimes ruled by remnants of the Ming imperial family—collectively called the Southern Ming—survived until 1662. ...
Passage 4: ... . Zhu Di assumed the throne because the Yongle Emperor (r. 1402–24); his reign is universally viewed by scholars as a "second founding" of the Ming dynasty since he reversed a lot of his father's policies....

AGENT: Thought: The passages do indirectly mention the 12 months 1453. Nevertheless, I can infer that the Ming dynasty lasted from 1368 to 1644, and 1453 falls inside this era. I'll use the `final_answer` tool to supply a summary based on the knowledge available.
Code:
```py
final_answer("The 12 months 1453 falls throughout the period of the Ming dynasty, which ruled from 1368 to 1644. During this time, the Ming dynasty was in full control of China and experienced significant developments similar to the development of the Forbidden City and the expansion of the Great Wall of China.")
```
OBSERVATIONS: Print outputs:
Last output from code snippet:
The 12 months 1453 falls throughout the period of the Ming dynasty, which ruled from 1368 to 1644. During this time, the Ming dynasty was in full control of China and experienced significant developments similar to the development of the Forbidden City and the expansion of the Great Wall of China.
------------------------------
TASK: Retrieve information in regards to the query:"1453" from the Wikipedia page "Ming dynasty".
AGENT: Thought: I want to seek out information related to the 12 months 1453 from the Wikipedia page "Ming dynasty". I'll use the `retrieve_passages` tool to get relevant passages.
Code:
```py
result = retrieve_passages("1453 Ming dynasty")
print(result)
```
OBSERVATIONS: Print outputs:
Retrieved passages for query "1453 Ming dynasty":
Passage 0: ... The Ming dynasty, officially the Great Ming, was an imperial dynasty of China, ruling from 1368 to 1644 following the collapse of the Mongol-led Yuan dynasty. The Ming dynasty was the last imperial dynasty of China ruled by the Han people, the bulk ethnic group in China ...
Passage 1: ... === Reference works and first sources ===
Farmer, Edward L. ed. Ming History: An Introductory Guide to Research (1994).
Goodrich, Luther Carrington (1976). Dictionary of Ming Biography, 1368–1644. Latest York: Columbia University Press. ISBN 978-0-231-03833-1.
The Ming History English Translation Project, A collaborative project that makes available translations (from Chinese to English) of portions of the 明史 Mingshi (Official History of the Ming Dynasty). ...
Passage 2: ... ==== Reign of the Hongwu Emperor ==== ...
Passage 3: ... . The Ming dynasty was the last imperial dynasty of China ruled by the Han people, the bulk ethnic group in China. Although the first capital of Beijing fell in 1644 to a insurrection led by Li Zicheng (who established the short-lived Shun dynasty), quite a few rump regimes ruled by remnants of the Ming imperial family—collectively called the Southern Ming—survived until 1662. ...
Passage 4: ... . Zhu Di assumed the throne because the Yongle Emperor (r. 1402–24); his reign is universally viewed by scholars as a "second founding" of the Ming dynasty since he reversed a lot of his father's policies....

AGENT: Thought: The passages do indirectly mention the 12 months 1453. Nevertheless, I can infer that the Ming dynasty lasted from 1368 to 1644, and 1453 falls inside this era. I'll use the `final_answer` tool to supply a summary based on the knowledge available.
Code:
```py
final_answer("The 12 months 1453 falls throughout the period of the Ming dynasty, which ruled from 1368 to 1644. During this time, the Ming dynasty was in full control of China and experienced significant developments similar to the development of the Forbidden City and the expansion of the Great Wall of China.")
```
OBSERVATIONS: Print outputs:
Last output from code snippet:
The 12 months 1453 falls throughout the period of the Ming dynasty, which ruled from 1368 to 1644. During this time, the Ming dynasty was in full control of China and experienced significant developments similar to the development of the Forbidden City and the expansion of the Great Wall of China.

On this blog post, I explained create a multi-agentic RAG system using code agents and a “small” open-source LLM like Qwen2.5–7B-Instruct. I even have discussed the principal architectural features and a few specific selections relative to the Hugging Face code agent implementation that I made to enhance the result. The total code details can be found in the next GitHub repo.

The multi-agentic system described, despite being powered by a small model running on consumer-grade hardware, can solve multi-hop question-answering tasks related to complex queries. Specifically:

  • It may well break down the query into manageable sub-tasks;
  • It may well discover the Wikipedia pages containing the mandatory information;
  • It may well mix information coming from multiple pages;
  • It may well seek for detailed information on a Wikipedia page;
  • It may well determine whether it needs more information and tries to seek out it;
  • It may well successfully fix small bugs within the code it produces and handle tool errors (like Wikipedia disambiguation errors).

I even have also outlined some limitations of the system, similar to increased computation time, repetitive actions, and the potential propagation of hallucinations. The latter could possibly be mitigated by including within the system a “proofreader” agent that checks that the reported information is in agreement with the retrieved sources.

It’s also value noting that, because the agentic system has a normal RAG approach at its core, all the standard techniques used to enhance the efficiency and accuracy of the latter will be implemented within the framework.

One other possible improvement is to make use of techniques to extend test time computation to present the model more “time to think” just like OpenAI o1/o3 models. It’s nonetheless necessary to notice that this modification will further increase execution time.

Finally, because the multi-agentic system is made up of agents specialized in a single task, using a distinct model engine for every of them could improve the performance. Specifically, it is feasible to fine-tune a distinct model for every task within the system for further performance gains. This could possibly be particularly useful for small models. It’s value mentioning that fine-tuning data will be collected by running the system on a set of predetermined tasks and saving the agents’ output when the system produces the right answer, thus eliminating the necessity for expensive manual data annotation.

I hope you found this tutorial useful, yow will discover the total code implementation within the GitHub repo and take a look at it yourself within the Colab notebook.

ASK DUKE

What are your thoughts on this topic?
Let us know in the comments below.

0 0 votes
Article Rating
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Share this article

Recent posts

0
Would love your thoughts, please comment.x
()
x