Overview

6 Building knowledge graphs with large language models

This chapter shows how to move from language-model-based knowledge extraction to a usable, explainable Knowledge Graph. Using the Rockefeller Archive Center diaries as a running example, it tackles real-world obstacles: converting analog, historical, idiosyncratically written documents via OCR; handling domain-specific entities of uneven granularity; coping with dense relational content; and performing the post-extraction heavy lifting of normalization, cleansing, entity resolution, and cross-source reconciliation. The emphasis is on why LLMs make this tractable compared to traditional NLP, while also making clear that disciplined graph-building practices remain essential.

The authors propose a three-layer graph design: a document layer to preserve provenance (files and pages), a meta-graph layer of raw entity mentions and relations from the LLM, and a final KG layer of resolved entities (persons, organizations, occupations, titles) and normalized relations. Pages are processed as chunks; mentions and their relationships are stored without merging, then cleaned (for example, lowercasing occupations and stripping honorifics from names) and resolved. Although LLMs implicitly help with coreference, robust entity resolution still relies on graph signals: string similarity rules informed by domain conventions, corroborating relationships such as WORKS_FOR and WORKS_ON, and community structure. Weakly connected components unify mentions into canonical nodes, while semantic embeddings cluster occupation terms to bridge vocabulary gaps and granularity differences—all while preserving traceability back to source text.

With a consolidated KG, graph data science reveals an “intellectual network” of scientists via relations like TALKED_WITH, TALKED_ABOUT, WORKS_WITH, and STUDENT_OF. Centrality metrics highlight influencers, bridges, and key connectors; focused multi-hop queries surface people and organizations around topics such as cyclotron research. The chapter also stresses feedback loops to catch extraction errors, then outlines scalable next steps: improving prompts or fine-tuning, handling multi-page context, resolving occupations at multiple levels, linking officer diaries to grants, and modeling conversations and their chains. Finally, it argues for the enduring value of KGs in the LLM era: they enable explainability and provenance, “de-blackbox” model outputs, democratize expensive models by extracting once and reusing often, foster exploratory analysis, and provide precise, controllable analytics beyond what a monolithic language model alone can reliably offer.

Path from domain-specific unstructured textual data towards KG insights. Each of the key steps relies on state-of-the-art Machine Learning models, be it for example Optical Character Recognition for document digitization, NER and Relation Extraction systems, Entity Resolution and Graph ML.
Simplified Knowledge Graph schema of the Rockefeller Archive Center project.
Graph-based Entity Resolution example.
Intellectual influence network made of relations TALKED_ABOUT, TALKED_WITH, WORKS_WITH and STUDENT_OF. Node styling is based on their betweenness centrality score.
Influence network in the 2-hop vicinity of the cyclotron research. The person node sizes are based on global PageRank centrality to highlight popular nodes in the graph.
Physics research influence network connecting Johns Hopkins University and Harvard University with no more than three hops among persons. The green and red relationships indicate positive and negative sentiments.

Summary

  • Knowledge Graph schema design, a.k.a. graph modelling, is a key step that ensures the information is stored in the most optimal way for the specific use case at hand. Well-designed schema simplifies the KG creation, entity, and relation cleansing, normalization, and resolution, as well as ensures efficient downstream analyses and insights discovery optimized for the specific use case.
  • Extracting high-quality entity relations from textual documents helps to design an unsupervised graph-based entity resolution approach.
  • Various graph data science and graph Machine Learning techniques help to analyze patterns and draw insights from Knowledge Graphs, which serve as an intermediate step towards answering complex questions without relying too heavily on black-box tools such as LLMs.

FAQ

