当前位置: 首页 > news >正文

AI - 浅聊一下基于LangChain的AI Agent

AI - 浅聊一下基于LangChain的AI Agent

大家好,今天我们来聊聊一个很有意思的主题: AI Agent ,就是目前非常流行的所谓的AI智能体。AI的发展日新月异,都2024年末了,如果此时小伙伴们对这个非常火的概念还不清楚的话,似乎有点落伍于时代了,希望今天通过这个短文来普及一下。

ai-langchain-agent

什么是AI Agent?

简单来说,AI Agent 就是一个能够自主进行任务的人工智能系统。它可以理解输入、处理数据并做出决策。比如自动客服机器人就在很多情况下充当AI Agent。AI Agent通过接收用户的指令和信息,利用内置的AI模型或算法进行处理,并提供相应的输出或采取行动。

AI Agent与RAG

RAG(Retrieval-Augmented Generation) 是一种结合检索和生成模型的方法,用来回答复杂问题或者生成内容。它的主要思路是先从一个大型数据库中检索出相关的信息,再用生成模型(比如GPT-3)来生成最终的回答。

Agent与RAG的比较

  1. 处理方式

    • AI Agent:更多是独立执行任务,可能会包括决策过程。它处理的任务可以是广泛的,比如对话、数据处理、业务操作等。
    • RAG:主要用于回答问题或者生成内容,通过检索相关信息然后生成回答。
  2. 优势

    • AI Agent:更通用,可以用于多种任务。适用于自动化操作、实时交互等。
    • RAG:结合了检索和生成的优势,能够回答非常复杂的问题,并且回答质量通常比较高。
  3. 实现难度

    • AI Agent:需要实现框架、决策逻辑、模型集成等,复杂度较高。
    • RAG:实现相对简单一些,主要是将检索和生成模型有效结合。

Agent与RAG的关系

理解AI Agent与RAG(Retrieval-Augmented Generation)的关系以及它们如何一起工作是一个很重要的课题。AI Agent 可以看作是一个更高层次的系统,它能够自主进行任务并做出决策。而 RAG 是一个技术方法,主要用于增强生成模型的能力,使其可以利用从大数据集或知识库中检索到的信息来生成更准确和相关的回答。简而言之,AI Agent可以构建在RAG之上,利用RAG的方法来提升问答和生成任务的效果。

那么为什么要在RAG上构建AI Agent?

  1. 提高优质回答的能力:RAG方法结合了检索和生成的优点,能够从庞大的知识库中检索出相关的信息,再通过生成模型来生成准确的回答。

  2. 保持上下文和连续性:RAG方法可以通过检索到的相关文档来保持对话的上下文和连续性,这对于长对话和复杂问题尤为重要。

  3. 增强多任务处理:AI Agent可以利用RAG来处理多个任务,比如询问问题、提供建议或者执行操作等。

AI Agent的优点和缺点

优点

  1. 自动化:AI Agent可以自动处理很多重复性任务,比如客服、数据分析等,减少人力成本。
  2. 24/7服务:与人类不同,AI Agent可以全天候工作,不受时间限制。
  3. 速度快:处理信息和响应速度非常快,能够即时提供服务。
  4. 数据驱动:能够处理和分析大量数据,从中提取有价值的见解。

缺点

  1. 依赖数据和模型:AI Agent的性能高度依赖于训练数据和模型的质量。如果数据有偏见,结果可能也会有偏见。

  2. 缺乏创造性:AI Agent在处理突发情况和非结构化问题时,往往不如人类灵活。

  3. 隐私问题:处理敏感数据时,存在隐私和安全风险。

用LangChain实现一个基于RAG的AI Agent

通过以下步骤,我们可以基于LangChain和OpenAI实现一个最小化的基于RAG的AI Agent。代码的主要目的是创建一个基于LangChain的AI Agent,该AI Agent能够检索和生成回答,并保持对话的上下文。以下是逐步解析每个部分的内容:

导入所需模块

首先,我们需要导入各种库和模块:

import os
from langchain_openai import ChatOpenAI  # 导入OpenAI聊天模型类
from langchain_openai import OpenAIEmbeddings  # 导入OpenAI嵌入模型类
from langchain_core.vectorstores import InMemoryVectorStore  # 导入内存向量存储类
import bs4  # 导入BeautifulSoup库用于网页解析
from langchain_core.tools import tool  # 导入工具装饰器
from langchain_community.document_loaders import WebBaseLoader  # 导入Web页面加载器
from langchain_text_splitters import RecursiveCharacterTextSplitter  # 导入递归字符文本切分器
from langgraph.checkpoint.memory import MemorySaver  # 导入内存保存器
from langgraph.prebuilt import create_react_agent  # 导入create_react_agent函数

设置API密钥

设置OpenAI的API密钥,这是为了能够使用OpenAI提供的模型和服务:

os.environ["OPENAI_API_KEY"] = 'your-api-key'

初始化嵌入模型和向量存储

初始化OpenAI嵌入模型和内存向量存储,用于后续的文档处理和搜索:

embeddings = OpenAIEmbeddings(model="text-embedding-3-large")
vector_store = InMemoryVectorStore(embeddings)

初始化聊天模型

初始化一个OpenAI的聊天模型,这里使用的是gpt-4o-mini

llm = ChatOpenAI(model="gpt-4o-mini")

加载并切分文档内容

使用WebBaseLoader从指定的网址加载文档内容,并使用BeautifulSoup仅解析指定的部分(如文章内容、标题和头部),然后使用文本切分器来将文档切分成小块:

loader = WebBaseLoader(web_paths=("https://lilianweng.github.io/posts/2023-06-23-agent/",),bs_kwargs=dict(parse_only=bs4.SoupStrainer(class_=("post-content", "post-title", "post-header"))),
)
docs = loader.load()  # 加载文档内容text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200)
all_splits = text_splitter.split_documents(docs)  # 切分文档# 将切分后的文档添加到向量存储
_ = vector_store.add_documents(documents=all_splits)

定义检索工具函数

定义一个用@tool装饰器修饰的检索工具函数,用于根据用户的查询检索相关内容:

@tool(response_format="content_and_artifact")
def retrieve(query: str):"""Retrieve information related to a query."""retrieved_docs = vector_store.similarity_search(query, k=2)  # 从向量存储中检索最相似的2个文档serialized = "\n\n".join((f"Source: {doc.metadata}\n" f"Content: {doc.page_content}")for doc in retrieved_docs)return serialized, retrieved_docs  # 返回序列化内容和检索到的文档

初始化内存保存器和创建反应代理

使用MemorySaver来保存对话状态,并使用create_react_agent函数创建AI Agent:

memory = MemorySaver()  # 初始化内存保存器
agent_executor = create_react_agent(llm, [retrieve], checkpointer=memory)  # 创建AI Agent

指定对话线程ID

指定一个对话的线程ID,用于管理多轮对话:

config = {"configurable": {"thread_id": "def234"}}

示例对话

定义一个输入消息,然后运行AI Agent来处理这个消息,并打印最后的响应:

input_message = ("What is the standard method for Task Decomposition?\n\n""Once you get the answer, look up common extensions of that method."
)for event in agent_executor.stream({"messages": [{"role": "user", "content": input_message}]},stream_mode="values",config=config,
):event["messages"][-1].pretty_print()  # 打印最后一条消息内容

