docling-project / docling-project/docling
All layout models produce empty markdown output with no text content
- Dominant language
- Python
- Stars
- 66.4k
- Forks
- 4.8k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 84
Description
### Bug
All Docling layout models (EGRET_MEDIUM, EGRET_LARGE, EGRET_XLARGE, V2, HERON_101) produce malformed markdown output with empty headers, bullets, and image placeholders when converting PDFs using `export_to_markdown()`.
The output consists primarily of:
- Empty markdown headers (`## \n\n`)
- Empty bullet points (`- \n`)
- Image placeholders (`\n\n`)
- Empty table structures
- No actual text content extracted from the PDF
### Steps to reproduce
1. Set up DocumentConverter with any layout model:
```python
from docling.document_converter import DocumentConverter, PdfFormatOption
from docling.datamodel.pipeline_options import PdfPipelineOptions, LayoutOptions, AcceleratorOptions
from docling.datamodel.base_models import InputFormat
from docling.datamodel.accelerator_options import AcceleratorDevice
from docling.datamodel.layout_model_specs import (
DOCLING_LAYOUT_EGRET_MEDIUM,
DOCLING_LAYOUT_EGRET_LARGE,
DOCLING_LAYOUT_EGRET_XLARGE,
DOCLING_LAYOUT_V2,
DOCLING_LAYOUT_HERON,
DOCLING_LAYOUT_HERON_101
)
# Configure pipeline options
_pipeline_options = PdfPipelineOptions()
_pipeline_options.generate_picture_images = True
_pipeline_options.images_scale = 1.0
_pipeline_options.do_ocr = False
_pipeline_options.do_table_structure = False
_pipeline_options.do_picture_classification = False
_pipeline_options.do_picture_description = False
_pipeline_options.accelerator_options = AcceleratorOptions(
device=AcceleratorDevice.CPU,
num_threads=8,
)
_pipeline_options.layout_options = LayoutOptions(
model_spec=DOCLING_LAYOUT_EGRET_LARGE, # Tried all models - same issue
skip_cell_assignment=True,
create_orphan_clusters=False,
)
# Create converter
doc_converter = DocumentConverter(
format_options={
InputFormat.PDF: PdfFormatOption(pipeline_options=_pipeline_options)
}
)
```
2. Convert a PDF document:
```python
from docling.datamodel.base_models import DocumentStream
from io import BytesIO
# Read PDF file
with open("sample.pdf", "rb") as f:
pdf_bytes = f.read()
buf = BytesIO(pdf_bytes)
source = DocumentStream(name="sample.pdf", stream=buf)
# Convert
result = doc_converter.convert(source)
doc = result.document
# Export to markdown
content = doc.export_to_markdown()
print(content)
```
3. Observe malformed output:
```markdown
##
##
##
##
##
##
##
##
##
##
##
##
-
-
##
##
-
-
-
##
##
##
| ``` ``` |
|------------|
##
##
```
### Expected Behavior
The markdown output should contain:
- Actual text content from the PDF
- Properly formatted headers with text
- Bullet points with content
- Table data (if present)
- Figure captions and descriptions
### Actual Behavior
The markdown output contains only empty structural elements with no text content.
### Additional Context
- **Tested Models**: All available layout models produce the same malformed output expect for the default model:
- `DOCLING_LAYOUT_EGRET_MEDIUM`
- `DOCLING_LAYOUT_EGRET_LARGE`
- `DOCLING_LAYOUT_EGRET_XLARGE`
- `DOCLING_LAYOUT_V2`
- `DOCLING_LAYOUT_HERON_101`
- **Pipeline Settings Tested**:
- OCR disabled: `do_ocr = False`
- Table structure disabled: `do_table_structure = False`
- Layout options: `skip_cell_assignment=True`, `create_orphan_clusters=False`
- **Environment**:
- OS: Windows
- Running in FastAPI service with async execution
- Using ThreadPoolExecutor for document conversion
### Docling version
docling 2.65.0
### Python version
Python 3.12.4
Contributor guide
Assessment
This issue has not been assessed yet.