Attention Is All You Need

Attention Is All You Need

【免费下载链接】nougat Implementation of Nougat Neural Optical Understanding for Academic Documents 【免费下载链接】nougat 项目地址: https://gitcode.com/gh_mirrors/no/nougat

We propose a new simple network architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence and convolutions entirely.

$$ \text{Attention}(Q, K, V) = \text{softmax}\left(\frac{QK^T}{\sqrt{d_k}}\right)V $$

ModelParametersWMT 2014 EN-DE
Transformer65M28.4 BLEU
RNN (Baseline)76M27.3 BLEU

## 使用指南

### 基础安装

```bash
# PyPI安装
pip install nougat-ocr

# 源码安装
pip install git+https://gitcode.com/gh_mirrors/no/nougat

命令行推理

# 单文件转换
nougat path/to/paper.pdf -o output_dir --model 0.1.0-base

# 批量处理目录
nougat path/to/pdf_dir -o results --batchsize 4 --no-skipping

高级参数调整

# 禁用失败检测(适合低质量PDF)
nougat input.pdf -o out --no-skipping

# 使用CPU全精度模式
nougat input.pdf --full-precision

# 仅转换特定页面
nougat thesis.pdf -p 3-5,7 --model 0.1.0-small

限制与已知问题

  1. 语言支持:主要优化英文,对中文、日文等非拉丁语言支持有限
  2. 非学术文档:在简历、手册等非论文类PDF上性能显著下降
  3. 复杂图表:数学公式识别准确率(~69% BLEU)低于纯文本
  4. 失败检测:部分清晰页面可能被误判为低质量(可通过--no-skipping禁用)
  5. 计算资源:基础模型推理需至少4GB GPU内存

mermaid

模型变体

模型标签大小速度准确率适用场景
0.1.0-small350MB快2×0.92×快速预览、低资源环境
0.1.0-base1.2GB基准1.0×生产环境、高精度需求

扩展与定制

数据集生成

# 1. 分割HTML与PDF页面
python -m nougat.dataset.split_htmls_to_pages \
  --html path/to/htmls --pdfs path/to/pdfs --out paired_data

# 2. 创建训练索引
python -m nougat.dataset.create_index --dir paired_data --out train.jsonl

# 3. 生成Seek Map(加速数据加载)
python -m nougat.dataset.gen_seek train.jsonl

微调训练

# 修改配置文件后启动训练
python train.py --config config/train_nougat.yaml

配置文件关键参数调整:

# config/train_nougat.yaml
max_epochs: 50                # 增加训练轮次
lr: 3e-5                      # 降低学习率
dataset_paths: ["custom_train.jsonl"]  # 自定义数据集
accumulate_grad_batches: 4    # 模拟更大批次

许可证信息

  • 代码:MIT许可证
  • 模型权重:CC-BY-NC 4.0(非商业使用)
  • 训练数据:arXiv/PMC开放获取论文(遵守各自使用条款)

完整许可证文本见仓库LICENSE与LICENSE-MODEL文件

引用格式

@misc{blecher2023nougat,
  title={Nougat: Neural Optical Understanding for Academic Documents},
  author={Lukas Blecher and Guillem Cucurull and Thomas Scialom and Robert Stojnic},
  year={2023},
  eprint={2308.13418},
  archivePrefix={arXiv},
  primaryClass={cs.LG}
}

【免费下载链接】nougat Implementation of Nougat Neural Optical Understanding for Academic Documents 【免费下载链接】nougat 项目地址: https://gitcode.com/gh_mirrors/no/nougat

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值