liveBook · Manning

LangExtract

As explained in Retrieval Augmented Generation, The Foundational Ideas

LangExtract is a library for extracting structured entities and relationships from text using prompted language models and preserving source offsets.

LangExtract turns unstructured text into graph-ready entities and relationships while preserving the character offsets that ground each extraction in its source sentence. This addresses a common production failure: a graph claim without provenance cannot be cited or checked. section 12.1.1

A practical extraction workflow combines:

  • A task prompt and a few examples describing the desired structured output. section 12.1.1
  • Chunking, parallel calls, and multiple passes over long documents to recover entities missed in one pass. section 12.1.1
  • Structured subject–predicate–object triplets that can be loaded into NetworkX, igraph, Neo4j, ArangoDB, or TigerGraph. section 12.1.1
  • An HTML viewer that displays extractions against the original text for schema and provenance checks. section 12.1.1

From document to grounded graph

A document is split into windows, an LLM extracts people, places, concepts, and their relationships, and each resulting triplet retains its character offsets. The graph can then support answers whose entities trace back to source text. section 12.1.1

How Retrieval Augmented Generation, The Foundational Ideas covers it

How deep it goes
Explains prompts, examples, chunking, parallelism, multi-pass extraction, graph loading, and offsets, but not schema design.
Examples
Uses entity–relationship triplets, source character offsets, and an HTML extraction viewer as concrete artifacts.
What it assumes
Assumes familiarity with prompted language models, text chunking, structured triplets, and graph storage.
What you can do after
Build it from scratch, extracting graph-ready entities and relations from long documents with inspectable provenance.
How it connects
Connects prompted extraction with graph-based RAG, knowledge graphs, provenance, and graph databases.

This explainer was generated by Manning's knowledge graph from the text of Retrieval Augmented Generation, The Foundational Ideas. The section links point to the parts of the book it draws on.