from smolagents import ManagedAgent
managed_web_agent = ManagedAgent(
agent=web_agent,
name="search",
description="Runs web searches for you. Give it your query as an argument.",
)
answer = manager_agent.run("If LLM training continues to scale up at the current rhythm until 2030, what would be the electric power in GW required to power the biggest training runs by 2030? What would that correspond to, compared to some countries? Please provide a source for any numbers used.")
示例输出
Based on current growth projections and energy consumption estimates, if LLM trainings continue to scale up at the
current rhythm until 2030:
1. The electric power required to power the biggest training runs by 2030 would be approximately 303.74 GW, which
translates to about 2,660,762 GWh/year.
1. Comparing this to countries' electricity consumption:
- It would be equivalent to about 34% of China's total electricity consumption.
- It would exceed the total electricity consumption of India (184%), Russia (267%), and Japan (291%).
- It would be nearly 9 times the electricity consumption of countries like Italy or Mexico.
2. Source of numbers:
- The initial estimate of 5 GW for future LLM training comes from AWS CEO Matt Garman.
- The growth projection used a CAGR of 79.80% from market research by Springs.
- Country electricity consumption data is from the U. S. Energy Information Administration, primarily for the year✅
2021.
在这个教程中,我们将构建一个多代理(multi-agent)系统,模拟一个能够协作完成复杂任务的网络浏览器。通过结合代码解释、网页搜索和网页访问工具,我们的系统将能够搜索信息、处理数据并回答复杂问题。
🌟 系统概览
我们设计的系统结构如下:
🚀 安装依赖
首先,运行以下命令安装所需的依赖包:
🔐 登录 Hugging Face Hub
为了调用 Hugging Face 的 Inference API,我们需要登录:
⚡️ 使用 Hugging Face 模型
我们将使用 Hugging Face 的 Qwen/Qwen2.5-Coder-32B-Instruct 模型,这是一款强大的代码生成和推理模型,支持长上下文(最多 128K tokens)。模型 ID 如下:
🔍 创建网络搜索工具
我们将使用
DuckDuckGoSearchTool
作为搜索工具,并重新实现一个VisitWebpageTool
来访问网页内容。以下是VisitWebpageTool
的实现:测试工具:
🤖 构建 Multi-Agent 系统
1️⃣ 创建 Web Agent
我们将
DuckDuckGoSearchTool
和visit_webpage
工具组合成一个 Web Agent:2️⃣ 封装为 Managed Agent
将
web_agent
封装为ManagedAgent
,使其可以被其他代理调用:3️⃣ 创建 Manager Agent
我们创建一个 Manager Agent 来管理整个系统。由于它负责高级推理,我们选择
CodeAgent
,并允许其导入额外的 Python 包(如time
、numpy
和pandas
)以支持复杂计算:🧠 运行系统
现在,我们可以运行系统来回答一个需要搜索和计算的问题:
示例输出
💡 扩展思路
你可以轻松扩展这个系统:
通过这种方式,我们可以构建一个功能强大的多代理系统,解决从搜索到推理的一系列问题!✅