# google/langextract

A Python library for extracting structured information from unstructured text using LLMs with precise source grounding and interactive visualization.

Repository: https://github.com/google/langextract
Canonical: https://ross.abutalabs.com/products/langextract
Homepage: https://pypi.org/project/langextract/
Language: Python
License: Apache-2.0
License Family: permissive
Topics: llm, nlp, python, gemini-ai, information-extration, large-language-models, structured-data, gemini, gemini-api, gemini-flash, gemini-pro
Last push: 2026-08-19T07:21:21+00:00

## Health v2 (maintenance only)
Score: 82/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 98, release rhythm 91, longevity 30
- inputs: {"age_days": 421, "days_push": 14, "days_rel": 62, "gap_med": 10, "n_releases_24m": 18}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 38490, forks 2707 (observed 2026-08-28T04:12:07.440641+00:00)

## What it is
LangExtract is a Python library that uses LLMs to extract structured information from unstructured text based on user-defined instructions and few-shot examples. It grounds every extraction to its exact character span in the source text and provides interactive visualization for traceability.

## Use cases
- extract structured data from clinical notes with llm
- parse entities from unstructured text with source citations
- extract medications from doctor reports
- structure radiology reports into
- highlight extracted fields back in the original document
- run information extraction with gemini or openai models
- use local llms with ollama for text extraction

## When to choose
- you need structured extractions that are verifiably grounded to exact source text spans
- you want schema-consistent LLM outputs enforced via few-shot examples
- you need to work with clinical or long documents requiring traceability
- you want provider flexibility across Gemini, OpenAI, or local Ollama models

## When to avoid
- you need fully offline extraction without any LLM
- you want a general-purpose NLP pipeline beyond information extraction
- you cannot send text to cloud LLM APIs and lack local model infrastructure
- you need high-throughput extraction with minimal LLM cost

## Facets
- artifact type: library
- maturity: active
- function: nlp, llm-inference, data-science, rag
- domain: large-language-models, artificial-intelligence, data-science
- platform: python
- tags: information-extraction, structured-output, source-grounding, gemini, openai, ollama, few-shot, natural-language-processing

## Member repositories
- google/langextract (main) score 82

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:12:07.440641+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T16:24:50.829910+00:00, confidence not recorded.
  - readme: https://github.com/google/langextract (fetched 2026-08-28T04:12:07.440641+00:00, sha a5025496853a)
  - homepage: https://pypi.org/project/langextract/ (fetched 2026-08-29T07:46:57.145072+00:00, sha 4b4e8fead74a)
  - registry_pypi: https://pypi.org/pypi/langextract/json (fetched 2026-08-29T07:46:57.154619+00:00, sha b265d3fc8fc4)
- Data as of 2026-08-30T08:39:29.467469+00:00.
