Back to all articles

LangExtract keeps the original words close to your AI-extracted data

Pulling details from reports is easier to trust when you can see the words behind each result. Google's LangExtract pairs structured extraction with source highlights, but good examples and human checks still matter.

November 5, 2026
Cover image for: LangExtract keeps the original words close to your AI-extracted data

Someone sends you a spreadsheet of customer complaints. One row says a parcel arrived late, another says a replacement was promised, and a third somehow contains both. Before you act, you want to see the actual messages. Otherwise, you are trusting a neat table to tell the whole story, and neat tables have excellent poker faces.

That is the kind of problem LangExtract addresses. It uses a language model to pull information out of text, then connects extracted passages to their locations in the original document. You get a way to inspect where a result came from instead of treating the model's answer as a finished record.

This is a review of the project's documentation, not a hands-on accuracy test. Its appeal is the review process it makes possible, rather than a promise that it will read every document correctly.

What LangExtract actually gives you

LangExtract's official GitHub repository describes a Python library for extracting structured information from unstructured text. It lives in Google's GitHub organization, though the maintainers explicitly say it is not an officially supported Google product.

You describe what you want to find and provide examples of what a good extraction looks like. The library uses a model to identify matching information, organize it into categories, and attach attributes. Source grounding means connecting that extracted text back to a specific place in the input.

Imagine a repair business that wants to find appliance names, reported faults, and promised appointments in customer messages. A useful extraction might pair the words 'washing machine' with an appliance category, while 'leaks during the spin cycle' becomes a reported fault. These are illustrative examples, not results from a test.

The project also generates a self-contained interactive HTML view for reviewing extracted items in context. A reviewer can inspect highlighted source passages rather than repeatedly hunting through the original text. That makes it worth considering for developers building document-review tools, analysts working with messy text, and operations teams that have engineering help.

Start with a small question, not the whole filing cabinet

LangExtract is a library, not a ready-made office app where anyone can drop a folder and expect a complete workflow. Someone needs to set up Python, choose a supported model, prepare the text, and decide what the output should mean.

A sensible first task would be narrower than 'understand our customer support history.' Try 'find each explicitly stated delivery problem and the product mentioned beside it.' That gives you something you can check against the original messages.

The high-level setup follows a short sequence:

  1. Install LangExtract and configure a supported model provider.
  2. Write instructions that define the information to extract, including what to leave out.
  3. Supply a few representative examples using exact passages from sample text.
  4. Run extraction on a small sample, then review both the structured results and the highlighted source passages.

Your examples do more work than a polished instruction paragraph alone. If a message says, 'I thought the package would arrive Tuesday, but nobody confirmed it,' should Tuesday become a promised delivery date? Probably not. Show that distinction in the examples so the task reflects how your team actually uses the data.

Include awkward cases early: several products in one message, an appointment that was later canceled, or a sentence saying a fault did not occur. A collection of easy examples can make a demonstration look tidy while leaving the difficult decisions unresolved.

A source highlight helps you check, but it cannot settle the meaning

Suppose a customer writes, 'The first agent offered a refund, but the supervisor said it needed approval.' Finding the word 'refund' is useful. Recording the refund as approved would be a mistake.

A highlight lets a reviewer spot that mistake without searching the entire message. It does not stop the model from making it. Nor does it tell you whether the customer's account is factually true. The tool connects an extraction to text; your team still has to judge what that text supports.

Missing information deserves equal attention. A review screen can show everything the model found while making omissions much less obvious. Check some complete source documents alongside the results, including documents where the tool returned nothing.

For a pilot, keep a small reference set that a person has already reviewed. Compare the output with that set for missed items, incorrect categories, and claims that the text does not support. Decide which errors require a human check before connecting the output to refunds, account changes, or other consequential actions.

Long documents bring extra work and extra cost

The documentation describes support for splitting long text into smaller pieces, processing pieces in parallel, and making multiple extraction passes to find more relevant information. Those features are useful when a report is too long to handle comfortably in one request.

They do not make document size irrelevant. More passes can mean more model calls, more waiting, and higher provider charges. Relationships that stretch across distant sections also deserve careful testing. You should not assume that finding two passages means the tool has understood how they relate.

The official release notes are worth reading before an upgrade. Recent entries address source alignment, model configuration, and how blocked or failed model responses are reported. Those details matter in a document pipeline: an empty result should not quietly stand in for a request that failed.

Keep the original input and the extraction settings together when your retention rules allow it. If a result changes after a model or library update, you will want enough context to investigate without guessing which version of the document someone used.

Local library, cloud model, or both?

LangExtract can use cloud models, including Gemini, and supports OpenAI through an optional dependency. It also has built-in support for local models through Ollama. You can run the Python code on your computer while still sending document text to a cloud provider, so 'installed locally' does not automatically mean the documents stay there.

Cloud use requires the appropriate API access and is subject to the provider's pricing and data terms. The library is available under Apache 2.0, but that license does not pay for model inference. Local inference avoids cloud-model API charges for those calls, while leaving you responsible for suitable hardware, setup, and the chosen model's license.

Provider capabilities differ, too. The README notes limitations in the local Ollama provider's schema support. A change of provider needs its own checks; treat it as more than swapping a name in a settings file.

Before using private messages or reports, decide who may send them to which service and who may open the results. The exported HTML review file can contain sensitive source text. Handle it like the underlying documents, rather than a harmless presentation you can forward freely.

When a simpler option is enough

If every document follows a fixed format, a conventional parser or a few well-tested rules may be cheaper and more predictable. If you only have a dozen short messages, a spreadsheet and a careful reader may finish the job before anyone has configured Python.

A structured-output library such as Instructor is another option when your main problem is getting model replies into validated fields. LangExtract is more directly suited to a workflow where extracted passages need to remain connected to the document for review. Neither approach removes the need to check the meaning of the output.

Try LangExtract if you have recurring text-extraction work, someone comfortable with Python, and a reviewer who benefits from seeing the original words beside each result. Start with a small, non-sensitive sample and a question narrow enough to score honestly. If the highlights help your reviewer catch a mistaken promise or a missing fault, you have a concrete reason to keep going.