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.
Bu egzersiz
Retrieval Augmented Generation (RAG) with LangChain
kursunun bir parçasıdırEgzersiz talimatları
- Create a graph QA chain that queries the
graphdatabase while ignoring nodes with the"Concept"type; anllmhas been defined for you, and you should setverbose=True. - Invoke the
graph_qa_chainwith the input provided.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
# Create the graph QA chain excluding Concept
graph_qa_chain = ____
# Invoke the chain with the input provided
result = ____({"query": "Who was Marie Curie married to?"})
print(f"Final answer: {result['result']}")