# LangExtract

A Python library that uses large language models to pull structured information out of unstructured text, mapping every extracted value back to its exact location in the source for verification.

LangExtract takes a user-defined extraction task, described with a prompt and a few-shot example, and applies it to documents such as clinical notes or reports, returning structured, schema-consistent output. Every extraction is grounded to its exact character location in the source text, so results can be highlighted and traced back for review; extractions the library cannot locate in the source text are flagged rather than silently kept.

For long documents, it chunks text, processes chunks in parallel, and makes multiple passes to improve recall. It generates a self-contained, interactive HTML file for reviewing thousands of extracted entities in context, and supports both cloud models such as the Gemini family and local open-source models through a built-in Ollama interface, along with custom and OpenAI-compatible model providers.

It is written in Python and licensed under Apache-2.0.

Website: https://github.com/google/langextract
