Skip to content
SDB
Knowledge Graphs

Chapter 08 · beginner · 20 min

Real-World Use Cases

How knowledge graphs power production systems at Google, in medicine, finance, and AI

Subhendu Datta BhowmikAI Tutorials

Knowledge Graphs in Production

After learning the fundamentals, let's look at how leading organizations apply knowledge graphs to solve real-world problems. Each use case demonstrates different aspects of what makes knowledge graphs uniquely powerful.

Use Case 1: Google Knowledge Graph

Google introduced the Knowledge Graph in 2012 to improve search results. When you search for "Albert Einstein", you see a rich info panel — that's the Knowledge Graph in action.

How it works:

  • Entities (people, places, things) are represented as nodes
  • Billions of relationships connect them
  • When you search for a person, Google disambiguates the entity: "Einstein" → physicist, not a street name
  • The graph enables semantic search: understanding what you're searching for, not just matching keywords

Scale:

  • Over 500 billion facts
  • Covers ~5 billion entities
  • Powers Google Search, Google Assistant, Google Maps
Knowledge graph6 nodes · 6 edges

Nodes

  • Albert Einsteinperson

    Physicist (1879–1955)

  • Physicsfield

    Branch of natural science

  • Theory of Relativityconcept

    Framework in modern physics

  • Nobel Prize (Physics 1921)award

    Nobel Prize in Physics 1921

  • Princeton Universityorg

    University in New Jersey

  • Photoelectric Effectconcept

    Emission of electrons by light

Edges

  • albertfieldphysics
  • albertdevelopedrelativity
  • albertreceivednobelprize
  • albertworkedAtprinceton
  • nobelprizeawardedForphotoelectric
  • photoelectricpartOfphysics
A mini knowledge graph modeled after the Google Knowledge Graph for Albert Einstein. Click any node to explore relationships.

Use Case 2: Wikidata

Wikidata is a free, collaborative, multilingual knowledge base maintained by the Wikimedia Foundation. It serves as the structured data backbone for Wikipedia.

Key facts:

  • 100M+ statements covering all topics
  • Multilingual: data accessible in any language
  • Powers Wikipedia's infoboxes, categories, and maps
  • Used by researchers, AI systems, and governments worldwide
  • Query interface: https://query.wikidata.org (SPARQL)

Example — Every country's capital in 3 lines of SPARQL:

SELECT ?country ?capital WHERE {
  ?country wdt:P36 ?capital .
}

Use Case 3: Life Sciences and Medicine

Knowledge graph6 nodes · 6 edges

Nodes

  • Metformindrug

    Drug: Type 2 diabetes medication

  • Type 2 Diabetesdisease

    Metabolic disease with high blood sugar

  • Insulin Resistancecondition

    Reduced response to insulin

  • AMPK Proteinprotein

    AMP-activated protein kinase

  • Liverorgan

    Primary target organ of Metformin

  • Obesitycondition

    Risk factor for Type 2 Diabetes

Edges

  • metformintreatst2d
  • metforminactivatesampk
  • metformintargetsOrganliver
  • t2dcausedByinsulin
  • obesityriskFactorOft2d
  • ampkreducesinsulin
A biomedical knowledge graph showing drug-disease-protein relationships. Used in drug discovery to identify new treatment targets.

Biomedical KG Applications:

  • Drug discovery: Find proteins that interact with known disease pathways
  • Clinical decision support: Alert clinicians to drug-drug interactions
  • Genomics: Connect genes, variants, phenotypes, and diseases
  • Literature mining: Extract relationships from millions of papers

Real systems:

  • UniProt — protein knowledge base with 200M+ entries
  • Gene Ontology (GO) — standardized vocabulary for gene function
  • SNOMED CT — clinical terminology with 350K+ concepts and 1.5M+ relationships
  • OpenTargets — drug target identification platform (drug-gene-disease KG)

Use Case 4: Financial Services — Fraud Detection

Knowledge graph6 nodes · 6 edges

Nodes

  • Transaction #TX-4521transaction

    Suspicious $9,800 wire transfer

  • Account A-2291account

    Sending account

  • Account A-9941account

    Receiving account

  • John Doeperson

    Account holder

  • IP: 192.168.x.xip

    Login IP — flagged in 3 other cases

  • Device DV-007device

    Mobile device used for login

Edges

  • acc1initiatedBytx1
  • tx1sentToacc2
  • person1ownsacc1
  • person1usedIPip1
  • person1usedDevicedevice1
  • ip1linkedToacc2
A financial fraud detection knowledge graph. Red nodes indicate flagged entities. Graph traversal reveals connected suspicious patterns.

Why Graphs Excel at Fraud Detection:

Traditional fraud detection checks individual transactions in isolation. Knowledge graphs reveal patterns across the network:

  • Ring fraud: Multiple accounts controlled by the same person (same IP, device, phone)
  • Money mule networks: Chains of transfers designed to obscure the origin
  • Synthetic identity fraud: Detecting shared attributes across "different" identities

