需设置环境变量 EXTRACT_THINKER_MODEL 并配置对应提供商的 API key;处理 PDF 需额外安装 pypdf 并使用 DocumentLoaderPyPdf,扫描件还需 OCR 或视觉模型;系统 MIME 检测依赖 libmagic;2026 新增功能尚未发布到 PyPI,需从仓库 pip install -e . 安装

ExtractThinker
enoch3712Apache-2.0活跃维护面向 LLM 的文档智能库,用 ORM 风格接口编排文档解析、OCR 与信息抽取流程,让复杂文档工作流更灵活可控。
ExtractThinker is a Document Intelligence library for LLMs, offering ORM-style interaction for flexible and powerful document workflows.
pip install extract-thinkerREADME 未说明具体显存或 GPU 型号要求;可接入 Ollama 本地模型,也可用云端 LLM 提供商。
把文档变成带校验的 Python 对象的 LLM 文档抽取库,定义 Pydantic 契约即可抽取
面向 LLM 的文档智能库,用 ORM 风格接口编排文档解析、OCR 与信息抽取流程,让复杂文档工作流更灵活可控。
核心能力
- 用 Pydantic 契约定义字段、约束与后置校验
- 支持加载 PDF、图片、表格和电子表格
- 可对混合文档包做分类与拆分
- 提供补全策略处理长输入和不完整响应
- 支持 Ollama 本地模型接入
容易踩的坑
- v0.1.14最新正式版2025-06-09 · 2025-06-09 15:42 UTC
What's Changed
- Fixed Local LLM Integration Example in README.md by @iusshpandeh in https://github.com/enoch3712/ExtractThinker/pull/322
- libmagic added to poetry by @enoch3712 in https://github.com/enoch3712/ExtractThinker/pull/331
- Updated README.md with instructions for Windows setup. by @zurich123 in https://github.com/enoch3712/ExtractThinker/pull/328
- Fix deprecation errors in example file by @zurich123 in https://github.com/enoch3712/ExtractThinker/pull/329
- refactor, windows tessaract added to the docs by @enoch3712 in https://github.com/enoch3712/ExtractThinker/pull/333
- Added Receipt Example by @meghana1090 in https://github.com/enoch3712/ExtractThinker/pull/330
- azure documentloader with advance configs by @enoch3712 in https://github.com/enoch3712/ExtractThinker/pull/338
- Added EasyOCR Loader by @meghana1090 in https://github.com/enoch3712/ExtractThinker/pull/337
- [BUG] fix tests and EasyOCR by @enoch3712 in https://github.com/enoch3712/ExtractThinker/pull/340
- [BUG] Litellm: max_tokens no supported by @enoch3712 in https://github.com/enoch3712/ExtractThinker/pull/341
New Contributors
- @iusshpandeh made their first contribution in https://github.com/enoch3712/ExtractThinker/pull/322
- @zurich123 made their first contribution in https://github.com/enoch3712/ExtractThinker/pull/328
- @meghana1090 made their first contribution in https://github.com/enoch3712/ExtractThinker/pull/330
Full Changelog: https://github.com/enoch3712/ExtractThinker/compare/v0.1.13...v0.1.14
- v0.1.132025-04-24 · 2025-04-24 12:33 UTC
查看更新说明
What's Changed
- [HOT FIX] Classification Tree with Id by @enoch3712 in https://github.com/enoch3712/ExtractThinker/pull/318
- markdown image added by @enoch3712 in https://github.com/enoch3712/ExtractThinker/pull/320
Full Changelog: https://github.com/enoch3712/ExtractThinker/compare/v0.1.12...v0.1.13
- v0.1.122025-04-16 · 2025-04-16 13:35 UTC
查看更新说明
What's Changed
- add elements to init by @enoch3712 in https://github.com/enoch3712/ExtractThinker/pull/315
Full Changelog: https://github.com/enoch3712/ExtractThinker/compare/v0.1.11...v0.1.12
- v0.1.112025-04-08 · 2025-04-08 11:52 UTC
查看更新说明
What's Changed
- markdown page selection by @enoch3712 in https://github.com/enoch3712/ExtractThinker/pull/307
Full Changelog: https://github.com/enoch3712/ExtractThinker/compare/v0.1.10...v0.1.11
- v0.1.102025-04-07 · 2025-04-07 13:52 UTC
查看更新说明
What's Changed
- [FEATURE] MARKDOWN and Mistral by @enoch3712 in https://github.com/enoch3712/ExtractThinker/pull/300
- 301 update markdown docs by @enoch3712 in https://github.com/enoch3712/ExtractThinker/pull/302
- poetry update by @enoch3712 in https://github.com/enoch3712/ExtractThinker/pull/303
- [BUG] markdown getting starter NOT FOUND #304 by @enoch3712 in https://github.com/enoch3712/ExtractThinker/pull/305
Full Changelog: https://github.com/enoch3712/ExtractThinker/compare/v0.1.9...v0.1.10
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Complex documents. Validated Python objects.
ExtractThinker is an open-source Python library for turning documents into typed data. Define a Pydantic contract, choose a document parser and LLM, then load, classify, split and extract.
Documentation · Quickstart · Contributing · 2026 roadmap
First extraction
pip install extract-thinker
Set EXTRACT_THINKER_MODEL to a model available to you and configure that provider's API key. Save this sample as invoice.txt:
Invoice: INV-2026-001
Supplier: Example Company
Total: 120.00 EUR
import os
from pydantic import Field
from extract_thinker import Contract, DocumentLoaderTxt, Extractor, LLM
class Invoice(Contract):
invoice_number: str
supplier: str
total: float = Field(ge=0)
currency: str
extractor = Extractor(
DocumentLoaderTxt(),
LLM(os.environ["EXTRACT_THINKER_MODEL"], token_limit=1000),
)
result = extractor.extract("invoice.txt", Invoice)
print(result.model_dump())
The result is a validated Invoice. Schema validity does not guarantee factual accuracy; evaluate results on your documents. Extraction uses the configured provider and may incur charges.
For PDFs, install pypdf and use DocumentLoaderPyPdf. Scanned documents need OCR or a vision-capable model. System MIME detection requires libmagic (brew install libmagic on macOS or apt-get install libmagic1 on Debian/Ubuntu). See the quickstart for a credential-free loading check and setup details.
Build a document workflow
| Need | Component |
|---|---|
| Read PDFs, images, tables and spreadsheets | Document loaders |
| Define fields, constraints and post-validation | Pydantic contracts |
| Classify and split mixed document bundles | Classification and splitters |
| Handle long inputs and incomplete responses | Completion strategies |
| Use local models | Ollama setup |
2026 additions on main
The repository now includes page retrieval with SQLite, parallel field extraction, configurable model routing, local entity masking, page events, PyMuPDF/Camelot/Tabula/Adobe loaders, and an MCP service with Docker Compose. These changes are not yet a new PyPI release. Install from a checkout to use them:
git clone https://github.com/enoch3712/ExtractThinker.git
cd ExtractThinker
pip install -e .
Read the 2026 update and compatibility notes, MCP setup, and issue-resolution evidence. The core supports Python 3.9–3.13; the optional MCP service requires Python 3.10+.
Contribute
Start with CONTRIBUTING.md. The offline core suite runs without provider credentials. Good contributions include reduced document fixtures, loader compatibility fixes, examples with expected outputs, and clear reports of model or parser limitations.
If ExtractThinker helps your project, a GitHub star helps others find it. The roadmap focuses on reliable onboarding, reproducible examples and contributor support.
Articles and project history
Stay updated and connect with the community:
- Scaling Document Extraction with o1, GPT-4o & Mini
- Claude 3.5 — The King of Document Intelligence
- Classification Tree for LLMs
- Advanced Document Classification with LLMs
- Phi-3 and Azure: PDF Data Extraction | ExtractThinker
- ExtractThinker: Document Intelligence for LLMs