liveBook · Manning

Knowledge graph

As explained in LLMs in Production

A knowledge graph represents entities and the relationships between them as a graph of nodes and edges.

A knowledge graph represents entities as nodes and their relationships as edges, making linked facts directly queryable rather than merely similar to a prompt. section 12.2.5

Answering a multipart question

For “What is Gal Gadot’s husband’s current job?”, a knowledge graph can connect Gal Gadot to Jaron Varsano and then to his occupation. A similarity-based vector search may retrieve many articles about Gal Gadot without reliably finding the intermediate relationship. section 12.2.5

Use knowledge graphs when relationship-aware retrieval matters, while accounting for the added engineering work:

  • Query a graph database such as Neo4j to traverse connected entities and answer complex, multipart questions. section 12.2.5
  • Translate prompts into graph queries, often treating query generation as an NLP problem that LLMs can help solve. section 12.2.5
  • Expect more data-modeling effort and expertise than embedding documents for vector search. section 12.2.5

How LLMs in Production covers it

How deep it goes
Defines nodes and edges, compares graph and vector retrieval, and identifies query-generation and document-conversion hurdles.
Examples
Uses Gal Gadot’s relationship to Jaron Varsano and his occupation to illustrate multipart retrieval.
What it assumes
Assumes familiarity with RAG, prompts, similarity vector search, databases, and embeddings.
What you can do after
Evaluate when relationship-aware graph retrieval outweighs the simplicity of vector-based document search.
How it connects
Connects RAG, vector databases, graph databases, Neo4j, similarity search, NLP, and LLMs.

Also explained in

Compare how 12 books explain knowledge graph →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of LLMs in Production. The section links point to the parts of the book it draws on.