Graph pattern: A new account (open < 7 days) makes a near-limit transfer to another account that shares an IP address with 3 other flagged accounts. No individual data point looks suspicious — only the graph reveals the pattern.

Real systems:

  • JPMorgan Chase: Uses graph analytics to detect market manipulation
  • HSBC: Knowledge graph for anti-money-laundering compliance
  • Stripe: Graph-based fraud scoring for payment networks

Use Case 5: GraphRAG — Knowledge Graphs + LLMs

Knowledge graph6 nodes · 6 edges

Nodes

  • User Queryinput

    "Who are the top AI researchers at MIT?"

  • Knowledge Graphstore

    Structured entity-relationship store

  • Retrieved Subgraphdata

    Relevant nodes and edges from KG

  • Structured Contextdata

    Serialized graph facts as LLM context

  • LLMmodel

    Large language model generates answer

  • Grounded Answeroutput

    Factually grounded response with citations

Edges

  • queryretrieves fromkg
  • kgreturnssubgraph
  • subgraphserialized ascontext
  • querysent tollm
  • contextinjected intollm
  • llmgeneratesanswer
The GraphRAG architecture: a user query retrieves a structured subgraph which is injected as context into an LLM, producing grounded answers.

The Problem with Plain RAG

Standard RAG (Retrieval-Augmented Generation) retrieves text chunks from a vector store and injects them into an LLM prompt. But text chunks lack:

  • Structured relationships
  • Multi-hop reasoning ("who are colleagues of colleagues of Alice?")
  • Formal entity disambiguation

GraphRAG: The Solution

GraphRAG (popularized by Microsoft Research in 2024) replaces the vector store with a knowledge graph:

  1. Query arrives: "Who are the top AI researchers at MIT and what have they published recently?"
  2. Named Entity Recognition extracts: MIT, AI researchers, publications
  3. Graph retrieval finds: MIT nodes → connected Person nodes (isAffiliatedWith MIT, researchArea AI) → their Publication nodes
  4. The subgraph is serialized as structured context (Turtle or JSON) and injected into the LLM prompt
  5. The LLM generates an answer grounded in the graph facts, with citations

Benefits:

  • Factual grounding — reduces hallucinations
  • Multi-hop reasoning — follows chains of relationships
  • Explainability — every fact in the answer traces back to a graph triple
GraphRAG — constructing an LLM prompt from a knowledge graph subgraphpython
from rdflib import Graph, Namespace
from anthropic import Anthropic

EX = Namespace("http://example.org/")

def retrieve_subgraph(g: Graph, entity_uri: str, depth: int = 2) -> str:
    """Retrieve a subgraph around an entity and serialize as facts."""
    # SPARQL query: get all facts within 2 hops of the entity
    query = f"""
    CONSTRUCT {{
        ?s ?p ?o .
        <{entity_uri}> ?p1 ?o1 .
    }}
    WHERE {{
        {{
            <{entity_uri}> ?p1 ?o1 .
        }} UNION {{
            <{entity_uri}> ?p1 ?mid .
            ?mid ?p ?o .
        }}
    }}
    """
    subgraph = Graph()
    subgraph += g.query(query)

    # Serialize as readable Turtle
    return subgraph.serialize(format="turtle")

def graphrag_query(kg: Graph, user_question: str, entity_uri: str) -> str:
    """Answer a question using GraphRAG."""
    # 1. Retrieve relevant subgraph
    context = retrieve_subgraph(kg, entity_uri)

    # 2. Build structured prompt
    prompt = f"""You are a knowledge assistant. Use the following knowledge graph
facts to answer the question accurately. Only use information from the provided
facts — do not hallucinate.

<knowledge_graph_facts>
{context}
</knowledge_graph_facts>

<question>
{user_question}
</question>

Answer based solely on the provided facts. Cite the relevant triples."""

    # 3. Call LLM
    client = Anthropic()
    message = client.messages.create(
        model="claude-opus-4-6",
        max_tokens=1024,
        messages=[{"role": "user", "content": prompt}]
    )

    return message.content[0].text

# Example usage
kg = Graph()
kg.parse("knowledge_graph.ttl", format="turtle")

answer = graphrag_query(
    kg,
    "Where does Alice work and what city is that company in?",
    "http://example.org/person/alice"
)
print(answer)

What's Next?

Congratulations — you've completed the Knowledge Graph Tutorial! You now understand:

✓ The fundamentals: nodes, edges, and triples ✓ RDF, Turtle, and JSON-LD serialization ✓ Ontologies with RDFS and OWL ✓ Querying with SPARQL ✓ Property graphs vs RDF models ✓ Building graphs with Python rdflib ✓ Inference and reasoning ✓ Real-world production applications

Continue Learning

  • Advanced SPARQL: property paths, aggregations, federated queries
  • Knowledge Graph Embeddings: TransE, RotatE, ComplEx for ML on graphs
  • Semantic similarity: Graph neural networks on knowledge graphs
  • Ontology design patterns: modular ontology patterns for common scenarios
  • Linked Open Data: Contributing to and consuming the web of data

Knowledge Graphs