docling-project / docling-project/docling
IndexError in VLM pipeline during table parsing (otsl_parse_texts)
- Dominant language
- Python
- Stars
- 66.4k
- Forks
- 4.8k
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 98
Description
## Summary
`IndexError: list index out of range` occurs in Docling's VLM pipeline during table parsing, specifically in the `otsl_parse_texts` function when processing certain PDF table structures.
## Environment
- **Docling Version**: 2.56.1
- **Python Version**: 3.13.2
- **Operating System**: macOS 25.0.0 (Darwin)
- **Architecture**: arm64 (Apple Silicon)
- **VLM Pipeline**: Granite Docling MLX (Apple Silicon optimized)
## Error Details
### Stack Trace
ndexError: list index out of range
File "/venv/lib/python3.13/site-packages/docling_core/types/doc/utils.py", line 186, in count_down
while tokens[r_idx_iter][c_idx] in which_tokens:
~~~~~~~~~~~~~~~~~~^^^^^^^
File "/venv/lib/python3.13/site-packages/docling_core/types/doc/utils.py", line 236, in otsl_parse_texts
row_span += count_down(
split_row_tokens,
r_idx_iter,
c_idx,
[TableToken.OTSL_UCEL.value, TableToken.OTSL_XCEL.value],
)
File "/venv/lib/python3.13/site-packages/docling_core/types/doc/utils.py", line 276, in parse_otsl_table_content
table_cells, split_row_tokens = otsl_parse_texts(mixed_texts, tokens)
File "/venv/lib/python3.13/site-packages/docling_core/types/doc/document.py", line 5003, in load_from_doctags
table_data = parse_otsl_table_content(full_chunk)
File "/venv/lib/python3.13/site-packages/docling/pipeline/vlm_pipeline.py", line 206, in turn_dt_into_doc
conv_res.document = DoclingDocument.load_from_doctags(doctag_document=doctags_doc)
File "/venv/lib/python3.13/site-packages/docling/pipeline/vlm_pipeline.py", line 142, in assemble_document
conv_res.document = self.turn_dt_into_doc(conv_res)
### Error Location
- **File**: `docling_core/types/doc/utils.py`
- **Function**: `count_down` (line 186)
- **Context**: `otsl_parse_texts` function during table parsing
- **Trigger**: Processing `TableToken.OTSL_UCEL.value` and `TableToken.OTSL_XCEL.value`
## Steps to Reproduce
1. Enable VLM pipeline with Granite Docling model
2. Process a PDF file containing complex table structures
3. The error occurs during the VLM pipeline's table parsing phase
### Test File Details
- **File**: "AEC Standardized Ideal Customer Profiles- H2 2025.pdf"
- **Size**: 8,144,155 bytes (~8.1 MB)
- **VLM Enabled**: True
- **Error Type**: IndexError during table parsing
## Expected Behavior
The VLM pipeline should successfully parse table structures without throwing IndexError exceptions.
## Actual Behavior
The VLM pipeline crashes with `IndexError: list index out of range` when processing certain table structures, specifically when accessing `tokens[r_idx_iter][c_idx]` where the index is out of range.
## Root Cause Analysis
The issue appears to be in the `count_down` function within `otsl_parse_texts` where:
1. The function iterates through `split_row_tokens`
2. It accesses `tokens[r_idx_iter][c_idx]` without proper bounds checking
3. The `r_idx_iter` or `c_idx` values exceed the available indices in the `tokens` list
## Impact
- VLM pipeline fails completely for PDFs with certain table structures
- No graceful fallback mechanism
- Conversion process stops with error instead of continuing
## Suggested Fix
Add bounds checking in the `count_down` function before accessing `tokens[r_idx_iter][c_idx]`:
```python
# In docling_core/types/doc/utils.py, line 186
while (r_idx_iter < len(tokens) and
c_idx < len(tokens[r_idx_iter]) and
tokens[r_idx_iter][c_idx] in which_tokens):
```
## Additional Context
- This error only occurs with VLM pipeline enabled
- The same PDF processes successfully without VLM
- Error is specific to table parsing in the VLM pipeline
- Occurs on Apple Silicon with MLX-optimized Granite model
## Workaround
Currently, the only workaround is to disable VLM for problematic files, which loses the enhanced table structure detection that VLM provides.
Additional Context
This error only occurs with VLM pipeline enabled
The same PDF processes successfully without VLM
Error is specific to table parsing in the VLM pipeline
Occurs on Apple Silicon with MLX-optimized Granite model
Workaround
Currently, the only workaround is to disable VLM for problematic files, which loses the enhanced table structure detection that VLM provides.
Contributor guide
Assessment
This issue has not been assessed yet.