graph-constrained-reasoning  by RManLuo

Research implementation for faithful KG reasoning with LLMs

Created 1 year ago
251 stars

Top 99.8% on SourcePulse

GitHubView on GitHub
Project Summary

Graph-constrained Reasoning (GCR) addresses the challenge of ensuring Large Language Models (LLMs) perform faithful reasoning over Knowledge Graphs (KGs). It provides a novel framework that integrates KG structure directly into the LLM decoding process, enabling LLMs to generate reasoning paths grounded in KGs, thereby achieving accurate reasoning with zero hallucination. This is particularly beneficial for researchers and engineers building KG-aware AI systems that require high fidelity and trustworthiness.

How It Works

GCR integrates KG structure into the LLM decoding process using a KG-Trie data structure. This allows LLMs to directly query and traverse the graph during generation, ensuring that each reasoning step is faithful to the underlying KG. This approach bypasses the limitations of standard LLMs that may struggle to access or correctly interpret structured knowledge, leading to more accurate and verifiable outputs.

Quick Start & Requirements

  • Primary install: Use Poetry for dependency management within a Python 3.12 conda environment (conda create -n GCR python=3.12, conda activate GCR, poetry install).
  • Prerequisites: Poetry, Python 3.12, CUDA 12.1 (recommended), Flash-attention (pip install flash-attn --no-build-isolation). Data and pre-trained models are automatically downloaded from Huggingface.
  • Links: Official implementation of ICML 2025 paper. OpenAI API key required for the final reasoning step.

Highlighted Details

  • Official implementation of the ICML 2025 paper "Graph-constrained Reasoning: Faithful Reasoning on Knowledge Graphs with Large Language Models".
  • Novel KG-Trie integration into LLM decoding for faithful, KG-grounded reasoning.
  • Achieves zero reasoning hallucination by directly grounding LLM outputs in KG structure.
  • Supports fine-tuning and inference with various LLMs (Qwen2, Llama-2, Llama-3.1) and utilizes Flash-attention for fast decoding.

Maintenance & Community

No specific details regarding maintainers, community channels (e.g., Discord, Slack), or roadmap are provided in the README. The project is associated with an ICML 2025 publication, suggesting recent development activity.

Licensing & Compatibility

The repository's license is not specified in the provided README. This omission prevents an assessment of its compatibility for commercial use or integration into closed-source projects.

Limitations & Caveats

The setup recommends CUDA 12.1, implying potential compatibility issues with older GPU setups. The final reasoning step relies on external LLM APIs (e.g., ChatGPT), requiring API key configuration and incurring external service costs. Crucially, the absence of explicit licensing information is a significant blocker for adoption decisions.

Health Check
Last Commit

1 year ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
0
Star History
4 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.