Overview

1 Knowledge graphs and LLMs: a killer combination

Artificial intelligence—especially generative models—has changed how people interact with technology, yet mission-critical domains still demand accuracy, transparency, and fresh, domain-grounded knowledge that generic LLMs struggle to provide on their own. This chapter introduces knowledge graphs (KGs) as structured, contextual, and explainable representations of entities and their relationships, and shows why pairing them with LLMs creates a compelling foundation for advanced applications. The two technologies are presented as complementary: KGs bring verifiable, updatable knowledge and provenance, while LLMs contribute powerful natural language understanding and generation. The result is a “killer combination” aimed at sectors like healthcare, finance, and law enforcement, and at practitioners who need both expressive knowledge management and intuitive user experiences.

The chapter details how LLMs strengthen KGs by extracting entities and relations from unstructured text, accelerating graph construction, easing complex querying through natural language, and summarizing multi-hop results into clear answers. In the opposite direction, KGs mitigate LLM limitations by grounding responses to trusted data, reducing hallucinations, improving explainability, and keeping knowledge current without retraining an entire model. Together they enable natural language access to deeply connected organizational knowledge, harmonize heterogeneous sources, and support sophisticated reasoning and analysis. This synergy sets up a positive flywheel in which better graphs yield better model behavior, which in turn enriches the graphs. Concrete scenarios—such as drug discovery and conversational customer support—illustrate the practical value of the approach.

From an implementation view, the chapter frames a paradigm shift from rigid, siloed databases to graph-centered knowledge substrates built on four pillars: evolution (flexible, ever-growing structures), semantics (typed entities and meaningful relationships), integration (uniting structured and unstructured sources), and learning (reasoning and analytics for humans and machines). It advocates pragmatic, “just enough” semantics via taxonomies and ontologies, avoiding unnecessary rigidity while preserving interpretability and inference. The book is technology-agnostic, drawing on both RDF/SPARQL and labeled property graphs with openCypher/Gremlin, and explains their complementary strengths. Readers are guided to model schemas, ingest and validate data, apply modern ML (including GNNs), and use LLMs for extraction, query generation, and summarization—always anchored in business goals and demonstrated through real-world, end-to-end examples.

Example of a KG in the healthcare domain. The nodes (the circles) represent the entities, like people, diseases, anatomic parts, etc. The edges represent meaningful connections among entities. Both nodes and edges have properties describing relevant details.
Transfer Learning high-level principles. In transfer learning a model (or part of it) trained on a specific task (e.g. predicting randomly masked tokens) is then copied to be part of the training and the prediction for another task (e.g. relation extraction).
LLMs building blocks and differentiating characteristics.
Knowledge graph building with and without LLMs and LLMs support for querying and retrieval.
Summary of how LLMs and KGs can complement each other. Inspired by [11].
The four pillars of KGs: evolution, semantics, integration, and learning

