Llama 3.2 智能代理开发教程

news2024/10/8 16:19:11

构建研究代理可能很复杂,但使用 LangChain 和 Ollama,它会变得更加简单和模块化。

在本教程中,我们将向你展示如何基于Llama 3.2创建一个研究代理,该代理可以路由查询、执行网络搜索并使用工作流和 LLM 的组合生成详细响应。最后,你将拥有一个功能齐全的代理,可以处理各种信息检索任务!

NSDT工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器 - REVIT导出3D模型插件 - 3D模型语义搜索引擎 - AI模型在线查看 - Three.js虚拟轴心开发包 - 3D模型在线减面 - STL模型在线切割 

1、环境搭建

为了构建我们的研究代理,我们将使用 Ollama 进行 LLM 交互,使用 LangChain 进行工作流管理,使用 LangGraph 定义工作流节点,使用 LangChain 社区库进行扩展功能。对于网络搜索,我们还将使用 duckduckgo-search。

首先安装和配置这些工具。

Ollama 安装步骤

要在你的系统中使用 Ollama,需要安装 Ollama 应用程序,然后在系统中下载 LLama 3.2 模型。

  • 从 Ollama 官方网站下载安装程序。
  • 运行安装程序并按照屏幕上的说明完成设置。 Ollama 支持 MacO 和 Windows。
  • 安装后,可以使用终端运行模型:
  • 打开终端。
  • 导航到安装 Ollama 的目录。
  • 运行以下命令列出可用模型: ollama list
  • 要下载并运行模型,请使用: ollama pull <model_name> 和 ollama run <model_name>

你可以使用 Python 中的以下 pip 命令安装其他库:

!pip install langchain==0.2.12
!pip install langgraph==0.2.2
!pip install langchain-ollama==0.1.1
!pip install langsmith== 0.1.98
!pip install langchain_community​==0.2.11
!pip install duckduckgo-search==6.2.13
导入所需的库
# Displaying final output format
from IPython.display import display, Markdown, Latex
# LangChain Dependencies
from langchain.prompts import PromptTemplate
from langchain_core.output_parsers import JsonOutputParser, StrOutputParser
from langchain_community.chat_models import ChatOllama
from langchain_community.tools import DuckDuckGoSearchRun
from langchain_community.utilities import DuckDuckGoSearchAPIWrapper
from langgraph.graph import END, StateGraph
# For State Graph 
from typing_extensions import TypedDict
import os

2、代码实现

定义要使用的LLM

# Defining LLM
local_llm = 'llama3.2'
llama3 = ChatOllama(model=local_llm, temperature=0)

定义web搜索工具:

# Web Search Tool

wrapper = DuckDuckGoSearchAPIWrapper(max_results=25)
web_search_tool = DuckDuckGoSearchRun(api_wrapper=wrapper)

可以使用如下命令测试工具:

# Test Run
resp = web_search_tool.invoke("current Weather in New York")
print(resp)

Example output:
"East wind around 8 mph. Partly sunny, with a high near 69. Northeast wind around 8 mph. Mostly cloudy, with a low around 59. East wind 3 to 6 mph. Mostly sunny, with a high near 73. Light and variable wind becoming south 5 to 7 mph in the afternoon. Mostly clear, with a low around 60

定义提示词:

# Generation Prompt

generate_prompt = PromptTemplate(
    template="""
    
    <|begin_of_text|>
    
    <|start_header_id|>system<|end_header_id|> 
    
    You are an AI assistant for Research Question Tasks, that synthesizes web search results. 
    Strictly use the following pieces of web search context to answer the question. If you don't know the answer, just say that you don't know. 
    keep the answer concise, but provide all of the details you can in the form of a research report. 
    Only make direct references to material if provided in the context.
    
    <|eot_id|>
    
    <|start_header_id|>user<|end_header_id|>
    
    Question: {question} 
    Web Search Context: {context} 
    Answer: 
    
    <|eot_id|>
    
    <|start_header_id|>assistant<|end_header_id|>""",
    input_variables=["question", "context"],
)

# Chain
generate_chain = generate_prompt | llama3 | StrOutputParser()

# Test Run
question = "who is Yan Lecun?"
context = ""
generation = generate_chain.invoke({"context": context, "question": question})
print(generation)

