liveBook · Manning

What you will learn in Knowledge Graphs and LLMs in Action

Build AI systems using connected data

by Alessandro Negro with Vlastimil Kus, Giuseppe Futia and Fabio Montagna
Forewords by Maxime Labonne, Khalifeh AlJadda

Chapter by chapter

Chapter 1: Knowledge graphs and LLMs: A killer combination

The chapter introduces why knowledge graphs and large language models complement each other in domain-specific, data-driven applications.

1.1 Knowledge graphs · 1.2 Large language models · 1.3 KGs and LLMs: Stronger together · 1.4 The paradigm shift in data-driven applications · 1.4.1 The four pillars of knowledge graphs · 1.5 Building data-driven applications using KGs and LLMs · 1.5.1 Example use case: Drug discovery and development · 1.5.2 Example use case: Conversational AI for customer support · 1.5.3 Deciding whether to use a KG · 1.6 Knowledge graph technologies · 1.6.1 Taxonomies and ontologies · 1.7 How do we teach KGs and LLMs? · 1.8 Summary

What you learn in chapter 1 →

Chapter 2: Intelligent systems: A hybrid approach

The introduction frames intelligent advisor systems as combining KGs and LLMs to tackle complex problems, and argues that understanding their operation is necessary to judge their trustworthiness and safety.

2.1 What is intelligence? · 2.2 Designing an intelligent system · 2.2.1 What is an intelligent system? · 2.2.2 Categories of intelligent systems · 2.2.3 Characteristics of an intelligent system · 2.3 Knowledge acquisition and representation · 2.4 Reasoning · 2.5 Reasoning engines · 2.5.1 Limitations of a pure deductive reasoning engine · 2.5.2 Using inductive reasoning and ML · 2.5.3 The role of LLMs in the reasoning engine · 2.6 A KG approach to IASs · 2.7 Summary

What you learn in chapter 2 →

Chapter 3: Create your first knowledge graph from ontologies

The introduction explains why integrating diverse data into a knowledge graph is difficult and how an ontology can provide shared meaning, using rare-disease data as the chapter’s example.

3.1 Knowledge graph building: Warmup · 3.1.1 Business and domain understanding · 3.1.2 Data understanding · 3.2 Understanding knowledge graph technologies · 3.2.1 RDF or LPG? A goal-driven discussion · 3.2.2 Representing edge properties with RDF and LPG · 3.3 Building a knowledge graph · 3.3.1 Ontology ingestion and processing with neosemantics · 3.3.2 Annotation ingestion and processing · 3.4 Querying the data · 3.5 Reasoning over the KG · 3.6 Summary

What you learn in chapter 3 →

Chapter 4: From simple networks to multisource integration

The introduction frames the move from a single ontology to multisource knowledge graphs and explains why traditional integration, rather than LLMs, leads their construction.

4.1 Biomedical knowledge graphs and applications · 4.2 Multi-omic applications of KGs · 4.2.1 Creating a KG from the PPI and protein-disease networks · 4.2.2 High-level analysis of the resulting KGs · 4.2.3 Domain-specific analysis of the PPI and disease KG · 4.3 Pharmaceutical applications of KGs · 4.3.1 Deep analysis of the Hetionet knowledge graph · 4.3.2 LLM-assisted interpretation of pathway analysis results · 4.4 Clinical applications of KGs · 4.4.1 LLM-guided clinical decision support analysis · 4.5 Summary

What you learn in chapter 4 →

Chapter 5: Extracting domain-specific knowledge from unstructured data

Introduces why unstructured documents are valuable sources for knowledge graphs and frames the work as knowledge representation and knowledge learning.

5.1 The archives challenge · 5.2 Key concepts of knowledge extraction · 5.2.1 Recognizing named entities · 5.2.2 Extracting relations · 5.3 Building KGs with large language models · 5.3.1 Using LLMs · 5.3.2 Prompt engineering examples · 5.3.3 Prompt engineering guidelines · 5.3.4 KG building: Traditional NLP or LLMs? · 5.4 Summary

What you learn in chapter 5 →

Chapter 6: Building knowledge graphs with large language models

The introduction recalls what the Rockefeller Archive Center documents contain and sets up the move from extracted text to a knowledge graph.

