Overview

5 Domain-specific knowledge extraction from unstructured data

The chapter explains how to unlock knowledge from domain-specific unstructured text and shape it into connected, queryable knowledge graphs. It frames the task as a multistep pipeline—ingestion, NLP, enrichment, modeling—and highlights two overarching challenges: knowledge representation (how to model information so it is reusable and efficient) and knowledge learning/construction (how to mine insights from text). Using the Rockefeller Archive Center as a case study—particularly program officers’ diaries rich in domain jargon, abbreviations, and historical context—the chapter shows why bespoke extraction is needed to reveal patterns in grant-making, influence networks, and evolving research trends.

The core technical focus is on named entity recognition and relation extraction as the backbone of building KGs from text. Generic off-the-shelf models are a start but insufficient for domain nuances such as fine-grained research topics, historical titles, and abbreviated references (“U. Cal.”, initials-only people). The chapter contrasts traditional NLP pipelines with Large Language Models, showing how LLMs can collapse multiple steps (NER, coreference, normalization) thanks to transfer learning and generative reasoning—while cautioning about hallucinations and output instability. A practical, iterative prompt-engineering approach is presented: clearly define target entity and relation classes, provide representative examples, tune parameters (e.g., temperature 0 for determinism), and enrich outputs with properties (e.g., sentiment on “talked about”) for downstream analysis. The authors stress rapid prototyping, mini-KG “eyeballing,” unit-style prompt tests, and quantitative QA to stabilize outputs; when prompts plateau, fine-tuning the model with a small curated dataset can deliver the needed accuracy and consistency.

Finally, the chapter weighs when to choose traditional NLP versus LLMs. Traditional approaches offer speed, simpler and cheaper infrastructure, and easier on-prem security, but demand significant expertise, multiple custom models, and costly annotation. LLMs provide a faster path to domain adaptation, an all-in-one extraction capability with strong language understanding, and reduced post-processing, but can be slower, more expensive to serve, harder to deploy securely at scale, and may require fine-tuning for mission-critical quality. The guidance is pragmatic: start with prompt-based LLMs for exploration and rapid value, measure and harden with disciplined evaluation, fine-tune when needed, and remember that both toolsets have a place—LLMs can even pre-annotate data to accelerate traditional pipelines. The end goal is accurate, normalized, and connected knowledge that supports complex querying over information previously locked in unstructured documents.

Path from domain-specific unstructured textual data towards structured knowledge. 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 or Relation Extraction system.
A snippet of Warren Weaver's diary entry with highlighted relevant named entities.
Mental model of transforming textual data into structured knowledge: Named Entity Recognition and Relation extraction using a Large Language Model.
The two roles of Large Language Models in KG generation from textual data: prompt-based approach (upper branch of the flow) vs. fine-tuning approach (lower branch).

Summary

  • Producing Knowledge Graphs from unstructured textual data requires the identification of custom domain-specific named entities and relations among them.
  • A whole range of traditional NLP models, such as Named Entity Recognition, Relation Extraction, or Coreference Resolution, have to be trained and chained in a complex workflow. Training each of them requires a high initial investment for building high-quality human-annotated training datasets, and specialized data science skills to train, evaluate, deploy, and monitor the models.
  • Large Language Models, such as OpenAI’s GPT, can be used out-of-the-box with iterative prompt engineering (or alternatively fine-tuning) to build domain-specific Knowledge Graphs of high accuracy with much lower initial costs compared to the traditional NLP.
  • Traditional NLP and LLMs both have their pros and cons, depending on the concrete domain and various requirements and business considerations. They can even coexist side by side, or one can be used to prepare a training dataset for the other.
  • The generative nature of LLMs means that we get cleaner more accurate KG with minimized need for entity normalization and even resolution.
  1. Chernow, Ron (May 5, 1998). Titan: “The Life of John D. Rockefeller Sr.,” New York: Random House. pp. 563–566. ISBN 978-0679438083.
  2. A. Vaswani et al., “Attention Is All You Need,” 2017, arXiv:1706.03762 [cs.CL]
  3. J. Kaplan et al., “Scaling Laws for Neural Language Models,” 2020, arXiv:2001.08361 [cs.LG]

FAQ

What are the main challenges in turning unstructured text into a Knowledge Graph?The process is multi-step (ingestion/OCR, NLP, enrichment, ML, data modeling) and hinges on two core challenges: knowledge representation (how to model information for reuse and extension) and knowledge learning/construction (mining entities and relations from text using NLP/LLMs).
Why is domain-specific Named Entity Recognition (NER) needed for archives like the Rockefeller Officer Diaries?Generic classes (Person, Organization, Location) are not enough. The diaries contain domain topics (disciplines, technologies, diseases), heavy use of abbreviations/initials, historical terminology, and fine-grained concepts that dictionary-based NER won’t capture.
What is relation extraction and why is schema consistency important?Relation extraction identifies semantic links between entity pairs (e.g., PERSON works_for ORGANIZATION). You can choose labels like WORKS_FOR or EMPLOYED_BY and direction, but must stay consistent across documents to build a coherent, queryable graph.
How do Large Language Models (LLMs) improve entity and relation extraction over traditional NLP?LLMs leverage transfer learning and can work out-of-the-box via prompts. They often handle coreference and abbreviation expansion implicitly, infer missing context, and generate cleaner entities/relations. However, they may hallucinate or produce variable outputs without careful prompting.
What prompt engineering practices improve extraction quality and stability?- Write a precise task description with domain guidance - List target entity and relation classes (nomenclature matters) - Provide a representative, complex example with expected output - Use temperature 0 for deterministic, factual extraction - Test prediction stability, add prompt “unit tests,” and inspect a mini-KG after milestones
How should I handle initials and organizational aliases in historical texts?Explicitly instruct the model in the prompt that people may be referenced by initials/surnames and organizations by short forms (e.g., “U. Cal.”). Include examples showing expansion to full names to guide normalization.
When should I fine-tune an LLM instead of relying on prompts?Fine-tune when the task is complex or mission-critical and prompt-based results aren’t accurate or stable enough. Fine-tuning uses a smaller labeled dataset than traditional NLP, costs more to train/serve, but yields more reliable, domain-specialized outputs. Prompts can pre-annotate data to speed labeling.
How can I mitigate hallucinations and variability in LLM outputs?- Use clear, unambiguous prompts and constrain outputs to specified classes - Set temperature to 0 - Provide concrete examples with normalized outputs - Validate with human QA on samples before scaling and iterate on the prompt
How do I choose between traditional NLP and LLMs for KG building?Choose LLMs for faster domain customization, “all-in-one” extraction, and superior language understanding; expect slower inference and higher infra/costs. Choose traditional NLP for faster/cheaper inference, simpler infra/security needs; expect heavier expertise and data annotation to build multiple models (NER, RE, coref, etc.). Dataset size, security, and latency needs often decide.
How should I evaluate extraction quality before full-scale KG generation?Run a quantitative QA on a sample: have an annotator mark correct/incorrect/missing entities and relations, compute per-class precision, recall, and F1, check stability across runs, and inspect a mini-KG to spot normalization gaps and systemic errors.

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