通过这种方式,可以实现一个基于LangChain的最小化AI Agent,它能够智能地响应用户查询,并在对话中保持上下文的一致性。

代码输出

================================ Human Message =================================What is the standard method for Task Decomposition?Once you get the answer, look up common extensions of that method.
================================== Ai Message ==================================
Tool Calls:retrieve (call_HmlIDGfLMemXCh88ut0Fqzxz)Call ID: call_HmlIDGfLMemXCh88ut0FqzxzArgs:query: standard method for Task Decomposition
================================= Tool Message =================================
Name: retrieveSource: {'source': 'https://lilianweng.github.io/posts/2023-06-23-agent/'}
Content: Tree of Thoughts (Yao et al. 2023) extends CoT by exploring multiple reasoning possibilities at each step. It first decomposes the problem into multiple thought steps and generates multiple thoughts per step, creating a tree structure. The search process can be BFS (breadth-first search) or DFS (depth-first search) with each state evaluated by a classifier (via a prompt) or majority vote.
Task decomposition can be done (1) by LLM with simple prompting like "Steps for XYZ.\n1.", "What are the subgoals for achieving XYZ?", (2) by using task-specific instructions; e.g. "Write a story outline." for writing a novel, or (3) with human inputs.Source: {'source': 'https://lilianweng.github.io/posts/2023-06-23-agent/'}
Content: Fig. 1. Overview of a LLM-powered autonomous agent system.
Component One: Planning#
A complicated task usually involves many steps. An agent needs to know what they are and plan ahead.
Task Decomposition#
Chain of thought (CoT; Wei et al. 2022) has become a standard prompting technique for enhancing model performance on complex tasks. The model is instructed to “think step by step” to utilize more test-time computation to decompose hard tasks into smaller and simpler steps. CoT transforms big tasks into multiple manageable tasks and shed lights into an interpretation of the model’s thinking process.
================================== Ai Message ==================================
Tool Calls:retrieve (call_gk1TfyTqR131FuctblLrjkz4)Call ID: call_gk1TfyTqR131FuctblLrjkz4Args:query: common extensions of Task Decomposition methods
================================= Tool Message =================================
Name: retrieveSource: {'source': 'https://lilianweng.github.io/posts/2023-06-23-agent/'}
Content: Tree of Thoughts (Yao et al. 2023) extends CoT by exploring multiple reasoning possibilities at each step. It first decomposes the problem into multiple thought steps and generates multiple thoughts per step, creating a tree structure. The search process can be BFS (breadth-first search) or DFS (depth-first search) with each state evaluated by a classifier (via a prompt) or majority vote.
Task decomposition can be done (1) by LLM with simple prompting like "Steps for XYZ.\n1.", "What are the subgoals for achieving XYZ?", (2) by using task-specific instructions; e.g. "Write a story outline." for writing a novel, or (3) with human inputs.Source: {'source': 'https://lilianweng.github.io/posts/2023-06-23-agent/'}
Content: Fig. 1. Overview of a LLM-powered autonomous agent system.
Component One: Planning#
A complicated task usually involves many steps. An agent needs to know what they are and plan ahead.
Task Decomposition#
Chain of thought (CoT; Wei et al. 2022) has become a standard prompting technique for enhancing model performance on complex tasks. The model is instructed to “think step by step” to utilize more test-time computation to decompose hard tasks into smaller and simpler steps. CoT transforms big tasks into multiple manageable tasks and shed lights into an interpretation of the model’s thinking process.
================================== Ai Message ==================================The standard method for Task Decomposition involves a technique known as the Chain of Thought (CoT), which enhances model performance on complex tasks by instructing it to "think step by step." This allows the model to break down large tasks into smaller, more manageable steps. Task decomposition can be achieved through various means, such as:1. **Simple Prompting**: Using prompts like "Steps for XYZ." or "What are the subgoals for achieving XYZ?"
2. **Task-Specific Instructions**: Providing specific instructions tailored to the task, e.g., "Write a story outline." for writing a novel.
3. **Human Inputs**: Involving human guidance in the decomposition process.### Common Extensions of Task Decomposition Methods
One notable extension of the standard method is the **Tree of Thoughts** (Yao et al. 2023). This method builds upon CoT by exploring multiple reasoning possibilities at each step. It decomposes the problem into various thought steps and generates multiple thoughts for each step, forming a tree structure. The search process can utilize either breadth-first search (BFS) or depth-first search (DFS), with each state being evaluated by a classifier or majority vote.Thus, while the Chain of Thought is the foundational method, the Tree of Thoughts represents an advanced extension that allows for a more nuanced exploration of tasks.

重点解释

让我们详细解释一下create_react_agentagent_executor在上面代码中的作用和实现。

create_react_agent

create_react_agent 是一个预构建的方法,用于创建一个反应式(reactive)的AI Agent。这个Agent能够根据特定的查询和工具来生成响应。在这个方法中,我们会整合一个语言模型(LLM)和一组工具,并添加一个检查点(Checkpointer)来维护对话的状态。

以下是这个方法的详细解释:

from langgraph.prebuilt import create_react_agent# 使用已定义的工具和语言模型创建一个反应式的AI Agent
agent_executor = create_react_agent(llm, [retrieve], checkpointer=memory)
参数解释:
  • llm: 这个参数传递了一个大语言模型,这里是ChatOpenAI,它是用于生成自然语言回答的核心组件。
  • tools: 一个工具列表,这里传递了retrieve工具。这个工具是用来进行文档检索的,可以基于用户的查询,从存储的文档中找到相关内容。
  • checkpointer: 传递了一个MemorySaver实例,用于保存和加载对话的状态。这个组件确保了即使在对话中断后,也可以恢复之前的对话状态。

agent_executor

agent_executor 是通过 create_react_agent 创建的AI Agent执行器,它能够接收用户的输入,利用预定义的工具和语言模型生成对应的回答,并管理对话状态。

以下是这个执行器的详细解释和使用示例:

# Specify an ID for the thread
config = {"configurable": {"thread_id": "def234"}}input_message = ("What is the standard method for Task Decomposition?\n\n""Once you get the answer, look up common extensions of that method."
)for event in agent_executor.stream({"messages": [{"role": "user", "content": input_message}]},stream_mode="values",config=config,
):event["messages"][-1].pretty_print()
流程解释:
  1. 配置线程ID:

    • config = {"configurable": {"thread_id": "def234"}}:这里指定了一个线程ID,用于管理特定对话线程的状态。
  2. 定义输入消息:

    • input_message定义了用户的输入,包括两个部分:请求标准的任务分解方法,然后查询这个方法的常见扩展。
  3. 执行对话流:

    for event in agent_executor.stream(...):启动AI Agent的对话流。

    • messages: 包含了用户输入信息的字典列表,每个字典表示一条消息。
    • stream_mode="values": 配置流式输出模式。
    • config: 传递配置选项,这里主要传递了线程ID。
  4. 处理和输出每个事件:

    • event["messages"][-1].pretty_print():对于每个事件,输出对话流末尾的消息内容(即AI生成的回复)。

代码总结

通过创建一个反应式的AI Agent (agent_executor),并结合了文档检索工具 (retrieve) 和大语言模型 (llm), 使得整个AI系统能够:

  1. 接收用户的查询。
  2. 通过工具从存储的文档中检索相关信息。
  3. 使用语言模型生成自然语言回答。
  4. 管理对话状态,使得多轮对话能够连贯进行。

