$ cd ..

KERAG

rag
knowledge graphs
langgraph
langchain
python

Implementation of Knowledge-Enhanced RAG (arXiv:2509.04716): combines SPARQL-based knowledge graphs with LLM relevance scoring and Chain-of-Thought reasoning for complex multi-hop QA. LangChain, LangGraph, multi-provider LLM support.

KERAG knowledge graph subgraph expansion for retrieval-augmented generation

KERAG (Knowledge-Enhanced Retrieval-Augmented Generation) is an implementation of the paper arXiv:2509.04716. It boosts QA coverage by expanding a subgraph around query entities from a knowledge graph, then using LLMs to score relevance and generate answers with Chain-of-Thought reasoning.

Four-phase pipeline

  1. Planning — Identifies key entities in the query
  2. Retrieval — Expands a multi-hop neighbourhood in the knowledge graph via SPARQL (or REST APIs)
  3. Filtering — LLM-based relevance scoring trims noise from the retrieved subgraph
  4. Summarization — CoT-based answer generation grounded in the filtered evidence

What makes it useful

  • Multi-hop neighbourhood expansion so the answer doesn’t depend on a single node match
  • Async throughout — full async/await support for high-throughput workloads
  • Multi-provider: OpenAI, Anthropic (Claude), Google (Gemini), xAI (Grok)
  • SPARQL knowledge bases and REST API-based graph systems both supported
  • 100% success rate across workflow, chain, and core tests (64.4% overall coverage)

The codebase is designed to be extended — swap in a custom knowledge base, add a new LLM provider, or plug it into an existing RAG stack.