生成提示模板 ( generate_prompt):

  • 此提示用于代理的生成阶段。
  • 它创建一个模板,其中动态插入来自网络搜索的问题 ( {question}) 和上下文 ( {context})。
  • 该模板指示 AI 助手:
  • 从给定的网络搜索上下文中合成信息。
  • 保持答案简洁而详细,类似于研究报告。
  • 如果提供的上下文中不存在所需信息,只需说“我不知道”。

链配置 ( generate_chain):

  • generate_chain 通过将 generate_prompt 与模型(例如 llama3)和字符串输出解析器 ( StrOutputParser) 链接在一起而形成。
  • 字符串输出解析器确保以纯文本格式返回最终响应。

代码定义了研究代理的生成阶段,其中它使用网络搜索上下文回答用户查询,或者在上下文为空时以“我不知道”响应。这种结构确保以简洁的报告格式提供准确且基于上下文的响应

定义路由提示:

# Router

router_prompt = PromptTemplate(
    template="""
    
    <|begin_of_text|>
    
    <|start_header_id|>system<|end_header_id|>
    
    You are an expert at routing a user question to either the generation stage or web search. 
    Use the web search for questions that require more context for a better answer, or recent events.
    Otherwise, you can skip and go straight to the generation phase to respond.
    You do not need to be stringent with the keywords in the question related to these topics.
    Give a binary choice 'web_search' or 'generate' based on the question. 
    Return the JSON with a single key 'choice' with no premable or explanation. 
    
    Question to route: {question} 
    
    <|eot_id|>
    
    <|start_header_id|>assistant<|end_header_id|>
    
    """,
    input_variables=["question"],
)

# Chain
question_router = router_prompt | llama3_json | JsonOutputParser()

# Test Run
question = "What's up?"
print(question_router.invoke({"question": question}))

路由器提示模板 ( router_prompt):

  • 本节使用 PromptTemplate 类创建提示模板。
  • 模板是格式化的文本,将动态填充特定问题。
  • 它指示助手何时使用网络搜索(针对最近事件或上下文密集型问题)以及何时生成响应(针对一般或上下文无关的查询)。
  • 它强调以 JSON 格式返回 web_search 或 generate 的二元选择。

链配置 ( question_router):

  • question_router 使用 router_prompt 作为输入,并将其与 llama3_json 模型和 JsonOutputParser 链接起来。
  • 管道接受问题,使用指定的 LLM(例如 LLaMA)对其进行处理,并使用单个键将结果解析为 JSON 输出:“choice”,其中 web_search 或 generate 作为值。

定义网络搜索查询转换器提示:

# Query Transformation

query_prompt = PromptTemplate(
    template="""
    
    <|begin_of_text|>
    
    <|start_header_id|>system<|end_header_id|> 
    
    You are an expert at crafting web search queries for research questions.
    More often than not, a user will ask a basic question that they wish to learn more about, however it might not be in the best format. 
    Reword their query to be the most effective web search string possible.
    Return the JSON with a single key 'query' with no premable or explanation. 
    
    Question to transform: {question} 
    
    <|eot_id|>
    
    <|start_header_id|>assistant<|end_header_id|>
    
    """,
    input_variables=["question"],
)

# Chain
query_chain = query_prompt | llama3_json | JsonOutputParser()

# Test Run
question = "What's happened recently with Gaza?"
print(query_chain.invoke({"question": question}))

查询转换提示 ( query_prompt):

  • 此提示专为优化网络搜索查询而设计。
  • 它将用户的随意或基本问题转换为有效的网络搜索字符串,可以检索更多相关信息。
  • 指示 LLM 将问题重新表述为更适合搜索引擎的格式。
  • 响应以 JSON 形式返回,其中包含单个键:查询,不包含任何其他文本。

链配置 ( query_chain):

  • query_chain 将 query_prompt 与语言模型 ( llama3_json) 和 JsonOutputParser 相结合。
  • 此设置允许提示转换查询并以 JSON 格式返回输出。

使用图形状态定义模块化研究代理工作流程:

# Graph State
class GraphState(TypedDict):
    """
    Represents the state of our graph.

    Attributes:
        question: question
        generation: LLM generation
        search_query: revised question for web search
        context: web_search result
    """
    question : str
    generation : str
    search_query : str
    context : str

# Node - Generate

def generate(state):
    """
    Generate answer

    Args:
        state (dict): The current graph state

    Returns:
        state (dict): New key added to state, generation, that contains LLM generation
    """
    
    print("Step: Generating Final Response")
    question = state["question"]
    context = state["context"]

    # Answer Generation
    generation = generate_chain.invoke({"context": context, "question": question})
    return {"generation": generation}

