Extract Thinker
An ORM (Object-Relational Mapping) style library for extracting structured data from documents using Large Language Models. Interact with documents using Pydantic models, just like you interact with databases.
π§ What is Extract Thinker?
Extract Thinker abstracts away the complexity of prompt engineering and document loading. It allows you to define Contracts (your data schema) and lets the library handle the extraction, classification, and validation against multiple document sources (PDFs, Images, etc.).
ORM Style
Pydantic -> Docs
Multi-Loader
OCR, Azure, AWS
Classification
Auto-route files
LLM Agnostic
Any Model
β¨ Key Capabilities
Pydantic Contracts
Define extraction schema using standard Pydantic models. The library guarantees output matches this structure.
Flexible Loaders
Swap between OCR engines (Tesseract, Azure, AWS Textract, Google DocAI) without changing extraction logic.
Document Classification
Automatically classify documents (e.g., "Invoice" vs "Driver License") and route to the correct extractor.
LLM Agnostic
Works with OpenAI, Anthropic, Cohere, and local models via LiteLLM. Optimize for cost or accuracy.
π» Code Example
from extract_thinker import DocumentLoaderPyPdf, Extractor, Contract
from pydantic import Field
# 1. Define your Data Model (The Contract)
class InvoiceContract(Contract):
invoice_number: str = Field(description="The unique number of the invoice")
date: str = Field(description="The date of the invoice")
total_amount: float = Field(description="The total amount to be paid")
vendor_name: str = Field(description="Name of the vendor/company")
# 2. Setup Loader and Extractor
loader = DocumentLoaderPyPdf()
extractor = Extractor()
extractor.load_document(loader, "invoice.pdf")
# 3. Extract!
result = extractor.extract(InvoiceContract)
print(f"Invoice #: {result.invoice_number}")
print(f"Total: ${result.total_amount}")
π― Ideal Use Cases
Financial Parsing
Extracting data from complex Invoices, Receipts, and Financial Statements.
KYC Automation
Extracting fields from ID cards, Passports, and Driver Licenses.
Legal Contracts
Extracting key clauses, dates, and parties from legal agreements.
π Resources
Test Your Knowledge
Score 8/10 or higher to pass
You need to be logged in to take this quiz.
Login to Continue