shcherbak-ai/contextgem
ContextGem: Effortless LLM extraction from documents
What it solves
ContextGem simplifies the process of extracting structured data and insights from documents. It removes the need to manually write complex extraction prompts, design validation models, and map outputs back to source references, which are typically required for reliable structured extraction.
How it works
ContextGem uses a declarative approach where the user describes what to extract using natural language, and the framework handles the how.
- Define Extraction Context: A
Documentobject is created containing the text or visual content of the source material. - Define Extraction Targets: Users define Aspects (to extract text segments like topics or themes) and Concepts (to extract specific data points like entities, facts, or classifications).
- Run LLM Extraction: A
DocumentLLMis configured (supporting cloud or local models via LiteLLM) to process the document and extract the defined aspects and concepts.
Who it’s for
Developers building applications that require deep, structured analysis of individual documents (such as contracts, invoices, or reports) and who want to avoid the inconsistencies of traditional RAG retrieval for single-document tasks.
Highlights
- Granular Reference Mapping: Provides precise paragraph- and sentence-level references for extracted data.
- Automated Prompting and Modeling: Handles dynamic prompt generation and data modeling automatically.
- Built-in Justifications: Automatically generates justifications for the extracted information.
- Hierarchical Extraction: Supports nested context extraction, allowing aspects to contain other aspects or concepts.
- Broad LLM Support: Integrates with various cloud and local LLMs via LiteLLM.