← all repositories
explosion/spacy-layout

Your spaCy pipeline just learned to read PDFs properly

It bridges Docling and spaCy to turn PDFs and Word documents into structured, layout-aware Doc objects ready for NLP or RAG.

909 stars Python Data ToolingRAG · Search
spacy-layout
Not currently ranked — collecting fresh signals.
star history

What it does

spacy-layout is a spaCy plugin that wraps Docling to ingest PDFs, Word files, and similar documents. It produces spaCy Doc objects where the text is segmented into labelled layout spans—sections, headers, tables—each tagged with bounding boxes and page coordinates. Tables surface as pandas DataFrames, and the whole document retains enough structure to feed straight into entity recognition, classification, or RAG chunking.

The interesting bit

Instead of dumping a blob of extracted text on your pipeline, it keeps the document’s architecture alive inside spaCy’s native data model. That means a named entity recognizer can know whether a span lives under a specific heading and exactly where it sits on the page.

Key highlights

  • Integrates Docling document conversion into a standard spaCy pipeline
  • Exposes layout spans with bounding boxes, page numbers, and nearest-heading references
  • Extracts tables as pandas DataFrames with customizable text representations
  • Supports batch processing via pipe and serialization to spaCy’s binary DocBin format
  • Compatible with any downstream spaCy component, from taggers to transformer models

Caveats

  • Heading detection accuracy depends on document structure, so noisy or unusual layouts may confuse the hierarchy.
  • Deserializing saved Docs requires re-initializing spaCyLayout so custom attributes re-register; the README concedes this workflow is “not elegant” and due for a redesign.

Verdict

Worth a look if you are already invested in spaCy and need structured document understanding for RAG or information extraction. If you just want a standalone PDF-to-markdown converter, use Docling directly and skip the middleware.

Frequently asked

What is explosion/spacy-layout?
It bridges Docling and spaCy to turn PDFs and Word documents into structured, layout-aware Doc objects ready for NLP or RAG.
Is spacy-layout open source?
Yes — explosion/spacy-layout is open source, released under the MIT license.
What language is spacy-layout written in?
explosion/spacy-layout is primarily written in Python.
How popular is spacy-layout?
explosion/spacy-layout has 909 stars on GitHub.
Where can I find spacy-layout?
explosion/spacy-layout is on GitHub at https://github.com/explosion/spacy-layout.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.