What is the main goal of this chapter and what dataset does it use?The chapter shows how to turn domain-specific unstructured text into a usable Knowledge Graph (KG) and extract insights from it. It uses historical, typewritten officer diaries from the Rockefeller Archive Center (RAC), where Rockefeller Foundation program officers recorded conversations and decisions related to research funding.
What are the biggest challenges in transforming historical diaries into a Knowledge Graph?- Analog, typewritten documents that require OCR - Historical context and obsolete disciplines - Uncommon linguistic conventions and abbreviations (e.g., “U.Cal.”) - Domain-specific entities (disciplines, technologies, treatments, diseases) - High relational density and complexity - Normalization, cleansing, entity resolution, and disambiguation - Reconciling multiple unstructured sources (officer diaries vs. board minutes)
Why use LLMs for knowledge extraction instead of traditional NLP?LLMs handle context and coreference implicitly, can recover full canonical names from partial mentions, and adapt better to domain-specific language and idiosyncratic writing styles. This reduces custom rule-building and lowers the need for separate coreference models, improving initial KG quality.
How is the Knowledge Graph modeled in this project?The schema has three layers: - Document-level layer: File and Page nodes created during ingestion and OCR. - Meta-graph layer: unmerged Entity nodes and their page-scoped relations (provenance preserved). - Knowledge Graph layer: normalized, resolved nodes (Person, Title, Organization, Occupation) and final relations (e.g., WORKS_ON, WORKS_FOR). This “onion” design enables post-processing, explainability, and clean end-user views.
What is the meta-graph and how is it created?The meta-graph stores page-scoped entity mentions and relations before resolution: - Chunking strategy: split long documents (e.g., by page or diary entry) to respect token limits. - For each chunk, create Entity nodes (with name/label) linked to the source Page. - Create RELATED_TO_ENTITY relationships with a type property for the relation class. This preserves provenance for explainability and allows recreating the final KG after updates.
Which normalization and cleansing steps improve KG consistency?- Normalize Occupation names (e.g., lowercase where case is irrelevant). - Strip titles and honorifics from person names (e.g., “Dr.”, “Prof.”) to avoid duplicate nodes. - Store normalized forms (e.g., name_normalized) and use them in downstream linking.
How does graph-based entity resolution work for people and organizations?- Create similarity edges (e.g., META_PERSONS_SIMILAR) using domain-aware name rules (first/middle/surname patterns) and context from relations (WORKS_FOR, WORKS_ON). - For organizations, apply careful similarity and stop-word handling (e.g., avoid linking generic “Foundation” names). - Run Weakly Connected Components (WCC) on the similarity graph to group mentions. - Choose a canonical name per group (e.g., longest full name) and create resolved KG entities. Community detection and additional signals can further boost confidence.
How are Occupation entities resolved across different granularities?Occupations vary from broad (“nuclear physics”) to specific (“heavy nitrogen”). Use semantic embeddings (e.g., Sentence-BERT or GPT) and agglomerative clustering to: - Link semantically related occupations, even with low string similarity. - Control granularity by tuning clustering thresholds. - Create SIMILAR_OCCUPATION links to power cross-document analyses and diary–grant linkage.
How is the intellectual network analyzed and what insights can it reveal?- Build a person-to-person network from TALKED_WITH, TALKED_ABOUT, WORKS_WITH, and STUDENT_OF. - Run graph algorithms (PageRank, Eigenvector, degree, betweenness) to find influencers, bridges, and popular referents. - Answer focused questions (e.g., cyclotron-related neighborhood, connectors between universities). Quality tip: include a feedback loop so analysts can validate/flag extraction mistakes surfaced by the visualization.
Why build Knowledge Graphs in the era of LLMs?- Explainability: inspectable nodes, edges, and provenance. - De-blackboxing: turn opaque LLM outputs into verifiable structured facts. - Democratization: run the LLM once to build a KG, then reuse the graph widely and cheaply. - Explorability: intuitive visualization and hypothesis testing. - Advanced analytics: precise graph algorithms and ML (e.g., centrality, temporal analysis) under analyst control.

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
$499.99
only $41.67 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
$499.99
only $41.67 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
$499.99
only $41.67 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