RuAG: Learned-rule-augmented Generation for Large Language Models

Yudi Zhang, Pei Xiao, Lu Wang, Chaoyun Zhang, Meng Fang, Yali Du, Yevgeniy Puzyrev, Randolph Yao, Si Qin, Qingwei Lin, Mykola Pechenizkiy, Dongmei Zhang, Saravan Rajmohan, Qi Zhang

TL;DR

RuAG (Learned-Rule-Augmented Generation) is a novel framework that enhances Large Language Model (LLM) performance by distilling massive datasets into compact, interpretable first-order logic rules. By leveraging an LLM to define search parameters and Monte Carlo Tree Search (MCTS) to discover high-precision patterns, RuAG equips the model with "distilled wisdom" rather than raw data, significantly outperforming standard Retrieval-Augmented Generation (RAG) and In-Context Learning (ICL).

The Bottleneck in External Data Learning

While LLMs are powerful, they often struggle with domain-specific reasoning or tasks requiring deep knowledge of external datasets. Current solutions face significant bottlenecks:

  • In-Context Learning (ICL): Limited by context window size, restricting the number of examples that can be provided.
  • Retrieval-Augmented Generation (RAG): Often retrieves noisy or irrelevant documents and struggles to capture global patterns across an entire dataset.
  • Supervised Fine-Tuning (SFT): Computationally expensive, prone to "catastrophic forgetting," and results in a "black box" model.
Comparison of learning paradigms

The authors identify a critical need for high information density. Instead of feeding an LLM a "needle in a haystack" via RAG, RuAG provides the LLM with the "rules of the haystack."

The RuAG Methodology

RuAG introduces a three-phase pipeline to transform raw data into actionable logic:

RuAG Pipeline
  1. LLM-Based Rule Search Formulation: Instead of relying on manual human definitions for every variable, RuAG uses an LLM’s commonsense to identify relevant "predicates" (features and targets). The LLM prunes the search space by filtering out impossible or irrelevant attributes.
  2. Logic Rule Search with MCTS: To navigate the massive combinatorial space of potential rules, the system employs Monte Carlo Tree Search (MCTS). MCTS efficiently explores combinations to discover rules with high precision and broad data coverage.
  3. Rule-Augmented Generation: The discovered symbolic rules (e.g., Temperature ≥ 30 AND Humidity < 50 ⇒ Sunny) are translated into natural language. These sentences are then injected directly into the LLM's prompt, acting as a highly concentrated knowledge base for the specific task.

Experimental Validation

The authors evaluated RuAG across four distinct domains to demonstrate its versatility: Document-level relation extraction (DWIE), massive log anomaly detection (HDFS), a cooperative multi-agent grid-world game (Alice & Bob), and a private industrial dataset for unauthorized party abuse detection.

RuAG consistently outperformed baselines, including Vanilla LLMs, ICL, RAG, and specialized deep learning models:

  • Relation Extraction (DWIE): Achieved an F1 score of 60.42%, significantly beating RAG (52.30%) and ICL (50.26%).
  • Log Anomaly Detection (HDFS): Reached a near-perfect Precision of 100% and an F1 of 92.59, whereas RAG trailed at 84.32.
  • Decision Making (Alice & Bob): Vanilla LLMs and RAG had a 0% win rate due to their inability to grasp counter-intuitive strategies. RuAG achieved a 70% win rate by providing rules that explained the environment's hidden mechanics.

Key Insights and Future Directions

RuAG bridges the gap between symbolic AI (logic rules) and connectionist AI (LLMs). Logic rules act as a form of "lossy but high-value" knowledge compression. A single rule can summarize thousands of data points, making it far more context-efficient than RAG. Furthermore, unlike a fine-tuned model, RuAG offers high interpretability—the rules in the prompt are human-readable, explaining why a decision was made.

Limitations: * Predicate Quality: The system's success relies heavily on the LLM's initial ability to suggest good predicates. Missing a crucial feature during formulation limits the MCTS search. * Static vs. Dynamic Data: The current framework distills "offline" data. Adapting RuAG to "online" settings where rules change in real-time remains a challenge. * Computational Overhead: While cheaper than fine-tuning, running MCTS for rule discovery requires significant initial computation before generation can begin.

Ultimately, RuAG suggests that the future of LLM augmentation isn't just about retrieving more text, but about learning and injecting the underlying logic of the data we already possess.

Summary updated

BibTeX
@inproceedings{zhang2025ruag,
  author = {Yudi Zhang and Pei Xiao and Lu Wang and Chaoyun Zhang and Meng Fang and Yali Du and Yevgeniy Puzyrev and Randolph Yao and Si Qin and Qingwei Lin and Mykola Pechenizkiy and Dongmei Zhang and Saravan Rajmohan and Qi Zhang},
  title = {{RuAG: Learned-rule-augmented Generation for Large Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=BpIbnXWfhL},
}
Figure