# Node - Query Transformation

def transform_query(state):
    """
    Transform user question to web search

    Args:
        state (dict): The current graph state

    Returns:
        state (dict): Appended search query
    """
    
    print("Step: Optimizing Query for Web Search")
    question = state['question']
    gen_query = query_chain.invoke({"question": question})
    search_query = gen_query["query"]
    return {"search_query": search_query}


# Node - Web Search

def web_search(state):
    """
    Web search based on the question

    Args:
        state (dict): The current graph state

    Returns:
        state (dict): Appended web results to context
    """

    search_query = state['search_query']
    print(f'Step: Searching the Web for: "{search_query}"')
    
    # Web search tool call
    search_result = web_search_tool.invoke(search_query)
    return {"context": search_result}


# Conditional Edge, Routing

def route_question(state):
    """
    route question to web search or generation.

    Args:
        state (dict): The current graph state

    Returns:
        str: Next node to call
    """

    print("Step: Routing Query")
    question = state['question']
    output = question_router.invoke({"question": question})
    if output['choice'] == "web_search":
        print("Step: Routing Query to Web Search")
        return "websearch"
    elif output['choice'] == 'generate':
        print("Step: Routing Query to Generation")
        return "generate"

GraphState 类:

  • GraphState 是一个 TypedDict,它定义了图形工作流中使用的状态字典的结构。
  • 它包括四个键:
  • question:原始用户问题。
  • generation:LLM 生成的最终答案。
  • search_query:针对网络搜索优化的问题。
  • context:用于生成响应的网络搜索结果。

生成节点 (generate):

  • 此函数根据问题和上下文使用 LLM 生成最终响应。
  • 它在图形状态中输出生成键。
  • 打印消息:步骤:生成最终响应以指示其操作。

查询转换节点 (transform_query):

  • 此节点优化用户针对网络搜索的问题。
  • 调用 query_chain 并在状态中输出 search_query 键。
  • 打印消息:步骤:优化网络搜索查询。

网络搜索节点 (web_search):

  • 此节点使用优化查询 (search_query) 执行网络搜索。
  • 使用 Web 搜索工具 (web_search_tool.invoke) 并输出状态中的上下文键。
  • 打印搜索查询和消息:步骤:在 Web 上搜索:“<search_query>”。

条件路由 (route_question):

  • 此函数根据 question_router 做出的决定将问题路由到 web_search 或 generate。
  • 打印消息:步骤:路由查询。
  • 如果选择是 web_search,它将路由到 web_search 节点并打印将查询路由到 Web 搜索。
  • 如果选择是 generate,它将路由到 generate 节点并打印将查询路由到 Generation。

代码片段使用图形状态定义模块化研究代理工作流的核心节点和决策逻辑。每个函数代表工作流中的一个不同步骤,根据要求修改共享状态并通过适当的节点路由问题。最终输出是使用上下文(如果可用)或直接通过 LLM 生成生成的结构良好的响应。

使用 StateGraph 构建基于状态的工作流:

# Build the nodes
workflow = StateGraph(GraphState)
workflow.add_node("websearch", web_search)
workflow.add_node("transform_query", transform_query)
workflow.add_node("generate", generate)

# Build the edges
workflow.set_conditional_entry_point(
    route_question,
    {
        "websearch": "transform_query",
        "generate": "generate",
    },
)
workflow.add_edge("transform_query", "websearch")
workflow.add_edge("websearch", "generate")
workflow.add_edge("generate", END)

# Compile the workflow
local_agent = workflow.compile()

创建 StateGraph 实例(工作流):

  • StateGraph 用于表示研究代理的工作流。
  • 工作流使用 GraphState 类型初始化,确保所有节点都遵循定义的状态结构。

将节点添加到图表:

  • 以下节点已添加到工作流:
  • “websearch”:执行 web_search 函数以执行网络搜索。
  • “transform_query”:执行 transform_query 函数以优化用户问题以进行网络搜索。
  • “generate”:执行 generate 函数以使用 LLM 创建最终响应。

设置条件入口点 (workflow.set_conditional_entry_point):

  • 使用 route_question 函数定义工作流的入口点。
  • 它根据其决定将问题路由到两个节点之一:
  • “websearch”:如果查询需要更多上下文。
  • “generate”:如果不需要网络搜索。