这种设计实现了检索增强生成(RAG)架构的功能,既利用了检索模块带来的丰富上下文信息,又结合了生成模型的灵活应答能力,为用户提供更精准和个性化的服务。

LLM消息抓取

ai-langchain-agent-llm

交互1

请求
{"messages": [[{"lc": 1,"type": "constructor","id": ["langchain","schema","messages","HumanMessage"],"kwargs": {"content": "What is the standard method for Task Decomposition?\n\nOnce you get the answer, look up common extensions of that method.","type": "human","id": "bb39ed14-f51d-48cc-ac4c-e4eeefffaf55"}}]]
}
回复
{"generations": [[{"text": "","generation_info": {"finish_reason": "tool_calls","logprobs": null},"type": "ChatGeneration","message": {"lc": 1,"type": "constructor","id": ["langchain","schema","messages","AIMessage"],"kwargs": {"content": "","additional_kwargs": {"tool_calls": [{"id": "call_HmlIDGfLMemXCh88ut0Fqzxz","function": {"arguments": "{\"query\":\"standard method for Task Decomposition\"}","name": "retrieve"},"type": "function"}],"refusal": null},"response_metadata": {"token_usage": {"completion_tokens": 18,"prompt_tokens": 67,"total_tokens": 85,"completion_tokens_details": {"accepted_prediction_tokens": 0,"audio_tokens": 0,"reasoning_tokens": 0,"rejected_prediction_tokens": 0},"prompt_tokens_details": {"audio_tokens": 0,"cached_tokens": 0}},"model_name": "gpt-4o-mini-2024-07-18","system_fingerprint": "fp_bba3c8e70b","finish_reason": "tool_calls","logprobs": null},"type": "ai","id": "run-1992178b-d402-49b0-9c2b-6087ab5c2535-0","tool_calls": [{"name": "retrieve","args": {"query": "standard method for Task Decomposition"},"id": "call_HmlIDGfLMemXCh88ut0Fqzxz","type": "tool_call"}],"usage_metadata": {"input_tokens": 67,"output_tokens": 18,"total_tokens": 85,"input_token_details": {"audio": 0,"cache_read": 0},"output_token_details": {"audio": 0,"reasoning": 0}},"invalid_tool_calls": []}}}]],"llm_output": {"token_usage": {"completion_tokens": 18,"prompt_tokens": 67,"total_tokens": 85,"completion_tokens_details": {"accepted_prediction_tokens": 0,"audio_tokens": 0,"reasoning_tokens": 0,"rejected_prediction_tokens": 0},"prompt_tokens_details": {"audio_tokens": 0,"cached_tokens": 0}},"model_name": "gpt-4o-mini-2024-07-18","system_fingerprint": "fp_bba3c8e70b"},"run": null,"type": "LLMResult"
}

交互2

请求
{"messages": [[{"lc": 1,"type": "constructor","id": ["langchain","schema","messages","HumanMessage"],"kwargs": {"content": "What is the standard method for Task Decomposition?\n\nOnce you get the answer, look up common extensions of that method.","type": "human","id": "bb39ed14-f51d-48cc-ac4c-e4eeefffaf55"}},{"lc": 1,"type": "constructor","id": ["langchain","schema","messages","AIMessage"],"kwargs": {"content": "","additional_kwargs": {"tool_calls": [{"id": "call_HmlIDGfLMemXCh88ut0Fqzxz","function": {"arguments": "{\"query\":\"standard method for Task Decomposition\"}","name": "retrieve"},"type": "function"}],"refusal": null},"response_metadata": {"token_usage": {"completion_tokens": 18,"prompt_tokens": 67,"total_tokens": 85,"completion_tokens_details": {"accepted_prediction_tokens": 0,"audio_tokens": 0,"reasoning_tokens": 0,"rejected_prediction_tokens": 0},"prompt_tokens_details": {"audio_tokens": 0,"cached_tokens": 0}},"model_name": "gpt-4o-mini-2024-07-18","system_fingerprint": "fp_bba3c8e70b","finish_reason": "tool_calls","logprobs": null},"type": "ai","id": "run-1992178b-d402-49b0-9c2b-6087ab5c2535-0","tool_calls": [{"name": "retrieve","args": {"query": "standard method for Task Decomposition"},"id": "call_HmlIDGfLMemXCh88ut0Fqzxz","type": "tool_call"}],"usage_metadata": {"input_tokens": 67,"output_tokens": 18,"total_tokens": 85,"input_token_details": {"audio": 0,"cache_read": 0},"output_token_details": {"audio": 0,"reasoning": 0}},"invalid_tool_calls": []}},{"lc": 1,"type": "constructor","id": ["langchain","schema","messages","ToolMessage"],"kwargs": {"content": "Source: {'source': 'https://lilianweng.github.io/posts/2023-06-23-agent/'}\nContent: Tree of Thoughts (Yao et al. 2023) extends CoT by exploring multiple reasoning possibilities at each step. It first decomposes the problem into multiple thought steps and generates multiple thoughts per step, creating a tree structure. The search process can be BFS (breadth-first search) or DFS (depth-first search) with each state evaluated by a classifier (via a prompt) or majority vote.\nTask decomposition can be done (1) by LLM with simple prompting like \"Steps for XYZ.\\n1.\", \"What are the subgoals for achieving XYZ?\", (2) by using task-specific instructions; e.g. \"Write a story outline.\" for writing a novel, or (3) with human inputs.\n\nSource: {'source': 'https://lilianweng.github.io/posts/2023-06-23-agent/'}\nContent: Fig. 1. Overview of a LLM-powered autonomous agent system.\nComponent One: Planning#\nA complicated task usually involves many steps. An agent needs to know what they are and plan ahead.\nTask Decomposition#\nChain of thought (CoT; Wei et al. 2022) has become a standard prompting technique for enhancing model performance on complex tasks. The model is instructed to “think step by step” to utilize more test-time computation to decompose hard tasks into smaller and simpler steps. CoT transforms big tasks into multiple manageable tasks and shed lights into an interpretation of the model’s thinking process.","type": "tool","name": "retrieve","id": "290c729c-60c5-4624-a41f-514c0b67208d","tool_call_id": "call_HmlIDGfLMemXCh88ut0Fqzxz","artifact": [{"lc": 1,"type": "constructor","id": ["langchain","schema","document","Document"],"kwargs": {"id": "e42c541d-e1c7-4023-84a2-bded42cef315","metadata": {"source": "https://lilianweng.github.io/posts/2023-06-23-agent/"},"page_content": "Tree of Thoughts (Yao et al. 2023) extends CoT by exploring multiple reasoning possibilities at each step. It first decomposes the problem into multiple thought steps and generates multiple thoughts per step, creating a tree structure. The search process can be BFS (breadth-first search) or DFS (depth-first search) with each state evaluated by a classifier (via a prompt) or majority vote.\nTask decomposition can be done (1) by LLM with simple prompting like \"Steps for XYZ.\\n1.\", \"What are the subgoals for achieving XYZ?\", (2) by using task-specific instructions; e.g. \"Write a story outline.\" for writing a novel, or (3) with human inputs.","type": "Document"}},{"lc": 1,"type": "constructor","id": ["langchain","schema","document","Document"],"kwargs": {"id": "2511dbdc-2c14-46d7-831f-53182e28d607","metadata": {"source": "https://lilianweng.github.io/posts/2023-06-23-agent/"},"page_content": "Fig. 1. Overview of a LLM-powered autonomous agent system.\nComponent One: Planning#\nA complicated task usually involves many steps. An agent needs to know what they are and plan ahead.\nTask Decomposition#\nChain of thought (CoT; Wei et al. 2022) has become a standard prompting technique for enhancing model performance on complex tasks. The model is instructed to “think step by step” to utilize more test-time computation to decompose hard tasks into smaller and simpler steps. CoT transforms big tasks into multiple manageable tasks and shed lights into an interpretation of the model’s thinking process.","type": "Document"}}],"status": "success"}}]]
}
回复
{"generations": [[{"text": "","generation_info": {"finish_reason": "tool_calls","logprobs": null},"type": "ChatGeneration","message": {"lc": 1,"type": "constructor","id": ["langchain","schema","messages","AIMessage"],"kwargs": {"content": "","additional_kwargs": {"tool_calls": [{"id": "call_gk1TfyTqR131FuctblLrjkz4","function": {"arguments": "{\"query\":\"common extensions of Task Decomposition methods\"}","name": "retrieve"},"type": "function"}],"refusal": null},"response_metadata": {"token_usage": {"completion_tokens": 19,"prompt_tokens": 414,"total_tokens": 433,"completion_tokens_details": {"accepted_prediction_tokens": 0,"audio_tokens": 0,"reasoning_tokens": 0,"rejected_prediction_tokens": 0},"prompt_tokens_details": {"audio_tokens": 0,"cached_tokens": 0}},"model_name": "gpt-4o-mini-2024-07-18","system_fingerprint": "fp_bba3c8e70b","finish_reason": "tool_calls","logprobs": null},"type": "ai","id": "run-28ca8d6e-c417-4784-a97f-0664b909dcaa-0","tool_calls": [{"name": "retrieve","args": {"query": "common extensions of Task Decomposition methods"},"id": "call_gk1TfyTqR131FuctblLrjkz4","type": "tool_call"}],"usage_metadata": {"input_tokens": 414,"output_tokens": 19,"total_tokens": 433,"input_token_details": {"audio": 0,"cache_read": 0},"output_token_details": {"audio": 0,"reasoning": 0}},"invalid_tool_calls": []}}}]],"llm_output": {"token_usage": {"completion_tokens": 19,"prompt_tokens": 414,"total_tokens": 433,"completion_tokens_details": {"accepted_prediction_tokens": 0,"audio_tokens": 0,"reasoning_tokens": 0,"rejected_prediction_tokens": 0},"prompt_tokens_details": {"audio_tokens": 0,"cached_tokens": 0}},"model_name": "gpt-4o-mini-2024-07-18","system_fingerprint": "fp_bba3c8e70b"},"run": null,"type": "LLMResult"
}

