# Nougat — Neural Optical Understanding for Academic Documents > Nougat is a visual transformer model from Meta that converts academic PDF pages into structured Markdown, accurately preserving mathematical equations, tables, and text formatting. ## Install Save in your project root: # Nougat — Neural Optical Understanding for Academic Documents ## Quick Use ```bash pip install nougat-ocr # Convert a PDF to Markdown nougat path/to/paper.pdf -o output_dir # Or use the Python API python -c " from nougat import NougatModel from nougat.utils.dataset import LaTeXDataset model = NougatModel.from_pretrained('facebook/nougat-base') model.eval() " ``` ## Introduction Nougat (Neural Optical Understanding for Academic documents using a Generative Transformer) is a model from Meta Research that performs optical character recognition on academic PDF documents. Unlike traditional OCR systems, Nougat understands the visual layout of scientific papers and converts them directly into structured Markdown with LaTeX math notation. ## What Nougat Does - Converts scanned or digital academic PDFs to structured Markdown text - Preserves mathematical equations in LaTeX notation - Extracts tables with proper formatting and alignment - Handles complex multi-column layouts common in academic papers - Processes entire documents page by page with automatic stitching ## Architecture Overview Nougat uses an encoder-decoder transformer architecture based on the Donut model. A Swin Transformer encoder processes the PDF page rendered as an image, producing visual feature representations. An mBART-based text decoder autoregressively generates the Markdown output token by token. The model is trained on a large corpus of paired PDF-source data from arXiv, learning to map visual renderings of academic pages directly to their LaTeX/Markdown source representations. ## Self-Hosting & Configuration - Install via pip from PyPI as the nougat-ocr package - Requires a CUDA GPU with at least 6 GB VRAM for inference - Two model sizes available: base (250M parameters) and small - Processes approximately 2-5 pages per minute on a consumer GPU - API server mode available via nougat_api for batch processing ## Key Features - End-to-end PDF-to-Markdown without intermediate OCR or layout analysis stages - Accurate LaTeX math extraction from rendered equations - Handles degraded scans, watermarks, and complex page layouts - Pre-trained on arXiv papers covering STEM disciplines - Markdown output integrates directly with documentation and note-taking tools ## Comparison with Similar Tools - **Marker** — rule-based PDF converter with broader document support but less math accuracy - **GROBID** — ML-based scientific document parser focused on metadata and structure extraction - **MathPix** — commercial API for math OCR with high accuracy but closed-source - **Docling** — IBM document parser supporting multiple formats but less specialized for math - **Surya** — multilingual OCR focused on text detection and recognition, less academic-specific ## FAQ **Q: Does Nougat work on non-academic PDFs?** A: Nougat is trained primarily on academic papers from arXiv. It may produce reasonable results on other technical documents but is not optimized for general business or legal documents. **Q: How accurate is the math extraction?** A: On the arXiv test set, Nougat achieves high fidelity for inline and display math. Complex multi-line equations and rare symbols may occasionally have errors. **Q: Can Nougat handle scanned paper documents?** A: Yes, since Nougat processes page images directly, it works on both digital and scanned PDFs. Quality depends on scan resolution and clarity. **Q: How does Nougat compare to copy-pasting text from a PDF?** A: Direct copy-paste loses math formatting, table structure, and often introduces character errors. Nougat preserves semantic structure and produces clean, editable Markdown. ## Sources - https://github.com/facebookresearch/nougat - https://arxiv.org/abs/2308.13418 --- Source: https://tokrepo.com/en/workflows/asset-ed1264b8 Author: AI Open Source