A knowledge graph is a structured representation of knowledge in which entities are nodes and typed relationships are edges, organized by a schema or ontology that gives each node and relation a defined meaning. In artificial intelligence, and particularly in retrieval & knowledge systems, it lets software store facts such as which company acquired which firm, query them precisely and reason over connections that are scattered across many documents.
Knowledge graphs complement statistical methods such as embeddings and semantic search. Where a vector index finds text that is similar to a query, a knowledge graph answers questions that depend on explicit, verifiable relationships, which is why it is increasingly combined with language models in approaches such as GraphRAG.
How a knowledge graph represents knowledge
The basic unit of a knowledge graph is a fact expressed as a triple: subject, predicate and object, for example a drug, the relation treats and a disease. Entities carry unique identifiers, types such as Person or Organization, and attributes such as dates or quantities. A schema or ontology defines which types exist, which relations may connect them and which constraints apply.
Because every entity has one identifier, facts gathered from different sources about the same thing merge onto the same node. This identity layer is what distinguishes a knowledge graph from a set of unconnected records and makes multi-hop questions possible.
| Element | Role | Example |
|---|---|---|
| Entity or node | A uniquely identified thing | A specific company or person |
| Relation or edge | A typed link between entities | Employs, located in, part of |
| Attribute or property | A literal value on a node or edge | Founding year, start date |
| Class or type | A category of entities | Organization, Product, Disease |
| Ontology | Formal definitions and constraints | Every employee is a Person |
| Provenance | Where and when a fact came from | Source document, extraction date |
Data models, standards and query languages
Two data models dominate practice. The RDF model represents everything as triples with globally unique identifiers and is standardized together with the OWL ontology language and the SPARQL query language. The labeled property graph model allows properties directly on nodes and edges and is queried with languages such as Cypher and the standardized GQL.
| Aspect | RDF and OWL | Labeled property graph |
|---|---|---|
| Basic unit | Triple with identifiers | Node and edge with properties |
| Edge properties | Through reification or RDF-star | Native |
| Query language | SPARQL | Cypher, GQL |
| Reasoning | Formal inference from ontologies | Mostly application logic and algorithms |
| Typical strength | Data integration across organizations | Developer-friendly traversal and analytics |
Validation languages such as SHACL check that data conforms to expected shapes, for example that every product has exactly one manufacturer. Choosing a model depends more on integration and reasoning needs than on performance alone.
How knowledge graphs are built and maintained
Construction combines structured sources, such as databases and catalogs, with information extraction from text. The extraction pipeline usually performs named entity recognition, entity linking to existing identifiers and relation extraction, increasingly with language models doing much of the work.
| Step | Purpose | Typical difficulty |
|---|---|---|
| Schema design | Define types and relations | Balancing detail against usability |
| Entity extraction | Find mentions of entities | Ambiguous names and abbreviations |
| Entity resolution | Merge mentions of the same entity | False merges and missed duplicates |
| Relation extraction | Identify typed links | Implicit or negated statements |
| Validation and curation | Check constraints and quality | Scale of manual review |
| Updating | Keep facts current | Expiring and conflicting facts |
Entity resolution is usually the hardest step. Merging two different people with the same name corrupts every downstream answer, while failing to merge duplicates splits knowledge across nodes and hides connections.
Knowledge graphs in retrieval and AI systems
In retrieval-augmented generation, a knowledge graph supplies precise, connected context to a language model. Instead of retrieving only text chunks by vector similarity, the system identifies entities in the question, traverses their relationships and passes the relevant subgraph or its source passages to the model, which improves grounding and traceability.
| Method | What it retrieves | Best for |
|---|---|---|
| Vector search with embeddings | Semantically similar chunks | Open questions over unstructured text |
| BM25 keyword search | Chunks with matching terms | Exact names, codes and rare terms |
| Knowledge graph query | Entities and explicit relations | Multi-hop, aggregate and constraint questions |
| GraphRAG | Graph structure plus source text | Corpus-wide themes and connected facts |
Graphs also support graph algorithms such as shortest paths, centrality and community detection, and knowledge graph embeddings that encode nodes as vectors for link prediction, the task of inferring missing relations.
Limitations and common pitfalls
Knowledge graphs are expensive to build and maintain, and their value depends on coverage and accuracy. A graph is always incomplete, so the absence of a fact does not mean the fact is false, a principle known as the open-world assumption in RDF reasoning.
- Over-engineered ontologies slow adoption; start with the relations that answer real questions.
- Missing provenance makes facts impossible to audit or retract.
- Stale facts such as former roles or prices mislead unless facts carry validity dates.
- Automated extraction errors compound across hops; sample and review extracted triples.
- Unclear ownership of the schema leads to duplicate relations with overlapping meanings.
Successful projects usually begin with a narrow, high-value domain, measure answer quality on real questions and expand the schema only when new questions require it.
In simple terms
A knowledge graph is like a detailed map of how things are connected. Each dot on the map is a thing, such as a person, a company or a city. Each line says how two things relate. For example, a person works for a company, and the company is based in a city.
Because the connections are written down clearly, a computer can follow them from dot to dot. This lets it answer questions that no single document answers. It could find which suppliers of a company sit in a flooded region. The main idea is simple: knowing the connections is often as important as knowing the facts.
A practical example
A pharmaceutical research team maintains a knowledge graph linking drugs, protein targets, genes, diseases, clinical trials and publications. Facts come from curated databases and from language-model extraction over several hundred thousand abstracts, with every extracted triple linked to its source sentence and a confidence score.
When researchers ask which approved drugs act on targets associated with a rare disease, the system traverses disease to gene to protein to drug in seconds and returns a ranked list with supporting evidence. An assistant built on the graph explains each candidate using the linked passages. Scientists still validate every lead, but the graph reduces literature review from weeks to days and makes each suggestion traceable to its evidence.