Nougat:结合光学神经网络,引领学术 PDF 文档的智能解析、挖掘学术论文 PDF 的价值
Nougat:结合光学神经网络,引领学术 PDF 文档的智能解析、挖掘学术论文 PDF 的价值
这是 Nougat 的官方存储库,Nougat 是一种学术文档 PDF 解析器,可以理解 LaTeX 数学和表格。
Project page: https://facebookresearch.github.io/nougat/
1.安装
From pip:
From repository:
Note, on Windows: If you want to utilize a GPU, make sure you first install the correct PyTorch version. Follow instructions here
如果您想从 API 调用模型或生成数据集,则会有额外的依赖项。安装通过
pip install "nougat-ocr[api]"
or pip install "nougat-ocr[dataset]"
1.2 获取 PDF 的预测
1.2.1 CLI
To get predictions for a PDF run
目录或文件的路径(其中每行都是 PDF 的路径)也可以作为位置参数传递
The default model tag is 0.1.0-small
. If you want to use the base model, use 0.1.0-base
.
In the output directory every PDF will be saved as a .mmd
file, the lightweight markup language, mostly compatible with Mathpix Markdown (we make use of the LaTeX tables).
Note: On some devices the failure detection heuristic is not working properly. If you experience a lot of
[MISSING_PAGE]
responses, try to run with the--no-skipping
flag. Related: #11, #67
1.2.2 API
With the extra dependencies you use app.py
to start an API. Call
通过向http://127.0.0.1:8503/ predict/发出 POST 请求来获得 PDF 文件的预测。它还接受参数“start”和“stop”,以限制计算选择页码(包括边界)。
响应是一个带有文档标记文本的字符串。
To use the limit the conversion to pages 1 to 5, use the start/stop parameters in the request URL: http://127.0.0.1:8503/predict/?start=1&stop=5
2.Dataset
2.1 生成数据集
To generate a dataset you need
A directory containing the PDFs
A directory containing the
.html
files (processed.tex
files by LaTeXML) with the same folder structureA binary file of pdffigures2 and a corresponding environment variable
export PDFFIGURES_PATH="/path/to/binary.jar"
Next run
Additional arguments include
Finally create a jsonl
file that contains all the image paths, markdown text and meta information.
For each jsonl
file you also need to generate a seek map for faster data loading:
The resulting directory structure can look as follows:
Note that the .mmd
and .json
files in the path/paired/output
(here images
) are no longer required.This can be useful for pushing to a S3 bucket by halving the amount of files.
2.2Training
To train or fine tune a Nougat model, run
2.3 Evaluation
Run
To get the results for the different text modalities, run
2.4 FAQ
Why am I only getting
[MISSING_PAGE]
?Nougat was trained on scientific papers found on arXiv and PMC. Is the document you're processing similar to that?What language is the document in? Nougat works best with English papers, other Latin-based languages might work. Chinese, Russian, Japanese etc. will not work.If these requirements are fulfilled it might be because of false positives in the failure detection, when computing on CPU or older GPUs (#11). Try passing the
--no-skipping
flag for now.Where can I download the model checkpoint from.
They are uploaded here on GitHub in the release section. You can also download them during the first execution of the program. Choose the preferred preferred model by passing
--model 0.1.0-{base,small}
参考链接:https://github.com/facebookresearch/nougat
更多优质内容请关注公号:汀丶人工智能;会提供一些相关的资源和优质文章,免费获取阅读。
版权声明: 本文为 InfoQ 作者【汀丶人工智能】的原创文章。
原文链接:【http://xie.infoq.cn/article/0adcda172ae4b5dd970469ddf】。
本文遵守【CC-BY 4.0】协议,转载请保留原文出处及本版权声明。
评论