6.1 Transforming an archive to a KG · 6.1.1 Graph modeling · 6.1.2 Creating a metagraph · 6.1.3 Normalization and cleansing · 6.1.4 Graph-based entity resolution · 6.2 Intellectual network analysis: The value of graphs · 6.3 Next steps in the Rockefeller Archive Center project · 6.4 The value of knowledge graphs in the LLM era · 6.5 Summary

What you learn in chapter 6 →

Chapter 7: Named entity disambiguation

The chapter introduction explains what named entity recognition contributes to building knowledge graphs from text and why it is not sufficient for precise domain understanding.

7.1 From recognition to disambiguation · 7.2 Understanding named entity disambiguation · 7.3 Domain-based NED and LLMs · 7.4 Business and domain understanding · 7.4.1 Context · 7.4.2 Use case definition · 7.5 Understanding the data · 7.5.1 Unstructured data · 7.5.2 Domain ontologies · 7.6 Building a SoHO knowledge graph · 7.6.1 Defining the schema · 7.6.2 Processing and ingesting documents · 7.6.3 Disambiguating and ingesting medical entities · 7.6.4 Processing, loading, and mapping ontologies · 7.6.5 Generating entity co-occurrences · 7.7 KG-based use cases · 7.7.1 Conceptual search · 7.7.2 Structured knowledge-based search · 7.7.3 KG-based interpretability and discovery · 7.7.4 Uncovering new knowledge · 7.8 Summary

What you learn in chapter 7 →

Chapter 8: NED with open LLMs and domain ontologies

The introduction recalls scispaCy’s biomedical role in Chapter 7 and previews Chapter 8’s approach to named entity disambiguation.

8.1 Understanding limitations of traditional NED systems · 8.2 Ingesting the domain ontology · 8.3 Setting up the model with Ollama and Llama 3.1 8B · 8.4 End-to-end NED process · 8.4.1 Named entity recognition · 8.4.2 Candidate selection · 8.4.3 Candidate disambiguation · 8.5 Conclusions · 8.6 Summary

What you learn in chapter 8 →

Chapter 9: Machine learning on knowledge graphs: A primer approach

The introduction explains why machine learning on knowledge graphs matters for intelligent advisory systems: it can use integrated graph knowledge to provide insights beyond ordinary querying and navigation.

9.1 Machine learning on graphs: Why? · 9.2 Machine learning on graphs: What? · 9.2.1 Node classification · 9.2.2 Link prediction (a.k.a. relationship prediction) · 9.2.3 Clustering and community detection · 9.2.4 Graph classification · 9.3 Machine learning on graphs: How? · 9.3.1 Node classification and link prediction · 9.3.2 Graph classification · 9.3.3 Graph clustering · 9.4 Summary

What you learn in chapter 9 →

Chapter 10: Graph feature engineering: Manual and semiautomated approaches

This introduction explains why graph machine learning needs numerical features and compares manual, semiautomated, and learned ways to create them.

10.1 Manual node features · 10.1.1 Degree · 10.1.2 Triangles · 10.1.3 Density · 10.1.4 Geodesic (or shortest) path · 10.1.5 Closeness · 10.1.6 Betweenness · 10.1.7 PageRank · 10.1.8 Prediction · 10.2 Manual relationship features · 10.2.1 Node-based representation · 10.2.2 Path-based features · 10.3 Semiautomated feature extraction · 10.3.1 Performing ReFeX manually · 10.3.2 Performing ReFeX automatically with code · 10.4 Summary

What you learn in chapter 10 →

Chapter 11: Graph representation learning and graph neural networks

The introduction explains why graph representation learning can replace hard-to-scale manual feature engineering with learned embeddings and introduces GNNs as a way to learn them.

11.1 Embeddings in graph representation learning · 11.1.1 Understanding graph embeddings: From discrete to continuous · 11.1.2 Real-world applications and examples · 11.2 The encoder–decoder model · 11.2.1 The encoder: Converting graph structure to vectors · 11.2.2 The decoder: Reconstructing graph properties · 11.2.3 The power of the framework · 11.2.4 Node2Vec: An example of an encoder–decoder framework · 11.3 Shallow embeddings: A first approach to graph representation · 11.3.1 Understanding shallow embeddings · 11.3.2 Limitations of shallow embeddings · 11.4 Embeddings in knowledge graphs · 11.4.1 Loss function · 11.4.2 Multirelationship decoder · 11.5 Message passing and graph neural networks · 11.5.1 The message-passing framework: A neural conversation · 11.5.2 Motivation and intuition: Why message passing works · 11.5.3 The basic GNN model · 11.5.4 Message passing with self-loops · 11.6 Generalized aggregation and update methods · 11.6.1 Neighborhood normalization · 11.6.2 Neighborhood attention · 11.6.3 Multihead attention and transformer connections · 11.6.4 Generalized update methods · 11.7 The synergy of GNNs and LLMs · 11.8 Summary

