TextStruct converts scanned textbooks into structured, LLM-ready data.
The stack prioritizes:
- Open-source models
- Layout-aware document understanding
- Deterministic ingestion
- Optional multimodal retrieval for science & math
Why
- Best ecosystem for document AI
- Strong vision + LLM tooling
- Easy experimentation and scripting
Role
- Convert image-based PDFs into page images
Role
- Image preprocessing for OCR models
- Resize, normalize, denoise if required
Role
- Extract text with layout awareness
- Preserve headings, paragraphs, math blocks
Examples
- TrOCR
- DocTR
- PaddleOCR (layout modes)
Why
- Significantly better than classic OCR for textbooks
- Handles multi-column layouts
- More robust on science & math content
Notes
- OCR output is still imperfect
- Downstream structuring is expected to fix issues
Role
- Detect:
- Chapters
- Sections
- Subsections
- Clean OCR noise
- Normalize structure
Approach
- Heuristics first (patterns, numbering, casing)
- Optional local LLM pass for ambiguous cases
Design Principle
- LLMs assist, not control, the pipeline
Role
- Create stable, reusable chunks
- Preserve definitions and explanations
- Avoid arbitrary token splits
Chunk Types
- Definition
- Explanation
- Example
- Summary (if present)
Role
- Store structured, LLM-ready data
Metadata Fields
- Subject
- Grade / level
- Chapter
- Section
- Content type
- Page references
Role
- Vision-based retrieval over scanned textbook pages
- Particularly effective for:
- Mathematics
- Physics
- Diagrams
- Equations
How It Fits
- Used at query-time
- Does NOT affect ingestion or chunking
- Complements text-based retrieval
Design Rule
- TextStruct outputs remain usable without ColPali
Role
- Verify structure correctness
- Validate chunk stability
- Inspect metadata quality
- Chat UI
- End-user applications
- Vector database integration
- Perfect OCR accuracy
- Full diagram reasoning
- Ingestion > Retrieval
- Structure > embeddings
- Deterministic outputs
- Modular components
- Text-first, vision-augmented when needed
- Diagram → text explanation
- Knowledge graph export
- Fine-tuning dataset generation
- Multiple OCR backend support
- Hybrid retrieval (text + vision)
data/input/.