Skip to content

Latest commit

 

History

History
173 lines (126 loc) · 2.98 KB

File metadata and controls

173 lines (126 loc) · 2.98 KB

TextStruct — Tech Stack

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

Core Language

Python 3.11+

Why

  • Best ecosystem for document AI
  • Strong vision + LLM tooling
  • Easy experimentation and scripting

PDF & Image Handling

pdf2image

Role

  • Convert image-based PDFs into page images

Pillow (PIL)

Role

  • Image preprocessing for OCR models
  • Resize, normalize, denoise if required

OCR & Document Understanding (Primary)

Transformer-based OCR (LLM-style OCR)

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

Structure Detection (Core Value)

Rule-Based + LLM-Assisted Parsing

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

Chunking Engine (Ingestion-Time)

Custom Semantic Chunker

Role

  • Create stable, reusable chunks
  • Preserve definitions and explanations
  • Avoid arbitrary token splits

Chunk Types

  • Definition
  • Explanation
  • Example
  • Summary (if present)

Metadata Layer

JSON Schema

Role

  • Store structured, LLM-ready data

Metadata Fields

  • Subject
  • Grade / level
  • Chapter
  • Section
  • Content type
  • Page references

Optional Retrieval Layer (Query-Time)

ColPali (Optional, Non-Core)

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

Validation

Manual Review + Scripts

Role

  • Verify structure correctness
  • Validate chunk stability
  • Inspect metadata quality

Explicit Non-Goals (MVP)

  • Chat UI
  • End-user applications
  • Vector database integration
  • Perfect OCR accuracy
  • Full diagram reasoning

Design Philosophy

  • Ingestion > Retrieval
  • Structure > embeddings
  • Deterministic outputs
  • Modular components
  • Text-first, vision-augmented when needed

Future Extensions (Optional)

  • Diagram → text explanation
  • Knowledge graph export
  • Fine-tuning dataset generation
  • Multiple OCR backend support
  • Hybrid retrieval (text + vision)

⚠️ Input textbooks are not included in this repository. Place your own scanned PDFs inside data/input/.