定义工作流边缘:

  • 边缘定义节点之间的流程:
  • “transform_query”->“websearch”:转换查询后,转到网络搜索。
  • “websearch”->“generate”:完成网络搜索后,将结果传递给生成节点。
  • “generate”->END:生成最终响应后,工作流结束。

编译工作流:

  • workflow.compile() 步骤创建一个编译代理 (local_agent),可以调用该代理根据定义的工作流来处理查询。
  • local_agent 将根据定义的逻辑自动执行节点并路由查询。

代码使用 StateGraph 构建基于状态的工作流,其中包含用于查询转换、网络搜索和响应生成的节点。工作流根据预定义的条件自动路由这些节点,确保以最有效的方式处理每个查询以产生高质量的答案。

定义运行Agent的函数:

def run_agent(query):
    output = local_agent.invoke({"question": query})
    print("=======")
    display(Markdown(output["generation"]))

3、测试Agent

示例1:

run_agent("What is Latest news About Open AI?")

输出:

示例2:

run_agent("what is Transformer in AI?")

输出:

4、构建Streamlit应用程序来运行代理

在运行 Streamlit 应用之前,请确保已安装所有必需的库。

打开终端并安装 streamlit

!pip install streamlit 

如果有 requirements.txt 文件,你也可以使用以下命令安装依赖项:

pip install -r requirements.txt

接下来创建一个名为 streamlit_app.py 的新文件(或使用你喜欢的任何其他名称),并将之前提供的完整 Streamlit 代码粘贴到其中。

使用以下代码:

# Displaying final output format
from IPython.display import display, Markdown, Latex
# LangChain Dependencies
from langchain.prompts import PromptTemplate
from langchain_core.output_parsers import JsonOutputParser, StrOutputParser
from langchain_community.chat_models import ChatOllama
from langchain_community.tools import DuckDuckGoSearchRun
from langchain_community.utilities import DuckDuckGoSearchAPIWrapper
from langgraph.graph import END, StateGraph
# For State Graph 
from typing_extensions import TypedDict
import streamlit as st
import os
# Defining LLM
def configure_llm():
    st.sidebar.header("Configure LLM")
    
    # Model Selection
    model_options = ["llama3.2"]
    selected_model = st.sidebar.selectbox("Choose the LLM Model", options=model_options, index=0)
    
    # Temperature Setting
    temperature = st.sidebar.slider("Set the Temperature", min_value=0.0, max_value=1.0, value=0.5, step=0.1)
   
    # Create LLM Instances based on user selection
    llama_model = ChatOllama(model=selected_model, temperature=temperature)
    llama_model_json = ChatOllama(model=selected_model, format='json', temperature=temperature)
    
    return llama_model, llama_model_json

# Streamlit Application Interface
st.title("Personal Research Assistant powered By Llama3.2")
llama3, llama3_json=configure_llm()
wrapper = DuckDuckGoSearchAPIWrapper(max_results=25)
web_search_tool = DuckDuckGoSearchRun(api_wrapper=wrapper)
generate_prompt = PromptTemplate(
    template="""
    
    <|begin_of_text|>
    
    <|start_header_id|>system<|end_header_id|> 
    
    You are an AI assistant for Research Question Tasks, that synthesizes web search results. 
    Strictly use the following pieces of web search context to answer the question. If you don't know the answer, just say that you don't know. 
    keep the answer concise, but provide all of the details you can in the form of a research report. 
    Only make direct references to material if provided in the context.
    
    <|eot_id|>
    
    <|start_header_id|>user<|end_header_id|>
    
    Question: {question} 
    Web Search Context: {context} 
    Answer: 
    
    <|eot_id|>
    
    <|start_header_id|>assistant<|end_header_id|>""",
    input_variables=["question", "context"],
)

# Chain
generate_chain = generate_prompt | llama3 | StrOutputParser()
router_prompt = PromptTemplate(
    template="""
    
    <|begin_of_text|>
    
    <|start_header_id|>system<|end_header_id|>
    
    You are an expert at routing a user question to either the generation stage or web search. 
    Use the web search for questions that require more context for a better answer, or recent events.
    Otherwise, you can skip and go straight to the generation phase to respond.
    You do not need to be stringent with the keywords in the question related to these topics.
    Give a binary choice 'web_search' or 'generate' based on the question. 
    Return the JSON with a single key 'choice' with no premable or explanation. 
    
    Question to route: {question} 
    
    <|eot_id|>
    
    <|start_header_id|>assistant<|end_header_id|>
    
    """,
    input_variables=["question"],
)

