NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

When Rules Learn: A Self-Evolving Agent for Legal Case Retrieval

Mingxu Tao, Jiawei Hu, Xian Zhou, Wenpeng Hu, Jiajun Cheng, Yunbo Cao, Zhunchen Luo, Guotong Geng

TL;DR

This paper introduces a training-free, self-evolving LLM agent framework designed to optimize query-rewriting rules for legal case retrieval. By iteratively generating rules, planning combinations for experimental validation, and pruning ineffective strategies via a self-consistency mechanism, the framework significantly boosts traditional BM25 lexical retrieval, outperforming both human-crafted rules and state-of-the-art dense retrievers.

What Problem Does This Paper Address?

Legal case retrieval is a specialized domain where matching a user's legal dispute query to relevant historical cases is notoriously difficult. Legal documents are long, complex, and highly dependent on precise terminology. Surprisingly, while dense retrieval (neural embedding) models have revolutionized general information retrieval, they often fall short in the legal domain because they struggle with the strict lexical alignment required for legal facts and statutes. As a result, the classic keyword-matching algorithm BM25 remains a remarkably resilient baseline.

To help BM25 bridge the gap between user queries and legal documents, researchers use query rewriting—expanding queries with synonyms and legal terminology. However, manually designing high-quality rewriting rules requires immense domain expertise, and naive automated rule generation often yields suboptimal results. The authors tackle this bottleneck by asking: Can an LLM agent autonomously discover, test, and refine its own query-rewriting rules without any gradient-based parameter training?

Methods

The authors propose EVOLVE, a closed-loop agent-environment system that treats rule optimization as an evolutionary process.

The self-evolution framework consisting of an action decision loop, rule generation, experiment planning, and rule elimination.

The framework operates via three core actions executed by a Core LLM:

  1. Rule Generation: The agent analyzes its current active rules, previously eliminated rules, and historical performance scores to generate or edit query-rewriting rules.
  2. Experiment Planning: Instead of testing rules in isolation, the agent selects promising combinations of rules to evaluate on a development dataset, leveraging historical results to find synergistic effects.
  3. Rule Elimination: To prevent the strategy space from exploding, the agent uses a cautious, two-stage consensus mechanism with self-consistency. It runs multiple independent trials to determine if a rule consistently degrades performance before moving it to the "removed" pool.

Crucially, the environment uses a separate, frozen External Rewriting LLM (Qwen3-4B-Thinking) to actually execute the rewrites, ensuring the core agent focuses purely on high-level strategy and reasoning.

Datasets

The framework was evaluated on LeCaRD-v2, a large-scale Chinese legal case retrieval benchmark containing 800 queries and a pool of 55,192 legal documents. The authors partitioned the dataset into:

  • Development Set: 100 instances used entirely for the agent's self-evolution process (up to 500 steps).
  • Test Set: 700 instances held out for final evaluation.

Key Insights and Ideas

  • BM25 Still Reigns Supreme: Empirical testing confirmed that vanilla BM25 outperforms representative dense retrieval models (like bge-m3) and even models continually trained on legal data (like SAILER and ReaKase-8B) when candidate pools are constrained.
  • Evolution is About Selection, Not Just Generation: Interestingly, the agent does not consistently generate better individual rules over time. Instead, it generates a mix of effective and ineffective rules at every phase. The true power of self-evolution lies in its downstream ability to plan clever combinations and ruthlessly prune the bad seeds.
  • Model Scale Dictates Planning Capability: Smaller core models (<20B parameters) lack the reasoning capacity to balance performance across multiple metrics, often over-optimizing for easier targets. In contrast, large models (like gpt-oss-120b) excel at maintaining high-quality "planning anchors" to systematically build on past experimental successes.

Key Results

The self-evolution framework was tested using various core LLMs and compared against vanilla BM25, human-written rules, and a non-evolutionary greedy selection baseline.

  • Main Performance: Powered by gpt-oss-120b, EVOLVE achieved the highest average recall (61.55%), outperforming the vanilla BM25 baseline (58.69%), a combination of three expert human-designed rules (60.52%), and the empirical greedy strategy (60.94%).
  • Dense Model Comparison: All rule-driven BM25 variants significantly outperformed the top dense retriever, ReaKase-8B (57.07% average recall).
  • Pruning Accuracy: The rule elimination mechanism successfully distinguished quality; retained rules maintained a significantly higher median and maximum recall compared to eliminated rules.

Limitations and Future Work

While promising, the authors highlight a few key constraints:

  • Cold-Start Dependency: The framework requires at least one high-quality human-written "seed" rule at initialization to guide the agent effectively, especially when adapting to new legal jurisdictions or languages.
  • Reasoning Model Requirement: The framework relies heavily on advanced reasoning LLMs. When the authors attempted to use standard instruct models (like Qwen3-30B-A3B-Instruct) or weaker multilingual models, the agents failed to respect formatting constraints or generated fragmented, meaningless rules.

Future work will likely focus on reducing the dependency on massive core models and exploring how language-specific capabilities impact the evolutionary trajectory.

Summary updated

BibTeX
@inproceedings{tao2026when,
  author = {Mingxu Tao and Jiawei Hu and Xian Zhou and Wenpeng Hu and Jiajun Cheng and Yunbo Cao and Zhunchen Luo and Guotong Geng},
  title = {{When Rules Learn: A Self-Evolving Agent for Legal Case Retrieval}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2026},
  doi = {10.18653/v1/2026.findings-acl.2152},
}

Loading related content...

Figure