Skip to main content

Arxiv

arXiv是一个开放获取的存档,收录了200万篇物理学、数学、计算机科学、定量生物学、定量金融、统计学、电气工程与系统科学以及经济学方面的学术文章。

本笔记本展示了如何将Arxiv.org中的科学文章加载到我们可以在下游使用的文档格式中。

安装

首先,您需要安装arxiv Python包。

#!pip install arxiv

其次,您需要安装PyMuPDF Python包,该包将从arxiv.org网站下载的PDF文件转换为文本格式。

#!pip install pymupdf

示例

ArxivLoader有以下参数:

  • query:用于在Arxiv中查找文档的自由文本
  • 可选参数load_max_docs:默认值为100。使用它来限制下载的文档数量。下载所有100个文档需要时间,因此在实验中使用较小的数字。
  • 可选参数load_all_available_meta:默认值为False。默认情况下,只下载最重要的字段:Published(文档发布/最后更新日期)、Title(标题)、Authors(作者)、Summary(摘要)。如果为True,则还会下载其他字段。
from langchain.document_loaders import ArxivLoader
docs = ArxivLoader(query="1605.08386", load_max_docs=2).load()
len(docs)
docs[0].metadata  # 文档的元信息
    {'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\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.'}
docs[0].page_content[:400]  # 文档内容的所有页面
    'arXiv:1605.08386v1  [math.CO]  26 May 2016\nHEAT-BATH RANDOM WALKS WITH MARKOV BASES\nCAPRICE STANLEY AND TOBIAS WINDISCH\nAbstract. 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 fibers of a\nfixed integer matrix can be bounded from above by a constant. We then study the mixing\nbehaviour of heat-b'