跳到主要內容
Open on GitHub

Grobid

GROBID 是一個機器學習函式庫,用於提取、剖析和重新建構原始文件。

它被設計且期望用於剖析學術論文,在這方面它特別有效。

注意:如果提供給 Grobid 的文章是大型文件(例如,論文),超過一定數量的元素,則可能無法處理。

本頁面涵蓋如何使用 Grobid 來剖析 LangChain 的文章。

安裝

grobid 的安裝在 https://grobid.readthedocs.io/en/latest/Install-Grobid/ 中詳細說明。但是,透過 docker 容器執行 grobid 可能更容易且更少麻煩,如 此處 所記錄。

將 Grobid 與 LangChain 搭配使用

一旦 grobid 安裝並啟動並執行(您可以透過存取 https://127.0.0.1:8070 來檢查),您就可以開始了。

您現在可以使用 GrobidParser 來產生文件

from langchain_community.document_loaders.parsers import GrobidParser
from langchain_community.document_loaders.generic import GenericLoader

#Produce chunks from article paragraphs
loader = GenericLoader.from_filesystem(
"/Users/31treehaus/Desktop/Papers/",
glob="*",
suffixes=[".pdf"],
parser= GrobidParser(segment_sentences=False)
)
docs = loader.load()

#Produce chunks from article sentences
loader = GenericLoader.from_filesystem(
"/Users/31treehaus/Desktop/Papers/",
glob="*",
suffixes=[".pdf"],
parser= GrobidParser(segment_sentences=True)
)
docs = loader.load()

區塊中繼資料將包含邊界框。雖然這些有點難以剖析,但在 https://grobid.readthedocs.io/en/latest/Coordinates-in-PDF/ 中有說明


此頁面是否有幫助?