Knowledge Graph
A knowledge graph is a structured network of entities, such as customers, products and contracts, and the named relationships between them, stored so software can query and reason over connections.
Also known as: Graph database, GraphRAG
How it works
Data is stored as nodes (entities) and edges (relationships), for example Supplier A supplies Part 42, Part 42 is used in Model X. Two main models exist: RDF triples queried with SPARQL, a W3C standard, and property graphs such as Neo4j queried with Cypher or the ISO GQL standard published in 2024. Google popularized the term in 2012 when it introduced its Knowledge Graph to enrich search results.
Language models have renewed interest in graphs in two directions:
- Building graphs: LLMs extract entities and relationships from contracts, emails and reports, a task that once needed heavy manual work.
- GraphRAG: retrieval follows relationships in the graph, not only text similarity. Microsoft Research published its GraphRAG approach in 2024, using graph-based summaries to answer questions about a whole document collection.
Why it matters
Vector search finds passages that sound similar. It struggles with questions that depend on connections: which customers are affected if this supplier fails, or which contracts reference a clause that changed. A knowledge graph answers these directly and explains the path it followed, which helps with auditability. The cost is modeling effort and upkeep: someone has to define entity types and keep the graph current. Use one when relationships are central to the questions people ask; plain RAG is often enough otherwise. See knowledge management agents.
Knowledge Graph in depth
Example: supplier risk across documents and systems
Example: a hypothetical manufacturer wants to answer "If this supplier stops shipping, which finished products and customer orders are affected?". Data comes from the ERP (suppliers, parts, bills of materials, orders) and from contracts and emails (alternate suppliers, exclusivity clauses). The ERP data maps directly to nodes and edges. A language model extracts entities and relationships from contracts, such as "Supplier B is an approved alternate for Part 42", and each extracted fact is stored with its source document and a review status. A planner's question is translated into a graph query that walks from the supplier through parts and assemblies to open orders, and the answer lists affected orders with the path that explains each one.
Building a knowledge graph step by step
- Start from questions: list the questions people need answered; they define which entities and relationships matter.
- Design a small schema: entity types, relationship types and key properties. Reuse established vocabularies such as schema.org where they fit.
- Load structured data first: ERP, CRM and master data give reliable backbone facts.
- Extract from text: use named entity recognition and model-based relation extraction, with confidence scores and provenance.
- Resolve entities: merge "Northline Steel Ltd", "NORTHLINE STEEL" and a vendor code into one node; this step decides graph quality.
- Keep it current: incremental updates from source systems and re-extraction when documents change.
Tools and query options
| Category | Examples |
|---|---|
| Property graph databases | Neo4j, Memgraph, Amazon Neptune (which also supports RDF) |
| RDF triple stores | GraphDB, Apache Jena |
| Query languages | Cypher, ISO GQL, SPARQL, Gremlin |
| GraphRAG tooling | Microsoft's open-source GraphRAG project, graph integrations in LlamaIndex and LangChain |
For LLM applications, a common pattern combines vector search over text with graph traversal: semantic search finds the relevant entities, and the graph supplies their connections as context.
How to evaluate a knowledge graph
- Extraction precision and recall on a labeled sample of documents.
- Entity resolution accuracy: duplicates left unmerged and wrong merges.
- Coverage: share of target entities and relationships present.
- Answer accuracy on a set of real questions, compared with plain RAG on the same set.
- Freshness: lag between a change in a source system and the graph.
Expose the graph to people as well as to models. A simple interface where analysts can search an entity and see its connections helps them spot extraction errors, builds trust in the answers the AI gives, and turns domain experts into reviewers who improve the graph over time.
Common mistakes
- Designing a vast ontology before answering a single business question.
- Loading model-extracted facts without provenance or review, so errors spread silently.
- Skipping entity resolution, which leaves the graph fragmented.
- Using a graph where relationships are not central; plain retrieval would be simpler.
Knowledge graphs complement embeddings and vector databases, strengthen grounding for relationship questions, and give AI agents structured memory. We build them in knowledge management agents and NLP and document AI.
Questions about Knowledge Graph
Something else? Send us your question and an engineer replies with next steps.
Do we need a graph database to use a knowledge graph with AI?
Not always. Small graphs can live in a relational database with tables for entities and relationships, queried with recursive SQL, or even in memory for a prototype. A dedicated graph database becomes useful when queries traverse many hops, the graph grows large, or you want graph algorithms such as path finding and community detection. Start by proving that relationship-based answers help your use case, then choose storage based on query patterns, scale and what your team can operate.
How accurate is LLM-based extraction for building knowledge graphs?
It varies with document type, schema clarity and the model used, so measure it on your own documents. Extraction tends to be strong for clearly stated facts and weaker for implied relationships, long-range references across pages and domain-specific terms. Good practice includes a tight schema with definitions, few-shot examples, confidence scores, source references for every fact, and human review of low-confidence or high-impact facts before they enter the trusted graph. Track precision and recall on a labeled sample as you change models or prompts.