Code-on-Graph: Iterative Programmatic Reasoning via Large Language Models on Knowledge Graphs
On the map: LLM reasoning → Knowledge- and tool-augmented reasoning
Abstract (arXiv)
Knowledge Graphs (KGs) are widely used to mitigate the limitations of Large Language Models (LLMs), such as outdated knowledge and hallucinations. Existing LLM-KG integration frameworks typically rely on predefined operators to retrieve factual knowledge from KGs and inject it into prompts for answer generation. This paradigm faces two critical bottlenecks: 1) Inflexibility: The predefined operators are limited in scope and thus lack sufficient compositional expressiveness to fully capture the complex semantics required by KG questions. 2) Unscalability: Direct injection of factual knowledge into prompts limits scalability in handling large-scale factual knowledge. To address these two bottlenecks, we propose Code-on-Graph (CoG), a programmatic reasoning framework for LLM-KG integration. Specifically, given the factual knowledge retrieved at each reasoning step, CoG first identifies the corresponding KG schemas and represents these schemas as Python classes, which serve as abstract interfaces to the retrieved facts. It then generates executable code grounded in these classes, with the retrieved facts instantiated as objects of the corresponding classes during execution. This design enables flexible code-based reasoning while avoiding the direct injection of large-scale factual knowledge into prompts. Experiments on WebQSP, CWQ, and GrailQA demonstrate that CoG outperforms prior state-of-the-art models by up to 10.5%.
Key facts. Cited by 3 papers in the map (data through 14 Oct 2026). Placed in Knowledge- and tool-augmented reasoning, one of 17 directions in LLM reasoning. Builds on 33 of its 50 references that are in the map. First posted on arXiv 2 Jun 2026.
Builds on
33 of 50 references.
Closest ancestors · 9
Same direction, newest first
- 2025KnowCoder-V2: Deep Knowledge Analysis7 Jun
- 2025Self-Reflective Planning with Knowledge Graphs: Enhancing LLM Reasoning Reliability for Question Answering26 May
- 2025Reasoning of Large Language Models over Knowledge Graphs with Super-Relations28 Mar
- 2024Plan-on-Graph: Self-Correcting Adaptive Planning of Large Language Model on Knowledge Graphs31 Oct
- 2024Call Me When Necessary: LLMs can Efficiently and Faithfully Reason over Structured Environments13 Mar
- 2024KG-Agent: An Efficient Autonomous Agent Framework for Complex Reasoning over Knowledge Graph17 Feb
- 2023Reasoning on Graphs: Faithful and Interpretable Large Language Model Reasoning2 Oct
- 2023Think-on-Graph: Deep and Responsible Reasoning of Large Language Model on Knowledge Graph15 Jul
- 2022UniKGQA: Unified Retrieval and Reasoning for Solving Multi-hop Question Answering Over Knowledge Graph2 Dec
Other references · 24
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,459
- 2025Qwen3 Technical Reportcited by 8,820
- 2019DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lightercited by 4,307
- 2023Toolformer: Language Models Can Teach Themselves to Use Toolscited by 4,182
- 2023A Survey of Large Language Modelscited by 2,576
- 2022Program of Thoughts Prompting: Disentangling Computation from Reasoning for Numerical Reasoning Taskscited by 1,076
- 2025DeepSeek-V3.2: Pushing the Frontier of Open Large Language Modelscited by 815
- 2022PAL: Program-aided Language Modelscited by 652
- 2023ViperGPT: Visual Inference via Python Execution for Reasoningcited by 603
- 2018The Web as a Knowledge-base for Answering Complex Questionscited by 410
- 2023Chameleon: Plug-and-Play Compositional Reasoning with Large Language Modelscited by 356
- 2023StructGPT: A General Framework for Large Language Model to Reason over Structured Datacited by 343
12 more
- 2022Binding Language Models in Symbolic Languagescited by 228
- 2024G-Retriever: Retrieval-Augmented Generation for Textual Graph Understanding and Question Answeringcited by 223
- 2022DecAF: Joint Decoding of Answers and Logical Forms for Question Answering over Knowledge Basescited by 84
- 2023Few-shot In-context Learning for Knowledge Base Question Answeringcited by 74
- 2023T-SciQ: Teaching Multimodal Chain-of-Thought Reasoning via Mixed Large Language Model Signals for Science Question Answeringcited by 60
- 2024Generate-on-Graph: Treat LLM as both Agent and KG in Incomplete Knowledge Graph Question Answeringcited by 60
- 2022TIARA: Multi-grained Retrieval for Robust Question Answering over Large Knowledge Basescited by 59
- 2022Don't Generate, Discriminate: A Proposal for Grounding Language Models to Real-World Environmentscited by 57
- 2023FlexKBQA: A Flexible LLM-Powered Framework for Few-Shot Knowledge Base Question Answeringcited by 51
- 2023UniGen: A Unified Generative Framework for Retrieval and Question Answering with Large Language Modelscited by 14
- 2024EffiQA: Efficient Question-Answering with Strategic Multi-Model Collaboration on Knowledge Graphscited by 14
- 2026Towards Knowledgeable Deep Research: Framework and Benchmarkcited by 1
Built on by
Citing papers per year: 2026: 3.
3 papers.
- 2026Knowledge Graphs as Files: An Agent Harness Where Tool Creation and Tool Use Co-Evolve13 Oct 2026
- 2026GraphCert: Bootstrap Agentic Graph Reasoning with Certified Evidence Rubrics30 Sep 2026
- 2026Schema-Anchored Latent Reasoning for Semantic Parsing-Based Knowledge Base Question Answering17 Sep 2026
Similar, not cited
Close in wording, no citation either way
- 2026KG2Code: Bridging Knowledge Graphs and Large Language Models via Executable Code for Question Answering
- 2024Paths-over-Graph: Knowledge Graph Empowered Large Language Model Reasoning
- 2024Thinking with Knowledge Graphs: Enhancing LLM Reasoning Through Structured Data
- 2024Logic Query of Thoughts: Guiding Large Language Models to Answer Complex Logic Queries with Knowledge Graphs
- 2024Graph-constrained Reasoning: Faithful Reasoning on Knowledge Graphs with Large Language Models
- 2025Reliable Reasoning Path: Distilling Effective Guidance for LLM Reasoning with Knowledge Graphs
- 2024Graph Chain-of-Thought: Augmenting Large Language Models by Reasoning on Graphs
- 2024Debate on Graph: a Flexible and Reliable Reasoning Framework for Large Language Models