Programming Knowledge Graphs with Python: Model, Build, and Query AI-Ready Knowledge with Cypher, Neo4j, and AI Agents

Programming Knowledge Graphs with Python: Model, Build, and Query AI-Ready Knowledge with Cypher, Neo4j, and AI Agents book cover

Programming Knowledge Graphs with Python: Model, Build, and Query AI-Ready Knowledge with Cypher, Neo4j, and AI Agents

Author(s): Ryein Twardo (Author)

  • Publisher: GitforGits
  • Publication Date: September 26, 2026
  • Language: English
  • Print length: 254 pages
  • ISBN-10: 8117136090
  • ISBN-13: 9788117136096

Book Description

Get practical hands-on to build your own knowledge graph, and use it across retrieval, analytics and agents

LLMs sound confident, but they forget context, invent facts and can't show their reasoning. A knowledge graph gives them structured, traceable facts to work from. What you'll do in this book is grow a single Neo4j graph from the Python Enhancement Proposals, which are the documents that shaped the language. It starts with getting to grips with nodes and relationships and writing Cypher like a pro. Then you design a schema in Pydantic, chunk documents into a lexical graph and extract entities with spaCy and local LLMs. Then, you add vector embeddings and indexes, and combine full-text search, vector search and graph traversal into GraphRAG retrieval that cites its sources.

The rest of the book goes into more detail. You can rank and cluster nodes with Graph Data Science, infer new facts with rules, import ontologies and validate data with SHACL. You also give LangGraph agents guarded Cypher tools, serve the graph over MCP, store agent memory with Graphiti and trace every decision. At the end of the day, you keep the graph healthy with regular refreshes, time-bound facts, evaluation runs, query tuning and backups.

Key Learnings

  • Write expressive, parameterized Cypher queries from Python.
  • Design graph schemas with Pydantic, constraints and indexes.
  • Chunk documents into lexical graphs with batched ingestion pipelines.
  • Extract entities and relationships using spaCy rules and schema-guided local LLMs.
  • Store embeddings in Neo4j and query them through vector indexes and similarity metrics.
  • Build GraphRAG retrievers for full-text, vector search and subgraph expansion.
  • Rank, cluster and predict links with PageRank, Leiden and GDS pipelines.
  • Infer facts with Cypher rules, SKOS ontologies and SHACL shape validation.
  • Connect LangGraph agents to graphs through guarded Cypher tools, MCP and Graphiti memory.
  • Operate graphs with incremental refreshes, temporal facts, evaluation runs, tuning and backups.

Table of Content

  1. Thinking in Nodes and Relationships
  2. Writing Cypher with Confidence
  3. Designing Graph Schema
  4. Preparing Data and Chunks
  5. Extracting Entities and Relationships
  6. Structuring Embeddings in Graphs
  7. Retrieving with Vectors and Structure
  8. Analyzing Graph Structure
  9. Reasoning Symbolically over Knowledge
  10. Connecting AI Agents to Graphs
  11. Keeping Knowledge Graphs Healthy

View on Amazon

未经允许不得转载:Wow! eBook » Programming Knowledge Graphs with Python: Model, Build, and Query AI-Ready Knowledge with Cypher, Neo4j, and AI Agents