Agentic Patterns项目:包含Andrew Ng在其 DeepLearning.AI博客文章系列中定义的4种Agentic模式的从头实现,主打去框架化:没有 LangChain,没有 LangGraph,没有 LlamaIndex,没有 CrewAI。对LLM API 调用纯粹而简单。
反思模式:Reflection Pattern
这是一个非常基本的模式,但尽管它很简单,它却为LLM响应带来了令人惊讶的性能提升。
它允许大模型反思其结果,建议修改、添加、改进写作风格等。
BASE_GENERATION_SYSTEM_PROMPT = """
Your task is to Generate the best content possible for the user's request.
If the user provides critique, respond with a revised version of your previous attempt.
You must always output the revised content.
"""
BASE_REFLECTION_SYSTEM_PROMPT = """
You are tasked with generating critique and recommendations to the user's generated content.
If the user content has something wrong or something to be improved, output a list of recommendations
and critiques. If the user content is ok and there's nothing to change, output this: <OK>
"""
工具模式(Tool Pattern)
LLM 权重中存储的信息(通常)不足以对我们的问题提供准确而有见地的答案
这就是为什么我们需要为大模型提供接触外部世界的途径
实际上,可以构建任何你想要的工具(归根结底,它们只是 LLM 可以使用的功能),一个工具可以让你访问维基百科,另一个工具可以分析 YouTube 视频的内容或计算 Wolfram Alpha 中的困难积分。
TOOL_SYSTEM_PROMPT = """
You are a function calling AI model. You are provided with function signatures within <tools></tools> XML tags.
You may call one or more functions to assist with the user query. Don't make assumptions about what values to plug
into functions. Pay special attention to the properties 'types'. You should use those types as in a Python dict.
For each function call return a json object with function name and arguments within <tool_call></tool_call>
XML tags as follows:
<tool_call>
{"name": <function-name>,"arguments": <args-dict>, "id": <monotonically-increasing-id>}
</tool_call>
Here are the available tools:
<tools>
%s
</tools>
"""
规划模式(Planning Pattern)
经过上述两步,已经看到了能够反思和使用工具来访问外部世界的智能体。但是......规划呢,即决定按照什么步骤顺序来完成一项大任务?
这正是规划模式所提供的:让 LLM 将任务分解为更小、更容易实现的子目标,而不会忘记最终目标。
规划模式最典型的例子是ReAct技术:
REACT_SYSTEM_PROMPT = """
You are a function calling AI model. You operate by running a loop with the following steps: Thought, Action, Observation.
You are provided with function signatures within <tools></tools> XML tags.
You may call one or more functions to assist with the user query. Don' make assumptions about what values to plug
into functions. Pay special attention to the properties 'types'. You should use those types as in a Python dict.
For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags as follows:
<tool_call>
{"name": <function-name>,"arguments": <args-dict>, "id": <monotonically-increasing-id>}
</tool_call>
Here are the available tools / actions:
<tools>
%s
</tools>
Example session:
<question>What's the current temperature in Madrid?</question>
<thought>I need to get the current weather in Madrid</thought>
<tool_call>{"name": "get_current_weather","arguments": {"location": "Madrid", "unit": "celsius"}, "id": 0}</tool_call>
You will be called again with this:
<observation>{0: {"temperature": 25, "unit": "celsius"}}</observation>
You then output:
<response>The current temperature in Madrid is 25 degrees Celsius</response>
Additional constraints:
- If the user asks you something unrelated to any of the tools above, answer freely enclosing your answer with <response></response> tags.
"""
多智能体模式(Multiagent Pattern)
相信不少小伙伴都听过crewAI 或 AutoGen 等框架,它们允许您创建多智能体应用程序。
这些框架实现了多智能体模式的不同变体,其中任务被划分为由不同角色执行的较小子任务(例如,一个Agent可以是软件工程师,另一个Agent可以是项目经理等)。
这一模式的实际效果开发ing......
文末讨论:真正的AGI?
真正的AGI的秘密不在于一个万能的模型......而在于一系列针对特定问题空间的明确定义的本体,其中包含许多 AI 模型 + 代码,以在直觉+逻辑护栏之间取得适当的平衡,从而实现Agent推理、规划和决策???
https://www.deeplearning.ai/the-batch/how-agents-can-improve-llm-performance/?ref=dl-staging-website.ghost.io
https://github.com/neural-maze/agentic_patterns
来源 | PaperAgent
标签:主打,function,name,框架,模式,user,LLM,Agentic,arguments From: https://blog.csdn.net/AIBigModel/article/details/142823482