交互3

请求
{"messages": [[{"lc": 1,"type": "constructor","id": ["langchain","schema","messages","HumanMessage"],"kwargs": {"content": "What is the standard method for Task Decomposition?\n\nOnce you get the answer, look up common extensions of that method.","type": "human","id": "bb39ed14-f51d-48cc-ac4c-e4eeefffaf55"}},{"lc": 1,"type": "constructor","id": ["langchain","schema","messages","AIMessage"],"kwargs": {"content": "","additional_kwargs": {"tool_calls": [{"id": "call_HmlIDGfLMemXCh88ut0Fqzxz","function": {"arguments": "{\"query\":\"standard method for Task Decomposition\"}","name": "retrieve"},"type": "function"}],"refusal": null},"response_metadata": {"token_usage": {"completion_tokens": 18,"prompt_tokens": 67,"total_tokens": 85,"completion_tokens_details": {"accepted_prediction_tokens": 0,"audio_tokens": 0,"reasoning_tokens": 0,"rejected_prediction_tokens": 0},"prompt_tokens_details": {"audio_tokens": 0,"cached_tokens": 0}},"model_name": "gpt-4o-mini-2024-07-18","system_fingerprint": "fp_bba3c8e70b","finish_reason": "tool_calls","logprobs": null},"type": "ai","id": "run-1992178b-d402-49b0-9c2b-6087ab5c2535-0","tool_calls": [{"name": "retrieve","args": {"query": "standard method for Task Decomposition"},"id": "call_HmlIDGfLMemXCh88ut0Fqzxz","type": "tool_call"}],"usage_metadata": {"input_tokens": 67,"output_tokens": 18,"total_tokens": 85,"input_token_details": {"audio": 0,"cache_read": 0},"output_token_details": {"audio": 0,"reasoning": 0}},"invalid_tool_calls": []}},{"lc": 1,"type": "constructor","id": ["langchain","schema","messages","ToolMessage"],"kwargs": {"content": "Source: {'source': 'https://lilianweng.github.io/posts/2023-06-23-agent/'}\nContent: Tree of Thoughts (Yao et al. 2023) extends CoT by exploring multiple reasoning possibilities at each step. It first decomposes the problem into multiple thought steps and generates multiple thoughts per step, creating a tree structure. The search process can be BFS (breadth-first search) or DFS (depth-first search) with each state evaluated by a classifier (via a prompt) or majority vote.\nTask decomposition can be done (1) by LLM with simple prompting like \"Steps for XYZ.\\n1.\", \"What are the subgoals for achieving XYZ?\", (2) by using task-specific instructions; e.g. \"Write a story outline.\" for writing a novel, or (3) with human inputs.\n\nSource: {'source': 'https://lilianweng.github.io/posts/2023-06-23-agent/'}\nContent: Fig. 1. Overview of a LLM-powered autonomous agent system.\nComponent One: Planning#\nA complicated task usually involves many steps. An agent needs to know what they are and plan ahead.\nTask Decomposition#\nChain of thought (CoT; Wei et al. 2022) has become a standard prompting technique for enhancing model performance on complex tasks. The model is instructed to “think step by step” to utilize more test-time computation to decompose hard tasks into smaller and simpler steps. CoT transforms big tasks into multiple manageable tasks and shed lights into an interpretation of the model’s thinking process.","type": "tool","name": "retrieve","id": "290c729c-60c5-4624-a41f-514c0b67208d","tool_call_id": "call_HmlIDGfLMemXCh88ut0Fqzxz","artifact": [{"lc": 1,"type": "constructor","id": ["langchain","schema","document","Document"],"kwargs": {"id": "e42c541d-e1c7-4023-84a2-bded42cef315","metadata": {"source": "https://lilianweng.github.io/posts/2023-06-23-agent/"},"page_content": "Tree of Thoughts (Yao et al. 2023) extends CoT by exploring multiple reasoning possibilities at each step. It first decomposes the problem into multiple thought steps and generates multiple thoughts per step, creating a tree structure. The search process can be BFS (breadth-first search) or DFS (depth-first search) with each state evaluated by a classifier (via a prompt) or majority vote.\nTask decomposition can be done (1) by LLM with simple prompting like \"Steps for XYZ.\\n1.\", \"What are the subgoals for achieving XYZ?\", (2) by using task-specific instructions; e.g. \"Write a story outline.\" for writing a novel, or (3) with human inputs.","type": "Document"}},{"lc": 1,"type": "constructor","id": ["langchain","schema","document","Document"],"kwargs": {"id": "2511dbdc-2c14-46d7-831f-53182e28d607","metadata": {"source": "https://lilianweng.github.io/posts/2023-06-23-agent/"},"page_content": "Fig. 1. Overview of a LLM-powered autonomous agent system.\nComponent One: Planning#\nA complicated task usually involves many steps. An agent needs to know what they are and plan ahead.\nTask Decomposition#\nChain of thought (CoT; Wei et al. 2022) has become a standard prompting technique for enhancing model performance on complex tasks. The model is instructed to “think step by step” to utilize more test-time computation to decompose hard tasks into smaller and simpler steps. CoT transforms big tasks into multiple manageable tasks and shed lights into an interpretation of the model’s thinking process.","type": "Document"}}],"status": "success"}},{"lc": 1,"type": "constructor","id": ["langchain","schema","messages","AIMessage"],"kwargs": {"content": "","additional_kwargs": {"tool_calls": [{"id": "call_gk1TfyTqR131FuctblLrjkz4","function": {"arguments": "{\"query\":\"common extensions of Task Decomposition methods\"}","name": "retrieve"},"type": "function"}],"refusal": null},"response_metadata": {"token_usage": {"completion_tokens": 19,"prompt_tokens": 414,"total_tokens": 433,"completion_tokens_details": {"accepted_prediction_tokens": 0,"audio_tokens": 0,"reasoning_tokens": 0,"rejected_prediction_tokens": 0},"prompt_tokens_details": {"audio_tokens": 0,"cached_tokens": 0}},"model_name": "gpt-4o-mini-2024-07-18","system_fingerprint": "fp_bba3c8e70b","finish_reason": "tool_calls","logprobs": null},"type": "ai","id": "run-28ca8d6e-c417-4784-a97f-0664b909dcaa-0","tool_calls": [{"name": "retrieve","args": {"query": "common extensions of Task Decomposition methods"},"id": "call_gk1TfyTqR131FuctblLrjkz4","type": "tool_call"}],"usage_metadata": {"input_tokens": 414,"output_tokens": 19,"total_tokens": 433,"input_token_details": {"audio": 0,"cache_read": 0},"output_token_details": {"audio": 0,"reasoning": 0}},"invalid_tool_calls": []}},{"lc": 1,"type": "constructor","id": ["langchain","schema","messages","ToolMessage"],"kwargs": {"content": "Source: {'source': 'https://lilianweng.github.io/posts/2023-06-23-agent/'}\nContent: Tree of Thoughts (Yao et al. 2023) extends CoT by exploring multiple reasoning possibilities at each step. It first decomposes the problem into multiple thought steps and generates multiple thoughts per step, creating a tree structure. The search process can be BFS (breadth-first search) or DFS (depth-first search) with each state evaluated by a classifier (via a prompt) or majority vote.\nTask decomposition can be done (1) by LLM with simple prompting like \"Steps for XYZ.\\n1.\", \"What are the subgoals for achieving XYZ?\", (2) by using task-specific instructions; e.g. \"Write a story outline.\" for writing a novel, or (3) with human inputs.\n\nSource: {'source': 'https://lilianweng.github.io/posts/2023-06-23-agent/'}\nContent: Fig. 1. Overview of a LLM-powered autonomous agent system.\nComponent One: Planning#\nA complicated task usually involves many steps. An agent needs to know what they are and plan ahead.\nTask Decomposition#\nChain of thought (CoT; Wei et al. 2022) has become a standard prompting technique for enhancing model performance on complex tasks. The model is instructed to “think step by step” to utilize more test-time computation to decompose hard tasks into smaller and simpler steps. CoT transforms big tasks into multiple manageable tasks and shed lights into an interpretation of the model’s thinking process.","type": "tool","name": "retrieve","id": "c7583058-518c-437a-90a0-07c20c11703a","tool_call_id": "call_gk1TfyTqR131FuctblLrjkz4","artifact": [{"lc": 1,"type": "constructor","id": ["langchain","schema","document","Document"],"kwargs": {"id": "e42c541d-e1c7-4023-84a2-bded42cef315","metadata": {"source": "https://lilianweng.github.io/posts/2023-06-23-agent/"},"page_content": "Tree of Thoughts (Yao et al. 2023) extends CoT by exploring multiple reasoning possibilities at each step. It first decomposes the problem into multiple thought steps and generates multiple thoughts per step, creating a tree structure. The search process can be BFS (breadth-first search) or DFS (depth-first search) with each state evaluated by a classifier (via a prompt) or majority vote.\nTask decomposition can be done (1) by LLM with simple prompting like \"Steps for XYZ.\\n1.\", \"What are the subgoals for achieving XYZ?\", (2) by using task-specific instructions; e.g. \"Write a story outline.\" for writing a novel, or (3) with human inputs.","type": "Document"}},{"lc": 1,"type": "constructor","id": ["langchain","schema","document","Document"],"kwargs": {"id": "2511dbdc-2c14-46d7-831f-53182e28d607","metadata": {"source": "https://lilianweng.github.io/posts/2023-06-23-agent/"},"page_content": "Fig. 1. Overview of a LLM-powered autonomous agent system.\nComponent One: Planning#\nA complicated task usually involves many steps. An agent needs to know what they are and plan ahead.\nTask Decomposition#\nChain of thought (CoT; Wei et al. 2022) has become a standard prompting technique for enhancing model performance on complex tasks. The model is instructed to “think step by step” to utilize more test-time computation to decompose hard tasks into smaller and simpler steps. CoT transforms big tasks into multiple manageable tasks and shed lights into an interpretation of the model’s thinking process.","type": "Document"}}],"status": "success"}}]]
}
回复
{"generations": [[{"text": "The standard method for Task Decomposition involves a technique known as the Chain of Thought (CoT), which enhances model performance on complex tasks by instructing it to \"think step by step.\" This allows the model to break down large tasks into smaller, more manageable steps. Task decomposition can be achieved through various means, such as:\n\n1. **Simple Prompting**: Using prompts like \"Steps for XYZ.\" or \"What are the subgoals for achieving XYZ?\"\n2. **Task-Specific Instructions**: Providing specific instructions tailored to the task, e.g., \"Write a story outline.\" for writing a novel.\n3. **Human Inputs**: Involving human guidance in the decomposition process.\n\n### Common Extensions of Task Decomposition Methods\nOne notable extension of the standard method is the **Tree of Thoughts** (Yao et al. 2023). This method builds upon CoT by exploring multiple reasoning possibilities at each step. It decomposes the problem into various thought steps and generates multiple thoughts for each step, forming a tree structure. The search process can utilize either breadth-first search (BFS) or depth-first search (DFS), with each state being evaluated by a classifier or majority vote.\n\nThus, while the Chain of Thought is the foundational method, the Tree of Thoughts represents an advanced extension that allows for a more nuanced exploration of tasks.","generation_info": {"finish_reason": "stop","logprobs": null},"type": "ChatGeneration","message": {"lc": 1,"type": "constructor","id": ["langchain","schema","messages","AIMessage"],"kwargs": {"content": "The standard method for Task Decomposition involves a technique known as the Chain of Thought (CoT), which enhances model performance on complex tasks by instructing it to \"think step by step.\" This allows the model to break down large tasks into smaller, more manageable steps. Task decomposition can be achieved through various means, such as:\n\n1. **Simple Prompting**: Using prompts like \"Steps for XYZ.\" or \"What are the subgoals for achieving XYZ?\"\n2. **Task-Specific Instructions**: Providing specific instructions tailored to the task, e.g., \"Write a story outline.\" for writing a novel.\n3. **Human Inputs**: Involving human guidance in the decomposition process.\n\n### Common Extensions of Task Decomposition Methods\nOne notable extension of the standard method is the **Tree of Thoughts** (Yao et al. 2023). This method builds upon CoT by exploring multiple reasoning possibilities at each step. It decomposes the problem into various thought steps and generates multiple thoughts for each step, forming a tree structure. The search process can utilize either breadth-first search (BFS) or depth-first search (DFS), with each state being evaluated by a classifier or majority vote.\n\nThus, while the Chain of Thought is the foundational method, the Tree of Thoughts represents an advanced extension that allows for a more nuanced exploration of tasks.","additional_kwargs": {"refusal": null},"response_metadata": {"token_usage": {"completion_tokens": 274,"prompt_tokens": 762,"total_tokens": 1036,"completion_tokens_details": {"accepted_prediction_tokens": 0,"audio_tokens": 0,"reasoning_tokens": 0,"rejected_prediction_tokens": 0},"prompt_tokens_details": {"audio_tokens": 0,"cached_tokens": 0}},"model_name": "gpt-4o-mini-2024-07-18","system_fingerprint": "fp_bba3c8e70b","finish_reason": "stop","logprobs": null},"type": "ai","id": "run-4f607e3c-ad2c-41ca-8259-6a6ce3a07c7f-0","usage_metadata": {"input_tokens": 762,"output_tokens": 274,"total_tokens": 1036,"input_token_details": {"audio": 0,"cache_read": 0},"output_token_details": {"audio": 0,"reasoning": 0}},"tool_calls": [],"invalid_tool_calls": []}}}]],"llm_output": {"token_usage": {"completion_tokens": 274,"prompt_tokens": 762,"total_tokens": 1036,"completion_tokens_details": {"accepted_prediction_tokens": 0,"audio_tokens": 0,"reasoning_tokens": 0,"rejected_prediction_tokens": 0},"prompt_tokens_details": {"audio_tokens": 0,"cached_tokens": 0}},"model_name": "gpt-4o-mini-2024-07-18","system_fingerprint": "fp_bba3c8e70b"},"run": null,"type": "LLMResult"
}

