Declarative extraction
Describe aspects and concepts in code; the framework generates the extraction prompts rather than requiring users to write them manually.
ContextGem is a free, open-source Python framework that extracts structured data and insights from document text and images using LLMs and decision models. It helps developers build reusable extraction pipelines with typed outputs, source references, and optional justifications.
ContextGem is a free, open-source Python framework for extracting structured data and insights from documents with large language models and decision models. It packages prompt generation, data-model validation, source mapping, justifications, and multi-step orchestration into a declarative pipeline that can be reused and serialized.
Users describe the aspects and concepts they want to extract from document text or images. LLMs can produce typed answers and reasoning-oriented values, while decision models handle supported closed questions such as yes/no, labels, and ratings by returning probabilities for possible answers. Extracted items can be linked back to source paragraphs or sentences, which helps readers inspect where a result came from.
Describe aspects and concepts in code; the framework generates the extraction prompts rather than requiring users to write them manually.
Return text, numbers, dates, booleans, labels, ratings, and JSON objects as typed, validated items.
Map extracted items to the paragraphs or sentences that support them, with optional justifications for the result.
Organize extraction around aspects, sub-aspects, and concepts so model processing can focus on relevant parts of a document.
Route each aspect or concept to an appropriate LLM or decision model, with model fallback available through a model group.
Use decision models for supported closed questions and receive probabilities for possible answers, with a configurable decision threshold.
Define payment terms, fees, anomalies, entities, or other contract concepts and return the relevant passages with optional justifications for review.
Process repeated document batches with closed questions such as Boolean, label, or rating classifications when a fast, lower-cost decision-model answer is sufficient.
Extract structured fields such as dates, numbers, labels, and JSON objects from business documents for use in downstream Python workflows.
Investigate findings in reports or agreements by tracing each extracted item to the paragraph or sentence where it appears.
Combine model types in one pipeline: use an LLM for open-ended or reasoning-heavy questions and a decision model for suitable closed questions.
Install the package with `uv add contextgem` or `pip install -U contextgem`. For PDF, DOCX, and other file conversion through Docling, the project documents `uv add "contextgem[docling]"`. You then create a `Document`, describe aspects or concepts to extract, configure a model, and call the extraction workflow.
You describe the information to extract instead of writing prompts directly. ContextGem generates prompts, validates results into typed items, and can attach references to source paragraphs or sentences. The example workflow uses `DocumentLLM.extract_all(doc)` to run extraction.
LLMs can extract open values and answers that require reasoning, including aspects and concept types from text and images. Decision models are intended for closed questions such as Boolean, label, and rating concepts from text; they return probabilities for possible answers rather than generated text.
The project supports cloud or local LLMs through LiteLLM, with examples including OpenAI, Anthropic, Google, Azure OpenAI, xAI, Ollama, and LM Studio. It also documents decision-model support including TypeSafe Jev, OpenAI Decisions API, and Microsoft Foundry. The exact availability and configuration depend on the selected provider.
The current project metadata requires Python 3.11 or newer and below 3.15. The repository notes that Python 3.10 is no longer supported in the 1.0 migration guidance. Smaller local LLMs may not follow detailed extraction instructions reliably, so the documentation recommends testing them on a sample of documents.
nolainocr is an AI OCR tool that extracts structured data from PDF invoices, receipts, forms, contracts, and bank statements. It helps teams move document data into Excel, Google Sheets, JSON, or CSV without manual entry.
Clairic is Cloudflare’s System One extraction model for turning unstructured text and optional images into typed values, computed fields, estimates, and forecasts. It is hosted on Workers AI and is aimed at developers building structured data and AI workflows.
司马阅是一款面向企业的AI文档智能体平台,帮助团队把分散在文档中的知识转成可用于问答、检索、写作和审查的结构化能力。它适合对准确性和数据安全要求较高、且有大量文档工作流程的企业。
Capso is a native macOS screenshot and screen recording app for capturing, annotating, recording, and extracting text from screen content. It is free forever, open source, and positioned as an alternative to CleanShot X.
Extend is a document processing platform for turning PDFs and other documents into structured data. It helps teams parse, extract, split, classify, and route documents through APIs, Studio, Evals, Composer, and Workflows.
Invited turns dates found in bills, cheques, invitations, renewals and other documents into reminders. It supports camera images, screenshots, PDFs and shared files on iPhone and Android, with review before saving and no account required.