国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁(yè) > news >正文

成品網(wǎng)站nike源碼1688網(wǎng)絡(luò)推廣團(tuán)隊(duì)哪家好

成品網(wǎng)站nike源碼1688,網(wǎng)絡(luò)推廣團(tuán)隊(duì)哪家好,國(guó)外服務(wù)器加速,廣西網(wǎng)站建設(shè)哪家好Large Language Models (LLMs) 在語(yǔ)義知識(shí)方面表現(xiàn)不錯(cuò),但也有一些不足,如:不能正確計(jì)算數(shù)學(xué)公式、無(wú)法獲取最新知識(shí)新聞 通過 Agents 可以賦予 LLMs 更多能力,讓LLM能夠計(jì)算、上網(wǎng)查詢 agent 簡(jiǎn)單使用 from langchain import …

Large Language Models (LLMs) 在語(yǔ)義知識(shí)方面表現(xiàn)不錯(cuò),但也有一些不足,如:不能正確計(jì)算數(shù)學(xué)公式、無(wú)法獲取最新知識(shí)新聞

通過 Agents 可以賦予 LLMs 更多能力,讓LLM能夠計(jì)算、上網(wǎng)查詢

agent 簡(jiǎn)單使用

from langchain import OpenAI
# 語(yǔ)言模型
llm = OpenAI(
openai_api_key="OPENAI_API_KEY",
temperature=0,
model_name="text-davinci-003"
)from langchain.chains import LLMMathChain
from langchain.agents import Tool
# 能計(jì)算數(shù)學(xué)公式的一個(gè)chain
llm_math = LLMMathChain(llm=llm)# initialize the math tool
math_tool = Tool(
name='Calculator',
func=llm_math.run,
description='Useful for when you need to answer questions about math.' # 描述工具能做什么
)
# when giving tools to LLM, we must pass as list of tools
tools = [math_tool]# 如果 langchain.agents 中有相關(guān)工具,則可以直接使用
#from langchain.agents import load_tools
#tools = load_tools(
#['llm-math'],
#llm=llm
)# 初始化 agent
from langchain.agents import initialize_agent
zero_shot_agent = initialize_agent(agent="zero-shot-react-description", # 無(wú)記憶的agenttools=tools, # tools 中只有math_tool,所以只能做計(jì)算llm=llm,verbose=True, # 顯示執(zhí)行過程max_iterations=3)
zero_shot_agent("what is (4.5*2.1)^2.2?")

上面的 tools 中只有math_tool,所以 zero_shot_agent 只能做計(jì)算,不能回答其它常識(shí)問題,可以在 tools 中添加更多工具,使得 zero_shot_agent 擁有更多能力。

# 可以在 tools 中新增聊天工具
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
prompt = PromptTemplate(
input_variables=["query"],
template="{query}"
)
llm_chain = LLMChain(llm=llm, prompt=prompt)# initialize the LLM tool
llm_tool = Tool(
name='Language Model',
func=llm_chain.run,
description='use this tool for general purpose queries and logic'
)
tools.append(llm_tool)
# reinitialize the agent
zero_shot_agent = initialize_agent(
agent="zero-shot-react-description",
tools=tools,
llm=llm,
verbose=True,
max_iterations=3
)

agent 類型

zero-shot-react-description 無(wú)緩存的方式,聊天是單次的,無(wú)上下文緩存

zero_shot_agent = initialize_agent(
agent="zero-shot-react-description",
tools=tools,
llm=llm,
verbose=True,
max_iterations=3,
)

conversational-react-description 帶緩存

from langchain.memory import ConversationBufferMemorymemory = ConversationBufferMemory(memory_key="chat_history")conversational_agent = initialize_agent(
agent='conversational-react-description',
tools=tools,
llm=llm,
verbose=True,
max_iterations=3,
memory=memory,
)

react-docstore 可以檢索知識(shí)庫(kù),無(wú)緩存

from langchain import Wikipedia
from langchain.agents.react.base import DocstoreExplorerdocstore=DocstoreExplorer(Wikipedia())
tools = [Tool(name="Search", # 信息檢索func=docstore.search, description='search wikipedia'),Tool(name="Lookup", # 匹配相近結(jié)果func=docstore.lookup, description='lookup a term in wikipedia')
]docstore_agent = initialize_agent(tools,llm,agent="react-docstore",verbose=True,max_iterations=3)

self-ask-with-search 將LLM與搜索引擎結(jié)合起來(lái)

from langchain import SerpAPIWrapper# initialize the search chain
search = SerpAPIWrapper(serpapi_api_key='serp_api_key')# create a search tool
tools = [Tool(name="Intermediate Answer",func=search.run,description='google search')]# initialize the search enabled agent
self_ask_with_search = initialize_agent(tools,llm,agent="self-ask-with-search",verbose=True)

參考:
Superpower LLMs with Conversational Agents

http://aloenet.com.cn/news/31394.html

相關(guān)文章:

  • 朝陽(yáng)區(qū)社會(huì)建設(shè)工作室網(wǎng)站高效統(tǒng)籌疫情防控和經(jīng)濟(jì)社會(huì)發(fā)展
  • 網(wǎng)站建設(shè)包括啥千鋒教育培訓(xùn)機(jī)構(gòu)地址
  • web程序設(shè)計(jì)網(wǎng)站開發(fā)工具百度云怎么找資源
  • 莘縣網(wǎng)站建設(shè)最有效的線上推廣方式
  • 設(shè)計(jì)公司logo設(shè)計(jì)大全北京做seo的公司
  • 煙臺(tái)網(wǎng)站建設(shè)力推企匯互聯(lián)見效付款網(wǎng)站維護(hù)的內(nèi)容有哪些
  • 做水果的有什么網(wǎng)站桂林seo顧問
  • 個(gè)人網(wǎng)站建立多少錢陜西seo主管
  • html頁(yè)面模板關(guān)鍵詞優(yōu)化搜索引擎
  • 網(wǎng)站首頁(yè) 模板鄭州seo排名優(yōu)化
  • 公司免費(fèi)網(wǎng)站制作產(chǎn)品推銷
  • 網(wǎng)站維護(hù)工作是做啥web網(wǎng)頁(yè)制作成品
  • 衡水做淘寶網(wǎng)站整合營(yíng)銷網(wǎng)絡(luò)推廣
  • 臨沂網(wǎng)站seo互聯(lián)網(wǎng)營(yíng)銷師考試題庫(kù)
  • 重慶高端網(wǎng)站建設(shè)江蘇搜索引擎優(yōu)化
  • 商丘網(wǎng)站建設(shè)專業(yè)現(xiàn)狀營(yíng)銷策劃與運(yùn)營(yíng)方案
  • 濰坊網(wǎng)站開發(fā)公司秒收錄關(guān)鍵詞代發(fā)
  • 利用帝國(guó)軟件如何做網(wǎng)站qq空間秒贊秒評(píng)網(wǎng)站推廣
  • 網(wǎng)站發(fā)產(chǎn)品ps怎么做產(chǎn)品圖友情貼吧
  • 百度網(wǎng)站沒收錄百度賬戶安全中心
  • 有專門教做蛋糕的網(wǎng)站重慶網(wǎng)站推廣軟件
  • 物流網(wǎng)站建設(shè)哪個(gè)好智慧軟文發(fā)稿平臺(tái)官網(wǎng)
  • 網(wǎng)站一般在哪建設(shè)網(wǎng)絡(luò)推廣人員
  • app界面設(shè)計(jì)流程圖河北搜索引擎優(yōu)化
  • 深圳做網(wǎng)站好的公司外貿(mào)推廣優(yōu)化公司
  • qq怎么做網(wǎng)站客服企業(yè)推廣策略
  • 對(duì)政府網(wǎng)站一體化服務(wù)建設(shè)的需求百度投放廣告一天多少錢
  • 烏魯木齊可以做網(wǎng)站的公司有哪些重慶網(wǎng)站seo教程
  • 網(wǎng)站開發(fā)語(yǔ)言是什么app開發(fā)多少錢
  • 西安企業(yè)網(wǎng)站建設(shè)哪家好怎么用手機(jī)創(chuàng)建網(wǎng)站