Abstract
Reasoning over knowledge graphs (KGs) with first-order logic (FOL) queries is challenging due to the inherent incompleteness of real-world KGs and the compositional complexity of logical query structures. Most existing methods rely on embedding entities and relations into continuous geometric spaces and answer queries via differentiable set operations. While effective for simple query patterns, these approaches often struggle to generalize to complex queries involving multiple operators, deeper reasoning chains, or heterogeneous KG schemas. We propose ROG (Reasoning Over knowledge Graphs with large language models), an ensemble-style framework that combines query-aware KG neighborhood retrieval with large language model (LLM)-based chain-of-thought reasoning. ROG decomposes complex FOL queries into sequences of simpler sub-queries, retrieves compact, query-relevant subgraphs as contextual evidence, and performs step-by-step logical inference using an LLM, avoiding the need for task-specific embedding optimization. Experiments on standard KG reasoning benchmarks demonstrate that ROG consistently outperforms strong embedding-based baselines in terms of mean reciprocal rank (MRR), with particularly notable gains on high-complexity query types. These results suggest that integrating structured KG retrieval with LLM-driven logical reasoning offers a robust and effective alternative for complex KG reasoning tasks.
Introduction
Knowledge Graphs (KGs) serve as massive networks of real-world facts, yet reasoning over them using First-Order Logic (FOL)—which involves operations like intersection ("and"), union ("or"), and negation ("not")—is notoriously difficult. Historically, researchers have addressed this using geometric embeddings, mapping entities and relations into continuous mathematical spaces. While these methods excel at simple link prediction, they often struggle with "compositional complexity." When a query requires multiple logical steps or negations, embedding-based models frequently lose information during "fuzzy" mathematical transformations. Furthermore, these models are often brittle, requiring extensive retraining to adapt to new KG schemas.
The ROG Framework
To overcome these challenges, we introduce ROG (Reasoning Over knowledge Graphs), an ensemble-style framework that shifts the paradigm from pure embeddings toward a "retrieve-then-reason" approach using Large Language Models (LLMs).
The ROG process follows four main stages designed to maximize logical precision:
- Query Abstraction: To prevent the LLM from relying on potentially outdated or hallucinated internal knowledge, ROG replaces real entity and relation names with unique identifiers (IDs). This forces the model to rely strictly on the provided graph structure.
- Neighborhood Retrieval: Given the limited context windows of LLMs, ROG identifies the entities mentioned in a query and extracts a relevant $k$-hop subgraph. This compact context provides the necessary evidence without overwhelming the model.
- Query-Chain Decomposition: This is the core innovation of the framework. ROG deterministically breaks a complex FOL query into a sequence of basic 1-hop sub-queries. For example, a multi-hop projection query is broken into individual steps.
- Chain-of-Thought (CoT) Prompting: The LLM processes these sub-queries sequentially. Intermediate answers are stored in a cache and fed into the next prompt, ensuring logical consistency across the entire reasoning chain.
Key Results and Insights
ROG was evaluated on standard benchmarks, including FB15k and NELL995, testing 14 different FOL query types. The framework demonstrated a significant performance leap over state-of-the-art embedding models like Query2Box (Q2B) and BetaE, improving the Mean Reciprocal Rank (MRR) by 35% to 55% on average.
Several key insights emerged from this research:
- The Power of Decomposition: Traditional models attempt to solve complex queries in a single neural pass. ROG shows that breaking the problem into 1-hop steps drastically reduces error rates, as LLMs are significantly more reliable at simple tasks.
- Symbolic vs. Neural Hybridization: ROG proves that "crisp" symbolic logic and "flexible" neural reasoning can be successfully combined. By using the LLM as a controller for symbolic decomposition, the system gains both precision and adaptability.
- Generalization via Abstraction: By using IDs instead of names, the model becomes KG-agnostic. This suggests that the reasoning logic of an LLM is transferable across different domains (e.g., from medical to financial KGs) as long as the structure is provided.
Conclusion
ROG provides a robust alternative for complex KG reasoning by mitigating the "representation drift" often seen in long-chain embedding-based methods. While its success is tied to the underlying LLM’s reasoning capability and the quality of initial retrieval, it offers a scalable path forward for reasoning over incomplete and complex real-world data. Future work will explore more natural language query formats that do not follow strict FOL templates.
Summary updated