AI
What Is a Knowledge Graph? Examples and AI Uses
A knowledge graph stores facts as entities and relationships. How it works, an example, ontologies, graph databases, LLM and RAG uses, and limits.
A knowledge graph is a way of storing information as a network of entities (people, companies, products, places, concepts) connected by relationships (works at, located in, made by, part of). Instead of rows in a table or paragraphs in a document, facts are stored as small statements like Ada Lovelace → collaborated with → Charles Babbage, which software can follow, query and reason over. Google's search panels, Wikidata, product recommendations, fraud detection and many enterprise AI assistants rely on knowledge graphs to connect facts that live in different places.
This guide explains what a knowledge graph is and how it works, walks through a simple knowledge graph example, covers ontologies and graph databases, explains how knowledge graphs work with LLMs and RAG, and lists when they're worth the effort.
What Is a Knowledge Graph?
Every knowledge graph has three basic parts:
- Nodes (entities): the things you care about, each with a unique identity. "Paris" the city and "Paris" the person are different nodes.
- Edges (relationships): typed, directed connections between nodes, such as headquartered in or reports to.
- Properties (attributes): details stored on nodes or edges, such as a city's population or the start date of a job.
What turns a graph of data into a knowledge graph is meaning: the types of entities and relationships are defined in a schema or ontology, so software knows that reports to connects two employees, or that a city is located in a country. That shared meaning lets different systems combine their data and lets software infer new facts.
The term became widely known in 2012, when Google introduced its Knowledge Graph with the slogan "things, not strings". Google said it contained more than 500 million objects and 3.5 billion facts about them at launch. Today the largest open knowledge graph, Wikidata, holds more than 120 million items, edited by volunteers and used by search engines, AI systems and researchers.
How a Knowledge Graph Works
The basic unit of a knowledge graph is a triple: subject, predicate, object.
- Acme Robotics → headquartered in → Munich
- Munich → located in → Germany
- Jane Smith → CEO of → Acme Robotics
Because the triples share nodes, they link into a graph. Software can then answer questions that span several facts, such as "Which CEOs run companies headquartered in Germany?", by following edges: from Germany, back to cities located in it, to companies headquartered there, to their CEOs. In a relational database, the same question needs several joins across tables; in a graph, it's a natural path.
Knowledge graphs are built from three main sources:
- Structured data already in databases, spreadsheets and APIs, mapped onto the graph's schema.
- Unstructured text such as documents and web pages, where entities and relationships are extracted, today often with LLMs.
- People: curators and domain experts who add, review and correct facts.
A crucial and often underestimated step is entity resolution: recognizing that "IBM", "International Business Machines" and "I.B.M." are the same company, and that two people named John Smith are not.
A Knowledge Graph Example
Here's a small knowledge graph example for a company's internal knowledge:
| Subject | Relationship | Object |
|---|---|---|
| Payments API | owned by | Team Atlas |
| Team Atlas | part of | Platform group |
| Maria Lopez | member of | Team Atlas |
| Payments API | depends on | Ledger Service |
| Ledger Service | runs in | eu-west region |
| Incident 4821 | affected | Ledger Service |
| Runbook 12 | documents | Ledger Service |
With just these seven facts, the graph can answer questions no single document answers:
- Who should I page if the Ledger Service fails? Follow Ledger Service → depended on by Payments API → owned by Team Atlas → members.
- Which services were affected by incidents in the eu-west region? Follow region → services running there → incidents.
- Which runbook should an engineer read for the Payments API outage? Follow the dependency chain to the documented service.
This is why knowledge graphs are popular for IT operations, enterprise search and AI assistants: the answers depend on relationships spread across many systems.
Ontology, Taxonomy and Schema
These three terms come up constantly:
- Taxonomy: a hierarchy of categories, such as Vehicle → Car → Electric car. It organizes things but only describes "is a kind of" relationships.
- Ontology: a formal model of a domain: the types of entities, the relationships allowed between them, their properties and rules (for example, every employee works for exactly one company). An ontology lets software check data and infer new facts.
- Schema: the practical structure of a particular graph, often a simpler, application-focused version of an ontology.
Public vocabularies help graphs interoperate. Schema.org, backed by the major search engines, defines common types like Organization, Product and Event, and websites use it in structured data so search engines can add them to their knowledge graphs. That's also why "knowledge graph" comes up in SEO: Google's Knowledge Panel shows facts from its graph about people, places and organizations.
Knowledge Graph vs Graph Database
Knowledge graph vs graph database is a common confusion:
- A graph database is software for storing and querying graph-shaped data efficiently, such as Neo4j, Amazon Neptune, Memgraph or TigerGraph.
- A knowledge graph is the content and meaning: the entities, relationships and ontology that describe a domain.
You can store a knowledge graph in a graph database, but also in a relational database or as files, and a graph database can hold data that isn't a knowledge graph (for example, a raw social network without a schema).
There are also two main data models:
| RDF triple stores | Property graphs | |
|---|---|---|
| Data model | Subject-predicate-object triples with global identifiers (URIs) | Nodes and edges, both with key-value properties |
| Query language | SPARQL | Cypher, openCypher and the ISO standard GQL |
| Standards | W3C standards (RDF, RDFS, OWL, SHACL) | ISO GQL standard published in 2024 |
| Strengths | Linking data across organizations, formal reasoning, shared vocabularies | Developer friendliness, fast traversals, application data |
| Examples | Wikidata, many government and life-science datasets | Neo4j and similar databases in enterprise apps |
Many teams start with a property graph for its simplicity, and use RDF when they need standards-based data exchange or formal reasoning.
How Knowledge Graphs Are Used
- Search engines: answer boxes and knowledge panels, and understanding which "Jaguar" you mean.
- Recommendations: connecting users, products, categories and behaviour to suggest related items.
- Fraud and financial crime: finding rings of accounts, devices and addresses that are connected in suspicious ways.
- Life sciences: linking genes, proteins, diseases, drugs and papers to find research leads.
- Supply chains: mapping suppliers, parts, factories and risks several tiers deep.
- IT and security: mapping assets, dependencies, vulnerabilities and access rights.
- Enterprise knowledge and AI assistants: connecting people, projects, documents and systems so an assistant can answer questions that span them.
Knowledge Graphs and LLMs
Knowledge graphs and large language models complement each other:
- LLMs help build graphs. Extracting entities and relationships from text used to require custom models; now an LLM can read documents and output triples matching your schema, which people or rules then review.
- Graphs help LLMs answer accurately. An LLM's knowledge is fixed at training and can be wrong or vague about specific facts. A knowledge graph supplies precise, current facts and relationships the model can cite.
- Graphs give agents memory. Some agent memory systems store what they learn about users and projects as a graph of entities and relationships, which our guide to AI agent memory covers.
Knowledge Graph vs RAG
The knowledge graph vs RAG question isn't either-or. Standard retrieval-augmented generation splits documents into chunks, finds the chunks most similar to the question using vector search, and gives them to the LLM. That works well for questions answered in one or two passages.
It struggles when the answer depends on relationships across many documents, such as "Which suppliers of our top three products had quality incidents this year?", or on summarizing a whole collection. A knowledge graph handles those by following edges.
| Vector RAG | Knowledge graph | |
|---|---|---|
| Stores | Text chunks and embeddings | Entities, relationships, properties |
| Best at | Finding relevant passages for direct questions | Multi-hop questions, aggregations, exact relationships |
| Setup effort | Low | Higher: schema, extraction, entity resolution |
| Explainability | Shows retrieved passages | Shows the path of facts used |
| Freshness | Re-embed changed documents | Update individual facts |
GraphRAG combines them: it builds a graph from documents and uses it alongside vector search during retrieval. Our GraphRAG vs RAG guide explains how it works and when it's worth the cost. Many systems also use hybrid search to combine keyword and vector retrieval before reaching for a graph.
How to Build a Knowledge Graph
- Start with questions. List the questions you want to answer; they decide which entities and relationships matter.
- Design a small schema: a handful of entity types and relationships. Reuse public vocabularies such as schema.org where they fit.
- Load structured data first, from databases and APIs, where facts are already reliable.
- Extract from text with an LLM or NLP pipeline, constrained to your schema, and review samples for accuracy.
- Resolve entities so duplicates merge and different things stay apart.
- Choose storage: a graph database for traversal-heavy apps, or a relational database or files for small graphs.
- Keep it current with pipelines that update facts as source systems change, and record where each fact came from.
Limitations and Common Mistakes
- Building before knowing the questions, which produces a huge graph nobody uses.
- Over-engineering the ontology with hundreds of types before any data is loaded.
- Ignoring entity resolution, leaving duplicate and merged entities that make answers wrong.
- Trusting extracted facts blindly: LLM extraction makes mistakes; keep provenance and review.
- Letting the graph go stale: a graph is only as good as its update pipeline.
- Using a graph where a table would do: simple, flat data doesn't need a graph.
FAQ
What is a knowledge graph in simple terms?
It's a network of facts: things (like people, companies and products) connected by labelled relationships (like works at or made by), with a shared definition of what those things and relationships mean, so software can query and connect the facts.
What is a knowledge graph in AI?
In AI, knowledge graphs provide structured, reliable facts and relationships that models can use for search, recommendations and reasoning. With LLMs, they're used to ground answers in verified facts, answer multi-step questions and give AI agents structured memory.
What is the difference between a knowledge graph and a graph database?
A knowledge graph is the data and its meaning: entities, relationships and an ontology describing a domain. A graph database is software that stores and queries graph-shaped data. Knowledge graphs are often stored in graph databases, but not always.
Is a knowledge graph better than RAG?
They solve different problems. Vector-based RAG is simpler and good at finding relevant passages; knowledge graphs are better for questions that depend on relationships across many documents. GraphRAG combines both.
What is an example of a knowledge graph?
Google's Knowledge Graph behind search knowledge panels and Wikidata, with more than 120 million items, are well-known public examples. Companies also build internal knowledge graphs of products, customers, systems or research data.