6大核心模块(Modules)
示例(Examples)
arXiv

LangChain

ArXiv API工具#

本教程将介绍如何使用arxiv组件。

首先,您需要安装arxiv python软件包。

!pip install arxiv
 
from langchain.chat_models import ChatOpenAI
from langchain.agents import load_tools, initialize_agent, AgentType
 
llm = ChatOpenAI(temperature=0.0)
tools = load_tools(
    ["arxiv"], 
)
 
agent_chain = initialize_agent(
    tools,
    llm,
    agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
    verbose=True,
)
 
agent_chain.run(
    "What's the paper 1605.08386 about?",
)
 
> Entering new AgentExecutor chain...
I need to use Arxiv to search for the paper.
Action: Arxiv
Action Input: "1605.08386"
Observation: Published: 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.
Thought:The paper is about heat-bath random walks with Markov bases on graphs of lattice points.
Final Answer: The paper 1605.08386 is about heat-bath random walks with Markov bases on graphs of lattice points.
 
> Finished chain.
 
'The paper 1605.08386 is about heat-bath random walks with Markov bases on graphs of lattice points.'
 

ArXiv API封装器#

该工具包装了API封装器。下面,我们可以探索它提供的一些功能。

from langchain.utilities import ArxivAPIWrapper
 

运行一个查询以获取有关某篇科学 文章/文章的信息。查询文本限制为300个字符。

它返回这些文章字段:

  • 出版日期

  • 标题

  • 作者

  • 摘要

下一个查询返回有关一个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.  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.  Published: 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'