What you learn in chapter 11 →

Chapter 12: Node classification and link prediction with GNNs

The introduction connects two GNN tasks to real-world applications: identifying illicit activity in transaction graphs and recommending movies from user–movie interactions.

12.1 Node classification for anti-money laundering applications · 12.1.1 Input data · 12.1.2 Graph processor: Data preparation · 12.1.3 Graph processor: Homogeneous PyG graph · 12.1.4 Encoder–decoder architecture · 12.1.5 Evaluation and analysis · 12.2 Link prediction for movie recommendations · 12.2.1 Input data · 12.2.2 Graph processor: Data preparation · 12.2.3 Graph processor: Heterogeneous PyG graph · 12.2.4 Encoder–decoder architecture · 12.2.5 Evaluation and analysis · 12.3 Summary

What you learn in chapter 12 →

Chapter 13: Knowledge graph–powered retrieval-augmented generation

The introduction contrasts the ease of building NLP applications with LLMs against the work still needed to make them useful in enterprise production.

13.1 AI agents · 13.2 Chatting with the LLM · 13.3 Challenges in the production environment · 13.4 Chatting with the AI about private data · 13.4.1 Retrieval-augmented generation · 13.4.2 Vector-based RAG limitations · 13.4.3 Graph RAG · 13.4.4 Reasoning agents · 13.4.5 Let’s chat with our KG · 13.5 Summary

What you learn in chapter 13 →

Chapter 14: Asking a KG questions with natural language

The chapter introduces an expert-emulated approach to asking knowledge graphs questions and explains why its design accounts for presenting answers to end users.

14.1 Querying a knowledge graph in the policing domain · 14.1.1 Enabling domain experts with knowledge graphs · 14.2 RAG for KG querying: Capabilities and challenges · 14.2.1 RAG effectiveness with complete context · 14.2.2 RAG fragility with incomplete retrieval · 14.3 Schema-based approach for querying KGs · 14.3.1 Understanding and using graph schemas · 14.4 Think like an expert: Using metadata for enhanced querying · 14.5 Intent detection: Understanding user expectations · 14.5.1 Classifying by visualization type · 14.5.2 Is it data, documentation, or just complaining? · 14.6 From schema to LLM-ready context · 14.6.1 Schema extraction and representation · 14.6.2 Enriching schemas with descriptive annotations · 14.6.3 A practical approach to schema representation · 14.7 It’s time to think: Understanding LLM reasoning · 14.7.1 The order matters: Answer first vs. reasoning first · 14.7.2 Thinking in queries: From text to Cypher · 14.7.3 Structuring output for reliable query generation · 14.8 Response summarization: From results to insights · 14.9 Summary

What you learn in chapter 14 →

Chapter 15: Building a QA agent with LangGraph

The introduction previews an application that will combine chapter 14’s knowledge-graph querying techniques into a LangGraph pipeline with a Streamlit interface.

15.1 Building the LangGraph pipeline · 15.1.1 System architecture overview · 15.1.2 Configuring pipeline components · 15.1.3 Schema translation service · 15.1.4 State management design · 15.1.5 Pipeline agent implementation · 15.1.6 Pipeline integration layer · 15.2 Streamlit application · 15.2.1 Application overview · 15.2.2 LangGraph integration · 15.3 Expert-emulating investigation · 15.3.1 Identifying the initial case · 15.3.2 Spatial analysis of surveillance coverage · 15.3.3 Vehicle pattern detection · 15.3.4 Context-aware request refinement · 15.3.5 Historical record analysis · 15.4 Future directions and enhancements · 15.4.1 Learning from use · 15.4.2 Enhancing core capabilities · 15.4.3 Advanced evolution paths · 15.5 Summary

What you learn in chapter 15 →

Concepts explained in this book

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.