Overview
How an LLM turns unstructured prose into the structured (subject, predicate, object) triples a graph can traverse.
Why it matters
Building a knowledge graph from raw text starts with a step that has no equivalent in naïve RAG: an LLM reads each chunk and pulls out entities (people, organisations, products) and the relations between them, e.g. the sentence 'Acme acquired Widgetco in 2023' becomes the triple (Acme, acquired, Widgetco) with a date=2023 property. This is the bridge that turns an amorphous pile of documents into a queryable graph database.
There are two ways to run this extraction, and the difference matters enormously downstream:
- Free-form extraction lets the LLM invent whatever entity types and relation labels it wants. One chunk produces
acquired, the next producesbought, another producespurchased— three different edge labels that all mean the same thing but are invisible to each other in a graph query. - Schema-guided extraction gives the LLM a fixed, closed set of entity types (
Company,Person,Product) and relation types (acquired,worksAt,foundedBy) up front, and constrains it to only ever emit triples that conform to that schema.
Schema-guided extraction is almost always the right default in production: a graph with 200 synonymous relation labels for 'acquired' is not actually traversable — a query for 'who acquired whom' will silently miss two-thirds of the real acquisitions because they were extracted under a different label. Constraining the schema is what makes the graph reliable for the retriever, even if it means occasionally forcing a slightly awkward fit.
