FrameworksRAGModels

LangExtract: Python Library for Grounded Structured Extraction with LLMs

by Google (open-source project)

IntermediateDocumentationFree~1-2 hours to work through the README, examples and visualization, self-paced

Pull structured entities out of long documents with an LLM and trace every one back to its exact character offsets.

Start LearningAdded Nov 14, 2026 · Updated Nov 14, 2026

Overview

LangExtract is an Apache-2.0 Python library under the google GitHub organization that turns unstructured text into structured records using an LLM, a natural-language instruction and a handful of few-shot examples. The README notes it is not an officially supported Google product. Its defining feature is source grounding: each extraction is mapped to its exact character interval in the input, and extractions the library cannot locate get char_interval set to None so you can filter them out. Long inputs are handled with chunking, parallel processing and multiple extraction passes to improve recall, and documents can be fetched straight from a URL. Results are written to JSONL and rendered as a self-contained interactive HTML file for reviewing entities in context. The schema is enforced from your examples, with output_schema support on Gemini and OpenAI. Supported backends are Gemini (the README recommends gemini-3.5-flash as the default), OpenAI including Batch API and OpenAI-compatible endpoints, and local models through Ollama, plus a plugin system for custom providers. Worked examples cover full-text extraction from Romeo and Juliet (147,843 characters), medication and relationship extraction from clinical text, and RadExtract for radiology reports. The library was introduced on the Google for Developers Blog on July 30, 2025 by ML engineers Akshay Goel and Atilla Kiraly. PyPI shows version 1.7.2 released November 7, 2026 (checked November 14, 2026), and the repo had about 39.3k stars on that date.

At a Glance

Topic
Frameworks
Level
Intermediate
Format
Documentation
Cost
Free
Duration
~1-2 hours to work through the README, examples and visualization, self-paced
Provider
Google (open-source project)
Hands-on
Yes — code/exercises
Certificate
None

What You’ll Learn

  • ✓Define an extraction task with a prompt description and few-shot ExampleData examples
  • ✓Map every extracted entity back to its character offsets for verification and highlighting
  • ✓Filter out ungrounded extractions where the library returns a char_interval of None
  • ✓Process long documents with chunking, parallel workers and multiple extraction passes to raise recall
  • ✓Save results to JSONL and generate an interactive HTML view for human review
  • ✓Run extraction on Gemini, OpenAI including the Batch API, or local models through Ollama
  • ✓Enforce a consistent output schema using examples and output_schema on supported providers
  • ✓Add a custom model provider through the plugin system without changing core code

Highlights

  • •Character-level source grounding makes every extraction auditable, which most prompt-and-parse pipelines lack
  • •About 39.3k GitHub stars and 166 points on its Hacker News launch thread, as of November 14, 2026
  • •Still actively released: version 1.7.2 shipped November 7, 2026, sixteen months after the July 2025 first release
  • •Runs fully local through Ollama with no API key, so sensitive documents can stay on your own hardware
  • •Comes with real worked examples, including a full novel and a radiology-report demo on Hugging Face Spaces

Who It’s For

Best For

  • ✓Engineers building document ingestion and metadata extraction for RAG pipelines
  • ✓Teams in healthcare, legal or finance who must show where each extracted fact came from
  • ✓Developers replacing brittle regex or rule-based entity extraction with LLM extraction
  • ✓Data teams turning large text archives into structured tables for analysis

Prerequisites

  • •Intermediate Python and pip, with Python 3.10 or later
  • •A Gemini or OpenAI API key, or a local Ollama install for on-device models
  • •Basic understanding of prompting and few-shot examples

FAQ

What is LangExtract: Python Library for Grounded Structured Extraction with LLMs?

LangExtract is an open-source Python library that uses LLMs to extract structured data from unstructured text, guided by a prompt and a few examples. Its README and examples are for developers building document pipelines, RAG ingestion or clinical and legal extraction. You leave able to run grounded, reviewable extraction over long documents.

Is LangExtract: Python Library for Grounded Structured Extraction with LLMs free?

LangExtract: Python Library for Grounded Structured Extraction with LLMs is free to access.

What level is LangExtract: Python Library for Grounded Structured Extraction with LLMs for?

LangExtract: Python Library for Grounded Structured Extraction with LLMs is aimed at a intermediate audience. Recommended background: Intermediate Python and pip, with Python 3.10 or later, A Gemini or OpenAI API key, or a local Ollama install for on-device models, Basic understanding of prompting and few-shot examples.

How long does LangExtract: Python Library for Grounded Structured Extraction with LLMs take?

Expect roughly ~1-2 hours to work through the README, examples and visualization, self-paced. Most learners work through it at their own pace.

What will I learn from LangExtract: Python Library for Grounded Structured Extraction with LLMs?

You'll learn: Define an extraction task with a prompt description and few-shot ExampleData examples; Map every extracted entity back to its character offsets for verification and highlighting; Filter out ungrounded extractions where the library returns a char_interval of None; Process long documents with chunking, parallel workers and multiple extraction passes to raise recall; Save results to JSONL and generate an interactive HTML view for human review; Run extraction on Gemini, OpenAI including the Batch API, or local models through Ollama; Enforce a consistent output schema using examples and output_schema on supported providers; Add a custom model provider through the plugin system without changing core code.

Topics

information extractionstructured outputssource groundinggeminiollamadocument processing

Sources

This page was written from 4 sources, 3 on domains other than github.com.

  1. 1.github.com — langextractvendor
  2. 2.developers.googleblog.com — introducing langextract a gemini powered information extract
  3. 3.pypi.org — langextract
  4. 4.hn.algolia.com — hn.algolia.com