# Chain
question_router = router_prompt | llama3_json | JsonOutputParser()

query_prompt = PromptTemplate(
    template="""
    
    <|begin_of_text|>
    
    <|start_header_id|>system<|end_header_id|> 
    
    You are an expert at crafting web search queries for research questions.
    More often than not, a user will ask a basic question that they wish to learn more about, however it might not be in the best format. 
    Reword their query to be the most effective web search string possible.
    Return the JSON with a single key 'query' with no premable or explanation. 
    
    Question to transform: {question} 
    
    <|eot_id|>
    
    <|start_header_id|>assistant<|end_header_id|>
    
    """,
    input_variables=["question"],
)

# Chain
query_chain = query_prompt | llama3_json | JsonOutputParser()
# Graph State
class GraphState(TypedDict):
    """
    Represents the state of our graph.

    Attributes:
        question: question
        generation: LLM generation
        search_query: revised question for web search
        context: web_search result
    """
    question : str
    generation : str
    search_query : str
    context : str

# Node - Generate

def generate(state):
    """
    Generate answer

    Args:
        state (dict): The current graph state

    Returns:
        state (dict): New key added to state, generation, that contains LLM generation
    """
    
    print("Step: Generating Final Response")
    question = state["question"]
    context = state["context"]

    # Answer Generation
    generation = generate_chain.invoke({"context": context, "question": question})
    return {"generation": generation}

# Node - Query Transformation

def transform_query(state):
    """
    Transform user question to web search

    Args:
        state (dict): The current graph state

    Returns:
        state (dict): Appended search query
    """
    
    print("Step: Optimizing Query for Web Search")
    question = state['question']
    gen_query = query_chain.invoke({"question": question})
    search_query = gen_query["query"]
    return {"search_query": search_query}


# Node - Web Search

def web_search(state):
    """
    Web search based on the question

    Args:
        state (dict): The current graph state

    Returns:
        state (dict): Appended web results to context
    """

    search_query = state['search_query']
    print(f'Step: Searching the Web for: "{search_query}"')
    
    # Web search tool call
    search_result = web_search_tool.invoke(search_query)
    return {"context": search_result}


# Conditional Edge, Routing

def route_question(state):
    """
    route question to web search or generation.

    Args:
        state (dict): The current graph state

    Returns:
        str: Next node to call
    """

    print("Step: Routing Query")
    question = state['question']
    output = question_router.invoke({"question": question})
    if output['choice'] == "web_search":
        print("Step: Routing Query to Web Search")
        return "websearch"
    elif output['choice'] == 'generate':
        print("Step: Routing Query to Generation")
        return "generate"
# Build the nodes
workflow = StateGraph(GraphState)
workflow.add_node("websearch", web_search)
workflow.add_node("transform_query", transform_query)
workflow.add_node("generate", generate)

# Build the edges
workflow.set_conditional_entry_point(
    route_question,
    {
        "websearch": "transform_query",
        "generate": "generate",
    },
)
workflow.add_edge("transform_query", "websearch")
workflow.add_edge("websearch", "generate")
workflow.add_edge("generate", END)

# Compile the workflow
local_agent = workflow.compile()
def run_agent(query):
    output = local_agent.invoke({"question": query})
    print("=======")

    return output["generation"]
user_query = st.text_input("Enter your research question:", "")

if st.button("Run Query"):
    if user_query:
        st.write(run_agent(user_query))

将脚本文件保存在你的工作目录中。确保其命名正确,例如: streamlit_app.py

在保存 streamlit_app.py 的同一目录中打开你的终端。

使用以下命令运行 Streamlit 应用程序:

streamlit run streamlit_app.py

一旦应用程序开始运行,默认网络浏览器中将打开一个新选项卡,显示 Streamlit 界面。

或者,你可以手动打开浏览器并转到终端中显示的地址,通常如下所示:

http://localhost:8501/

配置 LLM 模型:

  • 使用侧边栏选项配置 LLM 模型:
  • 选择模型(请记住,必须先从 ollama 网站下载到您的系统中)
  • 使用滑块设置温度。

输入你的查询:

  • 在主界面中,你将看到一个标有“输入您的研究问题:”的文本输入框。
  • 在框中输入您的问题。

运行查询:

  • 单击“运行查询”按钮。
  • 该应用程序将使用配置的工作流程处理您的查询并显示结果。

