Course · Part of Generative AI & GraphRAG

Using Neo4j with LangChain

Integrate Neo4j with LangChain to build GraphRAG applications: vector retrievers, graph-enhanced retrieval, text-to-Cypher, and an LLM agent.

1 hour11 lessons across 3 modules
About this course

In this 1-hour course, you will learn

Using Neo4j with LangChain teaches you how to integrate a Neo4j graph database into your LangChain applications. In around an hour you will connect LangChain to Neo4j, build vector and graph-enhanced retrieversA component that searches a data source and returns the information relevant to a query. Often used to provide context for a language model., generate CypherNeo4j's implementation of GQL, the ISO standard query language for graph databases. It is declarative: you describe the pattern to find, and the database decides how to find it. from natural language, and create a simple agent that answers questions from a knowledge graphA representation of real-world entities and their relationships, stored according to organizing principles, typically in a graph database..

LangChain gives you the building blocks for LLMA model trained on text to predict the next token, and so to generate language. applications; Neo4j gives those applications grounded, connected context. The langchain_neo4j package joins the two, and this course works through its main components — Neo4jGraph, Neo4jVector, and the Cypher QA chain — with runnable code at every step.

  • Integrating Neo4j using LangChain

    Configure the LangChain Neo4j integration to connect your Python application to a live Neo4j database and query graph data within a LangChain pipeline.

  • GraphRAG

    Build graph-enhanced retrieval-augmented generation pipelines that combine structured graph traversal with vector search to deliver richer, more accurate LLM responses.

  • Vectors

    Store and query vector embeddings in Neo4j using LangChain's Neo4jVector retriever to perform semantic similarity search over graph-stored documents.

  • Text to Cypher

    Write LangChain chains that translate natural-language questions into Cypher queries, execute them against Neo4j, and return results to the LLM for answer generation.

  • Who this course is for

    This course is for Python developers already building with LangChain who want to add graph-backed retrieval to their applications. If you have built a chain or a simple chatbot and now need it to answer questions from your own data — with the accuracy that vector searchFinding the records whose vectors lie closest to a query vector. alone cannot provide — this course shows you how. Rather than teaching LangChain or Neo4j from scratch, it concentrates on the integration: how to query a graph from a chain, how to combine vector similarity with graph traversalFollowing relationships from one node to the next to reach other parts of a graph., and how to let an LLMA model trained on text to predict the next token, and so to generate language. write CypherNeo4j's implementation of GQL, the ISO standard query language for graph databases. It is declarative: you describe the pattern to find, and the database decides how to find it. safely against your schema. You should have completed Neo4j Fundamentals and Neo4j & GenerativeAI Fundamentals, recognize LangChain chains, prompts, and tools, and have an OpenAI API key, though you can substitute another provider.

  • What you'll build and do

    You get a Neo4j Aura instanceA single Neo4j database running in Aura. pre-loaded with a movie recommendations dataset, including plot embeddingsInformation represented as a numerical vector, positioned so that similar information sits close together. and a vector indexA structure over a vector property. The database searches it to find the vectors nearest a given one, rather than comparing every vector stored., so every example runs against real data from the first lesson. All the code is provided in a companion repository, and each practical lesson builds on the last, so you finish with a set of working programs you can adapt for your own projects.

    You will set up a development environment, create a simple LangChain agent, and connect it to Neo4j with the Neo4jGraph class. You will run vector searches over movie plots with Neo4jVector, wrap them in a retrieverA component that searches a data source and returns the information relevant to a query. Often used to provide context for a language model., and then extend the retrieval query so each semantic match brings back connected data from the graph — the GraphRAGRetrieval-augmented generation whose context comes from a knowledge graph, so the model can follow the relationships between facts. pattern in LangChain form. In the final module you will build a CypherNeo4j's implementation of GQL, the ISO standard query language for graph databases. It is declarative: you describe the pattern to find, and the database decides how to find it. QA chain that translates questions into Cypher, learn how the graph schema and few-shot examples improve the generated queries, and package text-to-Cypher as a retriever your agent can call as a tool.

  • Where to go next

    The retrieversA component that searches a data source and returns the information relevant to a query. Often used to provide context for a language model. in this course query an existing knowledge graphA representation of real-world entities and their relationships, stored according to organizing principles, typically in a graph database.. To learn how to build one from your own documents, take Constructing Knowledge Graphs with Neo4j GraphRAG for Python, which covers LLM-driven entity extraction, schema design, and pipeline customization. For a deeper understanding of embeddingsInformation represented as a numerical vector, positioned so that similar information sits close together. and vector indexes, take Introduction to Vector Indexes and Unstructured Data. This course also contributes to your preparation for the Neo4j & Generative AI Certification, which validates your GraphRAGRetrieval-augmented generation whose context comes from a knowledge graph, so the model can follow the relationships between facts. and LLMA model trained on text to predict the next token, and so to generate language. integration skills with Neo4j.