Summary

  • LLMs and KGs empower each other by overcoming individual limitations when used in isolation.
  • LLMs support KG creation from structured data and simplify the querying phase.
  • KGs provide ground knowledge for LLMs to answer domain-specific questions using up-to-date and private data.
  • Data-driven systems with contextualized knowledge are strategic for high-impact applications like recruitment tools and medical predictions.
  • KGs represent a core abstraction for incorporating human knowledge into machines, while LLMs provide natural language understanding capabilities.
  • KG and LLM adoption represents a paradigm shift where intelligent behavior is encoded once in a unique source of trust. This empowers data representation for different applications and diverse tasks.
  • KGs are ever-evolving graph data structures containing typed entities, their attributes, and meaningful relationships. They are built for specific domains from structured and unstructured data to craft knowledge for both humans and machines.
  • KGs have four pillars: evolution, semantics, integration, and learning.
  • KGs and LLMs support critical domains with data-driven decisions across multiple applications. These include Customer 360 for banking, drug discovery, retail recommendations, and conversational systems.
  • Two key technologies represent KGs: Resource Description Framework (RDF) and labeled property graphs (LPG).
  • Taxonomies and ontologies play fundamental roles by incorporating semantic metadata that makes traditional graphs smarter.
  1. J. Launchbury. “A DARPA Perspective on Artificial Intelligence” (2020). Accessed: May 5, 2022. [Online].
  2. J. Yosinski, et al., "How transferable are features in deep neural networks?," Proceedings of the 27th International Conference on Neural Information Processing Systems - Volume 2 (p./pp. 3320--3328), Cambridge, MA, USA: MIT Press, Accessed: July 26, 2024. [Online]. Available: https://arxiv.org/abs/1411.1792
  3. A. Vaswani et al., "Attention is all you need," In Proceedings of the 31st International Conference on Neural Information Processing Systems (NIPS'17). Curran Associates Inc., Red Hook, NY, USA, 6000–6010, 2017. Accessed: July 26, 2024. [Online]. Available: https://arxiv.org/abs/1706.03762
  4. J. Devlin et al., "BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding," 2018, Accessed: July 26, 2024. [Online]. Available: https://arxiv.org/abs/1810.04805
  5. A. Radford et al., "Language models are unsupervised multitask learners," 2019. Accessed: July 26, 2024. [Online]. Available: https://api.semanticscholar.org/CorpusID:160025533
  6. OpenAI, GPT-4 Technical Report. 2023, Accessed: July 26, 2024. [Online]. Available: https://arxiv.org/abs/2303.08774
  7. J. W. Rae et al., "Scaling language models: Methods, analysis & insights from training Gopher," arXiv preprint arXiv:2112.11446, 2021, Accessed: July 26, 2024. [Online]. Available: https://arxiv.org/abs/2112.11446
  8. A. Chowdhery et al., "PaLM: Scaling language modeling with pathways," The Journal of Machine Learning Research, Volume 24, Issue 1 Article No.: 240, Pages 11324 - 11436, 2023, Accessed: July 26, 2024. [Online]. Available: https://dl.acm.org/doi/10.5555/3648699.3648939
  9. J. Kaplan et al., “Scaling Laws for Neural Language Models,” 2020, arXiv:2001.08361 [cs.LG], Accessed: July 26, 2024. [Online]. Available: https://arxiv.org/abs/2001.08361
  10. J. Z. Pan et al., "Large Language Models and Knowledge Graphs: Opportunities and Challenges," Transactions on Graph Data and Knowledge, 1, 2:1--2:38. doi: 10.4230/TGDK.1.1.2, 2023, Accessed: July 26, 2024. [Online]. Available: https://arxiv.org/abs/2308.06374
  11. S. Pan et al., "Unifying Large Language Models and Knowledge Graphs: A Roadmap," IEEE Transaction on Knowledge Data Engineering, 36, 3580-3599. 2024, Accessed: July 26, 2024. [Online]. Available: https://ieeexplore.ieee.org/document/10387715
  12. D. Grande et al., “Reducing data costs without jeopardizing growth.” McKinsey Digital, 2020. Accessed: May 5, 2022. [Online]. Available: https://www.mckinsey.com/business-functions/mckinsey-digital/our-insights/reducing-data-costs-without-jeopardizing-growth
  13. F. Lecue, “On the role of knowledge graphs in explainable AI,” Semantic Web, vol. 11 no. 1, pp. 41-51, 2020. Accessed: May 5, 2022. [Online]. Available: http://semantic-web-journal.org/system/files/swj2259.pdf
  14. H. Zhang et al., “Grounded conversation generation as guided traverses in commonsense knowledge graphs,” arXiv Labs, arXiv preprint arXiv:1911.02707, May 5, 2020. Accessed: May 5, 2022. [Online]. Available: https://arxiv.org/abs/1911.02707
  15. J. Barrasa, A. E. Hodler, and J. Webber, Knowledge Graphs. Sebastopol, CA, USA: O'Reilly Media, Inc., 2021. Accessed: May 5, 2022. [Online]. Available: https://www.oreilly.com/library/view/knowledge-graphs/9781098104863/

FAQ

What is a Knowledge Graph (KG) and how is it structured?A Knowledge Graph is an ever-evolving graph where nodes represent real-world entities, edges represent meaningful named relationships, and properties add context. It encodes domain knowledge in a structured, explainable form that supports reasoning and complex queries across connected data.
What are Large Language Models (LLMs) and why are they effective?LLMs are large neural networks trained on vast text corpora. Built on transfer learning and transformer architectures, they generalize across many NLP tasks, enabling natural language understanding and generation. With sufficient scale and high-quality data, performance improves markedly, making prompt-driven use practical.
Why are KGs and LLMs a “killer combination”?LLMs extract entities/relations from unstructured text, help generate queries, and summarize results; KGs ground LLM responses with reliable, up-to-date domain knowledge, reducing hallucinations and improving explainability. Together they deliver accurate, contextual, and user-friendly intelligent systems.
What key challenges have historically limited KG adoption?High costs to build and maintain, complex multi-hop access patterns, and results dispersed across many nodes/edges. Extracting knowledge from unstructured text (languages, typos, pronouns, styles, domain jargon) further increases complexity without the aid of modern NLP/LLMs.
How do LLMs help build and query Knowledge Graphs?LLMs accelerate entity and relationship extraction from unstructured sources (papers, reports), assist schema-aware querying via natural language, and produce clear textual summaries of graph results. They reduce the need for many task-specific NLP models and make graph access more accessible.
How do KGs mitigate common LLM limitations like hallucinations and stale knowledge?KGs provide trusted, structured facts that can ground generation, detect inconsistencies, and explain answers via explicit relationships. They also externalize knowledge so updates don’t require retraining the LLM, improving freshness and auditability for mission-critical domains.
What is the paradigm shift in data-driven applications described in the chapter?Move from rigid, purpose-built systems over siloed data to flexible, semantics-rich graphs as a single source of truth, with relationships as first-class citizens. LLMs add natural language interfaces and unstructured-data ingestion, enabling adaptable, explainable, enterprise-scale applications.
What are the four pillars of modern Knowledge Graphs?Evolution (flexible, ever-extensible structure), Semantics (typed entities and meaningful relationships), Integration (unifying structured and unstructured, multi-source data), and Learning (supporting human analysis, reasoning, and ML over graph structure).
How do RDF and Labeled Property Graphs (LPG) compare?RDF encodes knowledge as statements (triples) with strong semantic interoperability and SPARQL querying; LPG models nodes/edges with properties, favoring traversal and pathfinding via languages like openCypher/Gremlin. RDF suits ontology-driven consistency; LPG excels at rich property-based analysis. They can be complementary depending on use case.
How do I decide whether I need KGs, LLMs, or both?Use KGs if you must harmonize silos, connect structured/unstructured data, evolve schemas, ensure provenance, and power graph-centric search/recommendation/visualization/ML. Use LLMs for entity/relation extraction from text, interpreting complex queries, conversational interfaces, and summarization. Most real-world systems benefit from both.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$399.99
only $33.33 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Knowledge Graphs and LLMs in Action ebook for free
choose your plan

team

monthly
annual
$49.99
$399.99
only $33.33 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Knowledge Graphs and LLMs in Action ebook for free
choose your plan

team

monthly
annual
$49.99
$399.99
only $33.33 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Knowledge Graphs and LLMs in Action ebook for free