基于 AutoGen 的 LLM 多智能体自动收集论文与生成报告实践
最近需要优化人脸姿态评估模型,往常我需要调研当前业界最新论文,在 arxiv 上查阅论文,然后到相关算法 benchmark 上查看排名,最后选定论文和模型。今天看到使用 AutoGen 自动获取数据并撰写分析报告的实验,于是突发奇想,我为什么不用 AutoGen 写一个根据我的需求自动调研最近 4 年人脸姿态评估论文并撰写一个报告给我呢?这样至少能节省不少时间,而且最终会输出一份中文报告。
1. 对话流程设计
要实现这样的任务,需要自动编码获取论文和摘要,然后根据获取到的论文摘要进行报告撰写。大致流程如下:
- UserAgent 发送任务给 PlannerAgent
- PlannerAgent 开始规划任务
- ProgrammingAgent 通过编写程序获取规划任务中的信息并发送给 Code Executor
- Code Executor 执行编码
- 如果程序运行出错,则反馈给 ProgrammingAgent,其根据反馈调整代码,再次给到 Code Executor
- 如果程序运行成功,则输出结果给到 WriterAgent
- WriterAgent 根据给定信息开始撰写报告,并发送给 UserAgent 审核
- 如果审核通过,结束;如果审核失败,则反馈给 Writer 让其优化。
2. 对话实现
熟悉如何编写 llm_config 和实例化 ConversableAgent 的同学可以跳过此部分。其中 system prompt 较长有所删减。
user_proxy = autogen.ConversableAgent(
name="Admin",
system_message="Give the task, and send instructions to writer to refine the blog post.",
code_execution_config=False,
llm_config=llm_config,
human_input_mode="ALWAYS",
)
planner = autogen.ConversableAgent(
name="Planner",
system_message="Given a task, please determine ...",
description="Given...",
llm_config=llm_config,
)
engineer = autogen.AssistantAgent(
name="Engineer",
llm_config=llm_config,
description="Write code based on the plan provided by the planner.",
)
writer = autogen.ConversableAgent(
name="Writer",
llm_config=llm_config,
system_message="Writer. Please write blogs in markdown format (with relevant titles)",
description="After all ...",
)
executor = autogen.ConversableAgent(
name="Executor",
description="Execute the code written by the engineer and report the result.",
human_input_mode="NEVER",
code_execution_config={
"last_n_messages": 3,
"work_dir": ,
: ,
},
)


