Scrapeless Wiki

What Is a Knowledge Graph? – Definition and How It Works

Informational P2 what is a knowledge graph

Learn what a knowledge graph is, how entities and relationships are modelled, how one is built from web data, and where it beats a table.

A knowledge graph stores entities and the relationships between them, rather than rows in tables. Its shape suits questions about connections, which relational structures answer awkwardly.

1. The Model

Facts are triples: a subject, a predicate, and an object.

(Acme Corp) --[headquartered_in]--> (Austin)
(Acme Corp) --[produces]--> (Widget)
(Widget)    --[category]--> (Tools)

Entities carry types and attributes; relationships carry direction and often their own properties, such as when a fact became true.

2. Why Relationships as First-Class Objects Help

In a relational model, traversing several relationships means several joins, and each additional hop costs more. In a graph, traversal follows edges directly, so multi-hop questions stay tractable.

Questions like "which suppliers connect to this company through at most three intermediaries" are natural in a graph and painful in SQL.

3. Building One From Web Data

  1. Extract entities β€” organisations, products, people, places β€” from pages and structured islands.
  2. Resolve them. The same entity appears under many names; this is the hardest stage.
  3. Extract relationships from text, tables, and structured data.
  4. Attach provenance β€” which source asserted each fact, and when.
  5. Reconcile conflicts between sources.

Entity resolution is where quality is decided. Merge wrongly and the graph asserts things about a company that were true of a different one.

4. Provenance Is Not Optional

Facts collected from the web have varying reliability. Storing the source and timestamp with each edge allows filtering by trust, resolving contradictions by recency, and answering questions about where a claim came from.

A graph without provenance cannot be audited, and an unauditable graph is difficult to trust once it is large.

5. Where It Beats a Table

Question type Fits
Aggregate over rows Table
Filter and group Table
Multi-hop connections Graph
Shortest path between entities Graph
Heterogeneous entity types Graph
Sparse, varying attributes Graph

6. Where It Is Overkill

For fixed-schema tabular data with predictable joins, a relational store is simpler, faster, and better understood. Adopting a graph because the domain "has relationships" β€” which every domain does β€” adds operational complexity for nothing.

The test is whether multi-hop traversal is a routine query, not whether relationships exist.

7. Use With Language Models

Graphs are increasingly paired with retrieval: an entity mentioned in a question is resolved, its neighbourhood retrieved, and that subgraph placed in the context.

This grounds answers in explicit relationships rather than in whatever similarity search happened to surface β€” useful precisely where a question spans several connected entities.

8. Summary

A knowledge graph models entities and their relationships as first-class objects, making multi-hop and path questions natural.

Building one from web data is mostly entity resolution and provenance rather than storage. Adopt it when traversal is a routine query pattern, and keep a table when the questions are aggregations.