查看输出:

  • 最终答案将自动显示。

5、结束语

使用 LangChain 和 Streamlit 创建研究代理展示了将模块化工作流与交互式应用程序相结合的强大功能。通过利用基于状态的决策节点和动态 LLM 配置,我们构建了一个能够路由查询、执行 Web 搜索和生成简明研究报告的工具。此设置不仅简化了复杂代理的开发,还为未来的增强提供了灵活性。

随着人工智能的不断发展,集成此类框架对于构建更直观和上下文感知的应用程序至关重要。所以,尝试一下,尝试不同的模型,看看你的研究代理如何针对各种用例进行定制!


原文链接:Llama 3.2 构建智能代理 - BimAnt

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2196735.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

我的书第三次重印啦,做一波活动,参与可抽现金红包~

大家好&#xff0c;我是拭心&#xff0c;好久不见。 四月份我的《Android 性能优化入门与实战》顺利出版&#xff0c;在朋友们帮忙宣传下&#xff0c;初印的两三千册很快卖完&#xff0c;四月份第二次重印&#xff0c;五个月后&#xff0c;又迎来了第三次重印。 这样的销量算不…

如何解决Lenovo笔记本电脑很快就自动休眠,自动锁屏,需要密码登录的问题

前段时间电脑经常会很快就锁屏了&#xff0c;只要离开电脑1分钟不到&#xff0c;就自动锁屏&#xff0c;然后就要输入密码登录&#xff0c;太烦了&#xff0c;后来百度和谷歌了不少帖子和方案&#xff0c;给的建议都是调整电源选项之类的参数。 尝试了各种修改参数&#xff0c…

栈和队列--DS

1. 栈(Stack) 1.1 栈的定义 **栈是一种特殊的线性表&#xff0c;其只允许在固定的一端(栈顶)进行元素插入和删除元素操作。**进行数据插入和删除操作的一段称为栈顶&#xff0c;另一端则称为栈底。栈中的数据元素遵守后进先出LIFO(Last In First Out)原则。 1.2 栈的核心操…

Android 无Bug版 多语言设计方案!

出海业务为什么要做多语言&#xff1f; 1.市场扩大与本地化需求&#xff1a; 通过支持多种语言&#xff0c;出海项目可以触及更广泛的国际用户群体&#xff0c;进而扩大其市场份额。 本地化是吸引国际用户的重要策略之一&#xff0c;而语言本地化是其中的核心。使用用户的母语…

E37.【C语言】动态内存管理练习题

目录 1. 答案速查 分析 源代码分析 反汇编代码分析(底层) 2. 答案速查 分析 3. 答案速查 分析 VS逐步调试 1. 求下列代码的执行结果 #include <stdio.h> char* GetMemory(void) {char p[] "hello world";return p; }void Test(void) {char* str…

软件测试学习笔记丨allure学习指南

本文转自测试人社区&#xff0c;原文链接&#xff1a;https://ceshiren.com/t/topic/32336 安装与下载 需要下载本地文件&#xff0c;并且添加到环境变量里 windows&#xff1a;下载&#xff0c;解压&#xff0c;并配置环境变量 mac&#xff1a;brew install allure 环境变量…

1688代采系统-反向海淘系统详细介绍

Onebound凡邦1688代采系统-反向海淘系统是一种专为海外买家及跨境电商提供一站式采购解决方案的平台。其核心功能和服务旨在解决跨境采购中的语言、货币等常见问题&#xff0c;并优化采购流程&#xff0c;提高采购效率。以下是对该系统的详细介绍。 一、核心功能 商品采集与展…

==与equals比较

在JVM中&#xff0c;内存分为堆内存跟栈内存。他们二者的区别是&#xff1a; 当我们创建一个对象&#xff08;new Object&#xff09;时&#xff0c;就会调用对象的构造函数来开辟空间&#xff0c;将对象数据存储到堆内存中&#xff0c;与此同时在栈内存中生成对应的引用&#…

【AI绘画】如何选择AI绘画工具?Midjourney VS Stable Diffusion?

前言 文章目录 &#x1f4af;如何选择合适的AI绘画工具 个人需求选择比较工具特点社区和资源 &#x1f4af; Midjourney VS Stable Diffusion&#xff1a;深度对比与剖析 使用费用对比使用便捷性与系统兼容性对比开源与闭源对比图片质量对比上手难易对比学习资源对比作品版权…

