#3232nd of 93 in Data and scraping for AIFor data and documents, documents and ocr
contextgem
Python library for extracting typed, source-referenced data from documents
Run it:Vast.ai ↗ (opens in a new tab)Clore.ai ↗ (opens in a new tab)Affiliate links, no effect on a rank.
- Stars
- 2.1k
- License
- Apache-2.0
- Last commit
- Nov 2026
- Last release
- Nov 2026
- Language
- Python
1,804 on 28 Apr 20262,098 on 24 Nov 2026
From GitHub's daily star counts.
Checked on GitHub.
Overview
ContextGem is a Python library that extracts structured data from documents using declarative aspects and concepts instead of hand-written prompts. It generates the prompts, validates output into typed items (text, numbers, dates, booleans, labels, ratings, JSON), and maps each item back to source paragraphs or sentences. LLMs run through LiteLLM, and version 1.0 adds decision models that return probabilities for closed questions.
Who it is for: Python developers building document extraction pipelines, e.g. contracts
Strengths
- Items carry references to source paragraphs or sentences, with optional justifications
- Works with any LLM supported by LiteLLM, including Ollama and LM Studio
- Decision models return per-answer probabilities with configurable thresholds
- Optional Docling extra converts PDF, DOCX, PPTX, XLSX, HTML and many other formats
Weaknesses
- Tested with hosted LLMs; smaller local models may not follow extraction instructions
- Decision models need an external provider such as TypeSafe Jev or OpenAI Decisions API
- Some formats need LibreOffice (DOC, PPT, XLS, RTF) when converting through Docling
- 1.0 renamed or removed classes and dropped Python 3.10, so 0.x code needs migration
What it needs
- GPU optional
- Needs LiteLLM, Docling (optional), LibreOffice (some formats)
- Models: OpenAI, Anthropic, Google, Azure OpenAI, xAI
What changed
- v1.6.0 ↗ (opens in a new tab)Security fix
“Upgraded pinned dependency versions: litellm==1.108.8, openai==3.51.0, genai-prices==0.2.3. ContextGem now requires openai 3: code of your own that uses the OpenAI SDK in the same environment must wo…”
From the release notes. No flag means the note does not say so, not that the upgrade is safe.
Also in Data and scraping for AI
See all 93| Rank | Project | Score |
|---|---|---|
| #30 | chandraOCR model that converts PDFs and images to Markdown, HTML or JSON with layout | 73 out of 100 |
| #31 | data-juicerOperator-based pipelines for cleaning and deduplicating multimodal training data | 73 out of 100 |
| #33 | doctrTwo-stage OCR library for PDFs and images, built on PyTorch | 69 out of 100 |
| #34 | datachainPython library that indexes cloud files into versioned, typed datasets | 69 out of 100 |
| #35 | webclawRust CLI and MCP server that turns web pages into clean markdown or JSON | 69 out of 100 |