小结

ai-quotes-electricity

AI Agent可以被设计为独立完成任务的系统,而RAG是一种用来增强生成模型回答能力的方法。在实际应用中,可以将AI Agent构建在RAG方法之上,从而利用RAG的优点,提升对复杂问题的回答质量和上下文连贯性。通过LangChain,我们可以轻松实现一个最小化的基于RAG的AI Agent,并利用它进行智能问答。希望这篇技术博客对大家有所帮助,如果有更多问题或者讨论,欢迎随时交流!

相关文章:

AI - 浅聊一下基于LangChain的AI Agent

AI - 浅聊一下基于LangChain的AI Agent 大家好,今天我们来聊聊一个很有意思的主题: AI Agent ,就是目前非常流行的所谓的AI智能体。AI的发展日新月异,都2024年末了,如果此时小伙伴们对这个非常火的概念还不清楚的话&a…...

校园综合服务小程序+ssm

摘 要 随着我国经济迅速发展,人们对手机的需求越来越大,各种手机软件也都在被广泛应用,但是对于手机进行数据信息管理,对于手机的各种软件也是备受用户的喜爱,校园综合服务被用户普遍使用,为方便用户能够可…...

RPC设计--TcpConnection和TcpServer

TcpConnection 对于服务端来说用来封装clientfd,对于client端来说,就是封装connect函数返回后的fd. 处理此fd上的读写,因此需要为其提供read\write方法,其方法内部调用系统的read\write函数,从fd中读写数据。 当Fd上…...

