P

Knowledge Graph: Definition and Examples

A Knowledge Graph is a data structure that organizes information as a network of relationships between entities, allowing AI systems to understand and reason about the links between different concepts.

Full definition

A Knowledge Graph is a structured representation of information that models relationships between real-world entities. Unlike a classic database organized in tables, a Knowledge Graph uses triplets (subject → relation → object) to capture the richness of connections between concepts. For example, "Paris → is the capital of → France" or "GPT-4 → is developed by → OpenAI."

This technology is at the heart of modern search engines like Google, which has used its own Knowledge Graph since 2012 to enrich search results with contextual information. When you see an information box to the right of a Google search (birth date of a celebrity, population of a city), it is the Knowledge Graph providing that structured data.

In artificial intelligence, Knowledge Graphs play a crucial role in anchoring language models to verifiable facts. They help reduce hallucinations by offering a structured source of truth that the AI can consult. This hybrid approach — combining the generative power of LLMs with the factual precision of knowledge graphs — is one of the most promising avenues for improving the reliability of AI systems.

In the context of prompt engineering, understanding Knowledge Graphs allows you to better structure your queries by making relationships between concepts explicit. An informed user can ask an LLM to reason in graph terms, identify implicit connections between ideas, or build a structured representation of a knowledge domain from raw text.

Etymology

The term "Knowledge Graph" was popularized by Google in May 2012 with the launch of its eponymous system, under the slogan "Things, not strings." However, the underlying concept existed since the 1970s in artificial intelligence research under the names "semantic networks" and "ontologies." The word "graph" refers to graph theory in mathematics, where information is represented as nodes (entities) connected by edges (relationships).

Concrete examples

Structured knowledge extraction from a text

From the following text, build a Knowledge Graph in triplet form (entity → relation → entity). Identify all named entities and their explicit and implicit relationships: [PASTE_TEXT]

Enriching a search through relational reasoning

Reasoning as a Knowledge Graph, what are the indirect links between artificial intelligence and personalized medicine? Identify the intermediate entities and the relationships that connect them.

Factual verification and hallucination reduction

Verify the following claims by breaking each one into subject-relation-object triplets, then assess whether each triplet is factual, plausible, or incorrect: [LIST_OF_CLAIMS]

Practical usage

In prompt engineering, Knowledge Graphs are useful for asking an LLM to structure complex information into explicit relationships between entities. You can use them to create knowledge bases from unstructured documents, or to guide the model's reasoning by asking it to trace connections between concepts. This approach is particularly effective for tasks of summarization, comparative analysis, and factual verification.

Related concepts

RAG (Retrieval-Augmented Generation)EmbeddingsOntologySemantic Web

FAQ

What is the difference between a Knowledge Graph and a relational database?
A relational database organizes data into tables with predefined columns, imposing a rigid schema. A Knowledge Graph, on the other hand, uses flexible triplets (subject-relation-object) that allow new relationships and entities to be added easily without restructuring the whole. The Knowledge Graph excels at representing heterogeneous and highly interconnected data, whereas a relational database is better suited for uniform tabular data.
How do Knowledge Graphs help reduce LLM hallucinations?
Knowledge Graphs serve as an external source of truth that the LLM can consult via a RAG (Retrieval-Augmented Generation) system. Instead of relying solely on its parametric memory, the model can verify facts in the graph before answering. This approach anchors responses in verified data and provides traceable sources for each claim.
Can an LLM be asked to create a Knowledge Graph from a text?
Yes, this is one of the most common use cases. By asking the LLM to extract named entities and their relationships in triplet form, you can build a Knowledge Graph from any text corpus. It is recommended to specify the desired output format (JSON, list of triplets, Mermaid format for visualization) and ask the model to distinguish explicit from inferred relationships.

See also

How to use this prompt

  1. Copy the prompt with the button above.
  2. Paste it into ChatGPT, Claude or your favorite AI assistant.
  3. Replace the bracketed variables with your details, then refine the result.

About Prompt Guide

Prompt Guide is a free library of 2500+ ready-to-use prompts for ChatGPT, Claude and other AIs, with guides to learn prompting and tools to build and optimize your own prompts.

More definitions

Get new prompts every week

Join our newsletter.