Favicon of LangExtract

LangExtract

A Python library extracts structured data from text with source links and visual review, using local models through Ollama or cloud models.

LangExtract is a Python library for developers who need to turn notes, reports or other text into structured data. It links extracted details to their original passages so people can check the results against the document.

  • Source tracing: Locate extracted text within the original document and see which results couldn't be matched to a source passage.
  • Custom extraction: Define the categories and attributes you need through instructions and examples, without fine-tuning a model; supported Gemini and OpenAI models also accept explicit output schemas.
  • Long documents: Process lengthy texts with repeated extraction passes to help catch details a single pass might miss.
  • Visual review: Generate a self-contained interactive HTML file that highlights extracted entities in context, and save structured results as JSONL.

The library is open source under Apache 2.0 and runs in your own Python environment or Docker. Built-in Ollama support lets you use local LLMs without an API key and keep inference on your own hardware. Gemini and OpenAI inference sends text to the selected cloud provider and requires an API key. It also supports OpenAI-compatible endpoints and custom model-provider plugins.

Extraction quality depends on the model, task instructions and examples. A match to a source passage doesn't establish that an inferred attribute is correct. Explicit output schemas are available with supported Gemini and OpenAI models, but the Ollama backend doesn't support them.

Similar to LangExtract