Mysql 的 B+ 树是否包含行数据?

在 MySQL 中,是否在 B树 的叶子节点上存储完整的行数据,取决于使用的 存储引擎 和 索引类型: 聚簇索引 (Clustered Index) 叶子节点包含完整的行数据。 适用场景:MySQL InnoDB 存储引擎的主键索引(或聚簇索引&#xf…...

CSS系列(2)-- 盒模型精解

前端技术探索系列:CSS 盒模型精解 📦 致读者:深入理解盒模型的本质 👋 前端开发者们, 今天我们将深入探讨 CSS 盒模型,这是构建网页布局的核心概念。通过本文,你将全面理解盒模型的工作原理及…...

Matlab在信号处理领域有哪些典型的设计实例?

以下是Matlab在信号处理领域的一些典型设计实例: 一、信号生成与频谱分析 正弦信号生成与频谱分析 - 题目:生成一个频率为 f 10 H z f 10Hz f10Hz,采样频率为 f s 100 H z f_s100Hz fs​100Hz,时长为 T 5 s T 5s T5s的正弦…...

frida(objection)中x.ts到x.py封装路径

objection run "android hooking list classes" 基于sensepost/objection.git/1.11.0 sensepost/objection.git/e7eb1 简版路径: android hooking list classes --> show_android_classes --> android_hooking_get_classes androidHookingGetClasses --&g…...

python学习笔记—1—基础环境配置和字面量

1. 字面量 在代码中被写下来的固定值称为字面量 (1)整数字面量 666 (2)浮点字面量 6.66 (3)字符串字面量 "supercarrydoinb" 2. python中的数据类型 3. 打印字面量 print("666") …...

【Windows11系统局域网共享文件数据】

【Windows11系统局域网共享文件数据】 1. 引言1. 规划网络2. 获取必要的硬件3. 设置网络4. 配置网络设备5. 测试网络连接6. 安全性和维护7. 扩展和优化 2. 准备工作2.1: 启用网络发现和文件共享2.2: 设置共享文件夹 3. 访问共享文件夹4. 小贴士5. 总结 1. 引言 随着家庭和小型办…...

包管理器npm, cnpm, yarn 和 pnpm 的命令

npm (Node Package Manager) 安装与更新 npm install 或 npm i: 安装项目依赖:根据 package.json 文件安装所有列出的依赖。参数: -S, --save:保存到 dependencies(默认行为)。-D, --save-dev:…...

MATLAB 最小二乘平面拟合(90)

MATLAB 最小二乘平面拟合(90) 一、算法介绍二、算法实现1.代码2.结果:一、算法介绍 平面方程: ax+by+cz+d = 0 执行任务:读取一组点云(这里用自定义生成的平面模拟点云代替,在其中添加了噪声来模拟真实的数据),使用最小二乘拟合平面,来输出平面参数,并可视化显示拟…...

kubesphere服务报错 页面无法登陆

kubesphere的页面无法访问 查看pod服务,发现ks-apiserver的pod一直在重启 在所在node节点,执行dmesg -T 发现内存溢出 修改deploy的memory的配置 原本的request memory的值为100M 调整为2G 修改之后,服务正常启动,页面访问正常…...

filezilla连接不上虚拟机的解决方案

现象 解决过程 虚拟机终端输入ip addr 输出&#xff1a; 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever p…...

番茄钟与Todo List:用Go构建高效的时间管理工具

引言 在当今快节奏的世界中&#xff0c;时间管理和任务组织变得越来越重要。为了帮助用户提高效率&#xff0c;我开发了一个基于Golang的开源项目&#xff0c;基于fyne的ui&#xff0c;它结合了经典的番茄工作法&#xff08;Pomodoro Technique&#xff09;和功能丰富的待办事…...

vim实用命令整理(常用的命令)

本章教程,总结自己平时使用vim过程中,经常使用的命令,分享给大家。 一、高频使用 i:进入插入模式(光标处插入) a:进入插入模式(光标后插入) esc:返回普通模式 ::进入命令模式 :w:保存 :q:退出 :wq:保存并退出 :q!:强制退出不保存 :e filename:打开文件 :set n…...

METAGPT

METAGPT: META PROGRAMMING FOR A MULTI-AGENT COLLABORATIVE FRAMEWORK MetaGPT&#xff1a;面向多代理协作框架的元编程 1. 引言 近年来&#xff0c;基于大型语言模型&#xff08;LLMs&#xff09;的多智能体系统在自动问题解决方面取得了显著进展。然而&#xff0c;现有的…...

LabVIEW调用Thorlabs的动态库进行开发

Thorlabs 产品在科研与生产领域中的应用广泛&#xff0c;当需要基于LabVIEW 进行二次开发时&#xff0c;可按照以下方法操作&#xff0c;以充分发挥设备性能并满足特定的项目需求。 创建 Kinesis LabVIEW 项目文件和文件夹 更详细的说明参见附件 在 LabVIEW 的启动界面中选择…...

Lua使用点号和冒号的区别

首先建立一个table&#xff0c;再分别定义两个方法&#xff0c;如下&#xff1a; local meta {}function meta:test1(...)print(self)print("")for k,v in pairs({...}) doprint(v)end endfunction meta.test2(...)print(self)print("")for k,v in pairs…...

Rust学习笔记_13——枚举

Rust学习笔记_10——守卫 Rust学习笔记_11——函数 Rust学习笔记_12——闭包 枚举 文章目录 枚举1. 定义1.1 无值变体1.2 有值变体1.3 枚举与泛型的结合 2. 使用2.1 和匹配模式一起使用2.2 枚举作为类型别名 3. 常用枚举类型 在Rust编程语言中&#xff0c;枚举&#xff08;enum…...

集合框架(1)

集合框架&#xff08;1&#xff09; 1、数组的特点与弊端 &#xff08;1&#xff09;特点&#xff1a; 数组初始化以后&#xff0c;长度就确定了。数组中的添加的元素是依次紧密排列的&#xff0c;有序的&#xff0c;可以重复的。数组声明的类型&#xff0c;就决定了进行元素初…...

【Docker系列】Docker 构建多平台镜像:arm64 架构的实践

&#x1f49d;&#x1f49d;&#x1f49d;欢迎来到我的博客&#xff0c;很高兴能够在这里和您见面&#xff01;希望您在这里可以感受到一份轻松愉快的氛围&#xff0c;不仅可以获得有趣的内容和知识&#xff0c;也可以畅所欲言、分享您的想法和见解。 推荐:kwan 的首页,持续学…...

软件工程 概述

软件 不仅仅是一个程序代码。程序是一个可执行的代码&#xff0c;它提供了一些计算的目的。 软件被认为是集合可执行的程序代码&#xff0c;相关库和文档的软件。当满足一个特定的要求&#xff0c;就被称为软件产品。 工程 是所有有关开发的产品&#xff0c;使用良好定义的&…...

汽车产业数字化转型:协同创新破解挑战,平衡安全与流通

在数字经济时代的浪潮中&#xff0c;数据资源和数据信息已成为驱动各行各业转型升级的“新石油”。汽车产业&#xff0c;作为国民经济的重要支柱&#xff0c;正经历着前所未有的变革。随着数字化创新和转型的深入&#xff0c;数据在汽车全产业链中的作用和价值日益凸显。在这个…...

Oracle EBS PAC 如何复修非标任务单生产生非常大的PAC成本?

系统环境 RDBMS : 12.1.0.2.0 Oracle Applications : 12.2.6 问题症状 非标准任务单组件和装配相同物料A,俗称投入A产A。该物料A的期初数量为0。 上期成本假设为20,而本期成本爆增至563.674234。关键问题点: 由于该物料没有期初数量,无法通过“更新定期成本”指定“新期本…...

Docker 学习总结(84)—— Docker 常用运维命令

版本与信息查询 docker --version:查看安装的Docker版本。 docker info:获取Docker系统的详细配置信息。 镜像管理 docker images:列出本地所有镜像。 docker search IMAGE_NAME:搜索Docker Hub上的镜像。 docker pull IMAGE_NAME[:TAG]:从仓库下载指定镜像。 docker rmi …...

【MySQL】存储过程和触发器

MySQL存储过程和触发器 一、存储过程的介绍二、存储过程的相关操作2.1创建存储过程2.2查看存储过程2.4调用存储过程2.5删除存储过程 三、变量3.1系统变量3.2用户定义变量3.3局部变量 四、存储过程中的关键字4.1 if4.2参数4.3case4.4 while4.5repeat4.6 loop4.7游标4.8条件处理程…...

透彻理解并解决Mockito模拟框架的单元测试无法运行的问题

本篇的实例基于Maven IDE (VS Code) 运行 在VS Code 运行的时候&#xff0c; 不需要在pom.xml 中添加任何插件就可以在测试类中看到如下的绿色按钮&#xff0c;单击就可以运行使用Mockito 注解 ExtendWith(MockitoExtension.class) 或是 Mockito 代码方式的测试。 不使用注…...

《掌握Nmap:全面解析网络扫描与安全检测的终极指南》

 nmap # 简介&#xff08;帮助&#xff09; 用法&#xff1a;nmap [扫描类型] [选项] {目标指定内容} 简介&#xff08;帮助&#xff09; 用法&#xff1a;nmap [扫描类型] [选项] {目标指定内容} 一、目标指定&#xff1a; 可以传入主机名、IP 地址、网络等。 例如&a…...

Thonny IDE + MicroPython + ESP32 + LU-ASR01语音识别

LU-ASR01是一款采用深度学习算法的离线语音识别开发板&#xff0c;无需联网即可独立运行。它具备自动识别中文语音输入并进行相应处理的能力。此开发板拥有1路输出的串口TX。该开发板需在天问Block IDE&#xff08;http://twen51.com/new/twen51/index.php&#xff09;中开发&a…...

关闭模组的IP过滤功能

关闭模组的IP过滤功能 关闭模组的IP过滤功能 本脚本用于关闭模组的IP过滤功能&#xff0c;关闭后&#xff0c; 源地址不是终端IP的数据包&#xff0c;也可以被模组转发给网络 关闭模组的IP过滤功能 cat > /usr/bin/ipfilter << "EOF"echo -e "ATCFUN…...

免费下载 | 2024数据资源入表年度发展报告

《2024数据资源入表年度发展报告》的核心内容包括以下几个方面&#xff1a; 总体发展概述&#xff1a; 数据被正式列入五大生产要素之一&#xff0c;标志着中国进入数据要素红利释放阶段。 “数据入表”是指将企业数据资源按会计准则确认、计量&#xff0c;并在财务报表中反映…...

【全网最新】使用 1panel面板 部署若依系统( springboot 和 vue)项目

​​​​​​使用 1panel面板 部署 springboot 和 vue_1panel部署vue项目-CSDN博客 准备工作: 准备好的网站后台代码文件准备好的网站前端页面安装好1panel1panel中安装好mysql1panel中安装好redis1panel中安装好Openresty部署后台接口 在application.yml中修改后台端口,这里…...

基于遗传优化算法的带时间窗多车辆路线规划matlab仿真

目录 1.程序功能描述 2.测试软件版本以及运行结果展示 3.核心程序 4.本算法原理 5.完整程序 1.程序功能描述 基于遗传优化算法的带时间窗多车辆路线规划matlab仿真&#xff0c;通过输入各个节点坐标&#xff0c;以及出发点到节点的时间窗&#xff0c;来进行优化&#xff0…...

MCU、ARM体系结构,单片机基础,单片机操作

计算机基础 计算机的组成 输入设备、输出设备、存储器、运算器、控制器 输入设备&#xff1a;将其他信号转换为计算机可以识别的信号&#xff08;电信号&#xff09;。输出设备&#xff1a;将电信号&#xff08;&#xff10;、&#xff11;&#xff09;转为人或其他设备能理解的…...

黑马点评项目测试总结

黑马点评项目测试面经总结&#xff1a; 一&#xff0c;怎么使用使用Postman进行接口测试&#xff1f; 1&#xff0c;安装Postman 2. 创建请求&#xff1a; 打开Postman&#xff0c;点击"New"按钮创建一个新的请求。在弹出的窗口中&#xff0c;选择请求的类型&#x…...

YOLOv8-ultralytics-8.2.103部分代码阅读笔记-loaders.py

loaders.py ultralytics\data\loaders.py 目录 loaders.py 1.所需的库和模块 2.class SourceTypes: 3.class LoadStreams: 4.class LoadScreenshots: 5.class LoadImagesAndVideos: 6.class LoadPilAndNumpy: 7.class LoadTensor: 8.def autocast_list(source…...

Ubuntu Linux 图形界面工具管理磁盘分区和文件系统(八)

本文为Ubuntu Linux操作系统- 第八弹~~ 今天接着上文的内容&#xff0c;讲Linux磁盘分区存储的相关知识~ 上期回顾&#xff1a;命令行-管理磁盘分区和文件系统 今天看酷酷的雪獒铠甲&#xff01;&#xff01;雪獒铠甲合体~ 文章目录 磁盘管理器GNOME Disks主要功能安装命令 磁盘…...

Windows系统修改文件的默认打开方式的3种方式

文章目录 1.右键打开方式2.属性3.设置-按文件类型打开 1.右键打开方式 2.属性 3.设置-按文件类型打开 word文档 excel表格...

2023 年“泰迪杯”数据分析技能赛B 题企业财务数据分析与造假识别

2023 年“泰迪杯”数据分析技能赛B 题企业财务数据分析与造假识别 一、背景 财务数据是指企业经营活动和财务结果的数据记录&#xff0c;反映了企业的财务状况 与经营成果。对行业、企业的财务数据进行分析&#xff0c;就是要评价其过去的经营业绩、 衡量现在的财务状况、预测…...

数据分析系列---requests的使用

&#x1f308;个人主页&#xff1a;羽晨同学 &#x1f4ab;个人格言:“成为自己未来的主人~” 主环境和虚拟环境 主环境是电脑上安装的python环境 虚拟环境在项目中可以实现环境的隔离&#xff0c;假设DemoA和DemoB分别用到了某个三方库1.0和2.0版本&#xff0c;那么在一个…...

sql删除冗余数据

工作或面试中经常能遇见一种场景题&#xff1a;删除冗余的数据&#xff0c;以下是举例介绍相应的解决办法。 举例&#xff1a; 表结构&#xff1a; 解法1&#xff1a;子查询 获取相同数据中id更小的数据项&#xff0c;再将id不属于其中的数据删除。-- 注意&#xff1a;mysql中…...

ElementUI 问题清单

1、form 下面只有一个 input 时回车键刷新页面 原因是触发了表单默认的提交行为&#xff0c;给el-form 加上submit.native.prevent就行了。 <el-form inline submit.native.prevent><el-form-item label"订单号"><el-inputv-model"query.order…...

uniapp 微信小程序webview 和 h5数据通信

项目是uniapp编写&#xff0c;因为是先开发了h5和app&#xff0c;小程序是突然要用的&#xff0c;做兼容开发已经来不及&#xff0c;由于微信小程序webview载入h5 因为通信必须要特殊限制&#xff08;网页向小程序 postMessage 时&#xff0c;会在以下特定时机触发并收到消息&a…...

3D 生成重建021-LRM基于大模型的生成式3D生成模型

3D 生成重建021-LRM基于大模型的生成式3D生成模型 文章目录 0 论文工作1 论文方法2 实验结果 0 论文工作 论文提出了一种名为大型重建模型 (LRM) 的新型模型&#xff0c;该模型可在短短 5 秒内根据单张输入图像预测物体的 3D 模型。与许多先前仅在 ShapeNet 等小型数据集上进行…...

12.6深度学习_模型优化和迁移_整体流程梳理

七、整体流程梳理 1. 引入使用的包 用到什么包&#xff0c;临时引入就可以&#xff0c;不用太担心。 import time import osimport numpy as np import pandas as pd import torch import torch.nn as nn import torch.optim as optim import torchvision import torchvisio…...

CCF-GESP 编程能力认证 C++ 七级 2024年9月份判断题详细解析

链接&#xff1a;CCF-GESP 编程能力认证 C 七级 2024年9月份选择题详细解析-CSDN博客 目录 第 1 题 第 2 题 第 3 题 第 4 题 第 5 题 第 6 题 第 7 题 第 8 题 第 9 题 第 10 题 第 1 题 表达式 a << 1 的结果为 a&#xff08;错误&#xff09; 【a是字符常…...

ESP32-S3模组上跑通ES8388(20)

接前一篇文章:ESP32-S3模组上跑通ES8388(19) 二、利用ESP-ADF操作ES8388 2. 详细解析 上一回解析完了es8388_init函数中的第7段代码,本回继续往下解析。为了便于理解和回顾,再次贴出es8388_init函数源码,在components\audio_hal\driver\es8388\es8388.c中,如下: ​ …...

UE5.5 Geometry库平面切割原理分析

平面切割--FMeshPlaneCut 平面定义: 面上一个点 法线 算法流程如下 求几何体所有顶点和面的有向距离(Signs) Sign计算&#xff1a; float Sign (VertexPos - PlaneOrigin).Dot(PlaneNormal); 遍历所有几何体所有交叉边, 进行SplitEdge 对于位于切割面两侧的交叉边(Sign…...

JAVAWeb中的Servlet学习

一 Servlet简介 1.1动态资源和静态资源 静态资源 无需在程序运行时通过代码运行生成的资源,在程序运行之前就写好的资源.例如:html css js img ,音频文件和视频文件 动态资源 需要在程序运行时通过代码运行生成的资源,在程序运行之前无法确定的数据,运行时动态生成,例如Servle…...

【Linux】多线程

目录 线程 线程和进程的关系 虚拟地址与物理地址的映射&#xff08;三级映射&#xff09; ​编辑 线程的使用 线程安全 临界资源和临界区 互斥锁 同步与互斥 互斥锁的使用 锁的初始化 加锁与解锁 信号量 信号与信号量的区别 信号量的使用 Lock_guard与unique_lock …...