跳到主要內容

ArXiv

本筆記本介紹如何搭配代理程式使用 arxiv 工具。

首先,您需要安裝 arxiv Python 套件。

%pip install --upgrade --quiet  langchain-community arxiv
from langchain import hub
from langchain.agents import AgentExecutor, create_react_agent, load_tools
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(temperature=0.0)
tools = load_tools(
["arxiv"],
)
prompt = hub.pull("hwchase17/react")

agent = create_react_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
agent_executor.invoke(
{
"input": "What's the paper 1605.08386 about?",
}
)


> Entering new AgentExecutor chain...
I should use the arxiv tool to search for the paper with the given identifier.
Action: arxiv
Action Input: 1605.08386Published: 2016-05-26
Title: Heat-bath random walks with Markov bases
Authors: Caprice Stanley, Tobias Windisch
Summary: Graphs on lattice points are studied whose edges come from a finite set of
allowed moves of arbitrary length. We show that the diameter of these graphs on
fibers of a fixed integer matrix can be bounded from above by a constant. We
then study the mixing behaviour of heat-bath random walks on these graphs. We
also state explicit conditions on the set of moves so that the heat-bath random
walk, a generalization of the Glauber dynamics, is an expander in fixed
dimension.The paper "1605.08386" is titled "Heat-bath random walks with Markov bases" and is authored by Caprice Stanley and Tobias Windisch. It was published on May 26, 2016. The paper discusses the study of graphs on lattice points with edges coming from a finite set of allowed moves. It explores the diameter of these graphs and the mixing behavior of heat-bath random walks on them. The paper also discusses conditions for the heat-bath random walk to be an expander in fixed dimension.
Final Answer: The paper "1605.08386" is about heat-bath random walks with Markov bases.

> Finished chain.
{'input': "What's the paper 1605.08386 about?",
'output': 'The paper "1605.08386" is about heat-bath random walks with Markov bases.'}

ArXiv API 封裝器

此工具使用 API 封裝器。以下,我們將探討它提供的一些功能。

from langchain_community.utilities import ArxivAPIWrapper
API 參考文檔:ArxivAPIWrapper

您可以使用 ArxivAPIWrapper 來取得關於一篇或多篇科學文章的資訊。查詢文字限制為 300 個字元。

ArxivAPIWrapper 會傳回以下文章欄位

  • 發布日期
  • 標題
  • 作者
  • 摘要

以下查詢會傳回 arxiv ID 為 "1605.08386" 的文章資訊。

arxiv = ArxivAPIWrapper()
docs = arxiv.run("1605.08386")
docs
'Published: 2016-05-26\nTitle: Heat-bath random walks with Markov bases\nAuthors: Caprice Stanley, Tobias Windisch\nSummary: Graphs on lattice points are studied whose edges come from a finite set of\nallowed moves of arbitrary length. We show that the diameter of these graphs on\nfibers of a fixed integer matrix can be bounded from above by a constant. We\nthen study the mixing behaviour of heat-bath random walks on these graphs. We\nalso state explicit conditions on the set of moves so that the heat-bath random\nwalk, a generalization of the Glauber dynamics, is an expander in fixed\ndimension.'

現在,我們想要取得關於一位作者 Caprice Stanley 的資訊。

此查詢會傳回關於三篇文章的資訊。預設情況下,查詢只會傳回關於前三篇熱門文章的資訊。

docs = arxiv.run("Caprice Stanley")
docs
'Published: 2017-10-10\nTitle: On Mixing Behavior of a Family of Random Walks Determined by a Linear Recurrence\nAuthors: Caprice Stanley, Seth Sullivant\nSummary: We study random walks on the integers mod $G_n$ that are determined by an\ninteger sequence $\\{ G_n \\}_{n \\geq 1}$ generated by a linear recurrence\nrelation. Fourier analysis provides explicit formulas to compute the\neigenvalues of the transition matrices and we use this to bound the mixing time\nof the random walks.\n\nPublished: 2016-05-26\nTitle: Heat-bath random walks with Markov bases\nAuthors: Caprice Stanley, Tobias Windisch\nSummary: Graphs on lattice points are studied whose edges come from a finite set of\nallowed moves of arbitrary length. We show that the diameter of these graphs on\nfibers of a fixed integer matrix can be bounded from above by a constant. We\nthen study the mixing behaviour of heat-bath random walks on these graphs. We\nalso state explicit conditions on the set of moves so that the heat-bath random\nwalk, a generalization of the Glauber dynamics, is an expander in fixed\ndimension.\n\nPublished: 2003-03-18\nTitle: Calculation of fluxes of charged particles and neutrinos from atmospheric showers\nAuthors: V. Plyaskin\nSummary: The results on the fluxes of charged particles and neutrinos from a\n3-dimensional (3D) simulation of atmospheric showers are presented. An\nagreement of calculated fluxes with data on charged particles from the AMS and\nCAPRICE detectors is demonstrated. Predictions on neutrino fluxes at different\nexperimental sites are compared with results from other calculations.'

現在,我們嘗試尋找不存在的文章資訊。在這種情況下,回應會是 "找不到符合條件的 Arxiv 結果"

docs = arxiv.run("1605.08386WWW")
docs
'No good Arxiv Result was found'

此頁面是否對您有幫助?