![ContextGem](_static/contextgem_wordmark.svg)
<br/>

# Welcome to ContextGem Documentation!

ContextGem is a free, open-source framework that makes it radically easier to extract structured data and insights from documents using LLMs and decision models — with minimal code.

#### NOTE
**New in 1.0: decision models.** Next to LLMs, ContextGem now works with [decision models](https://contextgem.shcherbak.ai/decision_models/decision_models/index.html.md), which answer closed questions (yes/no, one of your labels, a level of a scale) with the probability of each possible answer, fast and at a low cost.

**Upgrading from 0.x?** Some classes and parameters are renamed or removed, some defaults have changed, and Python 3.10 is no longer supported. Follow the [migration guide](https://contextgem.shcherbak.ai/migration_v1/index.html.md).

<br/>

Learn about the motivation behind ContextGem and how it works.

[Learn More](https://contextgem.shcherbak.ai/motivation/index.html.md)

Instructions to install ContextGem and quickly start using it.

[Get Started](https://contextgem.shcherbak.ai/installation/index.html.md)

Learn how to create and configure documents to extract information (aspects and concepts) from.

[Create Documents](https://contextgem.shcherbak.ai/documents/document_config/index.html.md)

Learn how to identify and extract specific document sections like clauses, chapters, or terms using ContextGem’s Aspects API.

[Extract Aspects](https://contextgem.shcherbak.ai/aspects/aspects/index.html.md)

Learn how to extract and infer structured data like JSON objects, strings, numbers, dates, booleans, ratings, and labels from documents using ContextGem’s Concepts API.

[Extract Concepts](https://contextgem.shcherbak.ai/concepts/supported_concepts/index.html.md)

Learn how to create reusable extraction pipelines that combine aspects and concepts for consistent document analysis across multiple files.

[Build Pipelines](https://contextgem.shcherbak.ai/pipelines/extraction_pipelines/index.html.md)

Learn about supported cloud LLM providers and local models, and how to configure and use them for extraction.

[Explore LLMs](https://contextgem.shcherbak.ai/llms/supported_llms/index.html.md)

Learn how to extract yes/no, label and rating concepts, as well as aspects, with decision models, which return probabilities instead of generating text.

[Explore Decision Models](https://contextgem.shcherbak.ai/decision_models/decision_models/index.html.md)

Explore advanced features and techniques for extracting data from documents.

[Learn More](https://contextgem.shcherbak.ai/advanced_usage/index.html.md)

Learn how to optimize your extraction pipeline for accuracy, cost, and performance.

[Optimize](https://contextgem.shcherbak.ai/optimizations/optimization_choosing_llm/index.html.md)

Learn how to serialize and deserialize ContextGem objects for storage and transfer.

[Save & Load](https://contextgem.shcherbak.ai/serialization/index.html.md)

Complete API documentation for all ContextGem modules and classes.

[View API](https://contextgem.shcherbak.ai/api/documents/index.html.md)

<br/>

## Indices and tables

* [Index](https://contextgem.shcherbak.ai/genindex/index.html.md)
* [Module Index](https://contextgem.shcherbak.ai/py-modindex/index.html.md)
* [Search Page](https://contextgem.shcherbak.ai/search/index.html.md)

<!-- Navigation structure (hidden from page, visible in sidebar) -->
