Large language models (LLMs) often struggle to use tools reliably in domain-specific settings, where APIs may be idiosyncratic, under-documented, or tailored to private workflows. This highlights the need for effective adaptation to task-specific tools. We propose RIMRULE, a neuro-symbolic approach for LLM adaptation based on dynamic rule injection. Compact, interpretable rules are distilled from failure traces and injected into the prompt during inference to improve task performance. These rules are proposed by the LLM itself and consolidated using a Minimum Description Length (MDL) objective that favors generality and conciseness. Each rule is stored in both natural language and a structured symbolic form, supporting efficient retrieval at inference time. Experiments on tool-use benchmarks show that this approach improves accuracy on both seen and unseen tools without modifying LLM weights. It outperforms prompting-based adaptation methods and complements finetuning. Moreover, rules learned from one LLM can be reused to improve others, including long reasoning LLMs, highlighting the portability of symbolic knowledge across architectures.
翻译:大型语言模型(LLM)在领域特定场景中可靠使用工具时常面临困难,这些场景中的API可能具有特殊性、文档不完善或专为私有工作流定制。这凸显了对任务特定工具进行有效适配的需求。我们提出RIMRULE,一种基于动态规则注入的神经符号化LLM适配方法。该方法从失败轨迹中提炼出紧凑、可解释的规则,并在推理过程中将其注入提示,以提升任务性能。这些规则由LLM自身提出,并通过最小描述长度(MDL)目标进行整合,该目标倾向于选择通用且简洁的规则。每条规则均以自然语言和结构化符号形式存储,支持在推理时高效检索。在工具使用基准测试上的实验表明,该方法无需修改LLM权重即可提升对已见和未见工具的准确率。其性能优于基于提示的适配方法,并能与微调技术形成互补。此外,从一个LLM学习到的规则可被重用以改进其他LLM(包括长推理LLM),这凸显了符号知识在不同架构间的可移植性。