跳至主要内容

Grobid

GROBID 是一个用于提取、解析和重构原始文档的机器学习库。

它被设计和期望用于解析学术论文,在解析学术论文方面表现得特别好。注意:如果提供给 Grobid 的文章是大型文档(例如论文),超过一定数量的元素,则可能无法处理。

此加载器使用 Grobid 将 PDF 解析为 Documents,保留与文本部分相关的元数据。


最佳方法是通过 Docker 安装 Grobid,请参阅 https://grobid.readthedocs.io/en/latest/Grobid-docker/

(注意:其他说明可以在 这里找到。)

一旦 grobid 运行起来,就可以像下面描述的那样进行交互。

现在,我们可以使用数据加载器。

from langchain_community.document_loaders.generic import GenericLoader
from langchain_community.document_loaders.parsers import GrobidParser
loader = GenericLoader.from_filesystem(
"../Papers/",
glob="*",
suffixes=[".pdf"],
parser=GrobidParser(segment_sentences=False),
)
docs = loader.load()
docs[3].page_content
'Unlike Chinchilla, PaLM, or GPT-3, we only use publicly available data, making our work compatible with open-sourcing, while most existing models rely on data which is either not publicly available or undocumented (e.g."Books -2TB" or "Social media conversations").There exist some exceptions, notably OPT (Zhang et al., 2022), GPT-NeoX (Black et al., 2022), BLOOM (Scao et al., 2022) and GLM (Zeng et al., 2022), but none that are competitive with PaLM-62B or Chinchilla.'
docs[3].metadata
{'text': 'Unlike Chinchilla, PaLM, or GPT-3, we only use publicly available data, making our work compatible with open-sourcing, while most existing models rely on data which is either not publicly available or undocumented (e.g."Books -2TB" or "Social media conversations").There exist some exceptions, notably OPT (Zhang et al., 2022), GPT-NeoX (Black et al., 2022), BLOOM (Scao et al., 2022) and GLM (Zeng et al., 2022), but none that are competitive with PaLM-62B or Chinchilla.',
'para': '2',
'bboxes': "[[{'page': '1', 'x': '317.05', 'y': '509.17', 'h': '207.73', 'w': '9.46'}, {'page': '1', 'x': '306.14', 'y': '522.72', 'h': '220.08', 'w': '9.46'}, {'page': '1', 'x': '306.14', 'y': '536.27', 'h': '218.27', 'w': '9.46'}, {'page': '1', 'x': '306.14', 'y': '549.82', 'h': '218.65', 'w': '9.46'}, {'page': '1', 'x': '306.14', 'y': '563.37', 'h': '136.98', 'w': '9.46'}], [{'page': '1', 'x': '446.49', 'y': '563.37', 'h': '78.11', 'w': '9.46'}, {'page': '1', 'x': '304.69', 'y': '576.92', 'h': '138.32', 'w': '9.46'}], [{'page': '1', 'x': '447.75', 'y': '576.92', 'h': '76.66', 'w': '9.46'}, {'page': '1', 'x': '306.14', 'y': '590.47', 'h': '219.63', 'w': '9.46'}, {'page': '1', 'x': '306.14', 'y': '604.02', 'h': '218.27', 'w': '9.46'}, {'page': '1', 'x': '306.14', 'y': '617.56', 'h': '218.27', 'w': '9.46'}, {'page': '1', 'x': '306.14', 'y': '631.11', 'h': '220.18', 'w': '9.46'}]]",
'pages': "('1', '1')",
'section_title': 'Introduction',
'section_number': '1',
'paper_title': 'LLaMA: Open and Efficient Foundation Language Models',
'file_path': '/Users/31treehaus/Desktop/Papers/2302.13971.pdf'}

此页面对您有帮助吗?


您也可以在 GitHub 上留下详细的反馈 GitHub.