1. Learn
  2. /
  3. Courses
  4. /
  5. Retrieval Augmented Generation (RAG) with LangChain

Connected

Exercise

Graph RAG with filtering

For large and complex graphs, LLMs can sometimes struggle to accurately infer the most relevant nodes and relationships to build the Cypher query. Quite often, you will only need the LLM to be aware of a subset of the graph, and excluding particular node types will not only make it easier for the LLM to accurately create the Cypher query, but it will improve the query latency.

The graph database you've been working with is available as graph.

Instructions

100 XP
  • Create a graph QA chain that queries the graph database while ignoring nodes with the "Concept" type; an llm has been defined for you, and you should set verbose=True.
  • Invoke the graph_qa_chain with the input provided.