猎头是这样看简历的?

猎头在看简历时&#xff0c;会遵循一系列高效而系统的步骤&#xff0c;以确保筛选出最适合客户需求的候选人。以下是对猎头如何看简历的详细分析&#xff0c;内容虽无法精确控制在3000字以内&#xff0c;但将尽量精简并涵盖关键信息&#xff1a; 一、初步浏览与筛选 1.基本信…

FLIR AX8 download.php 任意文件读取复现

0x01 产品描述&#xff1a; FLIR-AX8是美国菲力尔公司&#xff08;Teledyne FLIR&#xff09;旗下的一款工业红外热像仪AX8&#xff0c;英文名为Teledyne FLIR AX8 thermal sensor cameras。菲力尔公司专注于设计、开发、生产、营销和推广用于增强态势感知力的专业技术&#xf…

栈与队列面试题(Java数据结构)

前言&#xff1a; 这里举两个典型的例子&#xff0c;实际上该类型的面试题是不确定的&#xff01; 用栈实现队列&#xff1a; 232. 用栈实现队列 - 力扣&#xff08;LeetCode&#xff09; 方法一&#xff1a;双栈 思路 将一个栈当作输入栈&#xff0c;用于压入 push 传入的数…

传统少数民族物品检测系统源码分享

传统少数民族物品检测系统源码分享 [一条龙教学YOLOV8标注好的数据集一键训练_70全套改进创新点发刊_Web前端展示] 1.研究背景与意义 项目参考AAAI Association for the Advancement of Artificial Intelligence 项目来源AACV Association for the Advancement of Computer…

【C语言】分支和循环(3)

&#x1f600;个人主页: 起名字真南 &#x1f601;个人专栏 目录 1 for 循环1.1 语法形式1.2 执行流程图1.3 for循环的实践 2 do-while循环2.1 语法形式2.2 执行流程图2.3 do-while循环的实践 3 break 和 continue 语句4 goto语句 1 for 循环 1.1 语法形式 for循环是三种循环…

【Centos】系统安装虚拟系统管理器创建虚拟机

在windows服务器里使用vmware等工具轻松建立虚拟服务器&#xff0c;可以安装各种操作系统。 在Centos系统中默认安装菜单的系统工具中没有找到这个管理器的启动菜单&#xff0c;默认没有安装。 想使用KVM虚拟系统创建虚拟机如何操作呢&#xff1f;最简单就是下面这些命令&…

ViT(Vision Transformer详解)

Transformer作为前沿的深度学习框架&#xff0c;带有多模态的特性&#xff0c;对于不同类型的输入数据&#xff0c;不管是文本还是图像均可进行处理&#xff0c;而ViT则是对于Transformer中的视觉方面&#xff08;也就是输入数据为图像&#xff09;的衍生物&#xff08;因Trans…

从基础到精通:构建并微调大型语言模型以实现分类任务

本章内容 介绍不同的大型语言模型&#xff08;LLM&#xff09;微调方法准备用于文本分类的数据集修改预训练LLM以便进行微调微调LLM以识别垃圾信息评估微调后的LLM分类器的准确性使用微调后的LLM对新数据进行分类 到目前为止&#xff0c;我们已经编写了LLM的架构、对其进行了…

小程序和h5深度分析

你写过小程序/H5&#xff0c;那你知道他们的区别在哪里吗&#xff1f; 为什么说小程序的性能通常优于 H5? 小程序能访问到 DOM 对象吗&#xff1f; 小程序的原理是什么&#xff1f; 小程序和 H5 都是轻量级的、可直接在移动设备上运行的应用&#xff0c;但它们之间存在一些关…

C语言的类型提升机制

概念 在C语言中&#xff0c;整数类型按照其大小可以分为以下几类&#xff08;从小到大&#xff09;&#xff1a; charshortintlonglong long 当在表达式中涉及这些类型的混合运算时&#xff0c;较小的类型会被提升为较大的类型。具体规则如下&#xff1a; ①char 和 short …

【NLP自然语言处理】02 - NLP简介/NLP发展历史/应用场景

1.什么是自然语言处理 (NLP) 自然语言处理&#xff08;Natural Language Processing, NLP&#xff09;是人工智能的一个重要分支&#xff0c;旨在通过计算机实现对人类自然语言的理解、生成和互动。其核心任务包括分析、生成和转换人类语言&#xff0c;涉及语法、语义、语音识…