contextgem
Extract structured data and insights from documents using LLMs and decision models
What is contextgem?
Extract structured data and insights from documents using LLMs and decision models
Overview of contextgem
What it is
ContextGem is a free, open-source framework that extracts structured data and insights from documents using LLMs and decision models. It handles prompts, data models, source references, justifications, and multi-step pipelines with minimal code. The framework is tested with hosted LLMs such as gpt-6-luna (OpenAI) and claude-haiku-5-5 (Anthropic), and with decision models such as Jev (TypeSafe). It supports Python 3.10 and later.
Key features
- No prompts to write: prompts are generated from descriptions of what to extract.
- Typed, validated output: text, numbers, dates, booleans, labels, ratings, and JSON objects.
- Every fact traced to its source: items map back to paragraphs or sentences, with reasoning on request.
- Nested context: aspects, sub-aspects, and concepts focus the model on relevant text.
- The right model for each question: an LLM where reasoning is needed, a decision model for fast, low-cost closed questions.
- Answers with probabilities: a decision model gives the probability of each possible answer, and you set the threshold.
Use cases
- Extracting payment terms, anomalies, termination clauses, and other structured information from contracts and agreements.
- Answering closed questions (yes/no, labels, ratings) from documents at volume with decision models.
- Building agentic workflows that combine LLMs and decision models for document analysis.
Getting started
uv add contextgem # or: pip install -U contextgem
uv add "contextgem[docling]" # with Docling, to convert PDF, DOCX and other files
See the repository README for full quick-start examples with LLMs and decision models.
License and pricing
License: Apache-2.0. Pricing: open source (free).
Based on the project's public README and repository metadata.