arXiv:2603.21430cs.AIcs.SE2026-03中稿 · AAMAS 2026 EA被引 1

用知识图谱和案例推理提升大模型在特定领域写代码的能力

DomAgent: Leveraging Knowledge Graphs and Case-Based Reasoning for Domain-Specific Code Generation

  • 结合知识图谱与真实案例,动态检索并合成领域知识
  • 在数据科学和卡车软件任务中显著提升代码生成成功率
  • 可独立使用,让小模型逼近大模型的领域表现

大语言模型(LLMs)在代码生成方面表现出色,但因训练数据多来自公开领域,直接用于真实软件开发时成功率较低,尤其在需要高度专业化解决方案的场景下。为解决此问题,我们提出 DomAgent,一个通过结构化推理和精准检索实现领域自适应代码生成的自主编码代理。其核心组件 DomRetriever 模拟人类学习方式,融合自上而下的知识图谱推理与自下而上的案例推理,支持迭代检索与知识合成,确保上下文相关性和任务覆盖广度。DomRetriever 可作为 DomAgent 组成部分或独立集成于任意 LLM 实现灵活领域适配。我们在数据科学领域开放基准数据集 DS-1000 上评估,进一步应用于真实卡车软件开发任务。实验表明,DomAgent 显著提升领域代码生成性能,使小型开源模型在复杂实际应用中大幅缩小与大型专有 LLM 的差距。

原文摘要 · Abstract (English)

Large language models (LLMs) have shown impressive capabilities in code generation. However, because most LLMs are trained on public domain corpora, directly applying them to real-world software development often yields low success rates, as these scenarios frequently require domain-specific knowledge. In particular, domain-specific tasks usually demand highly specialized solutions, which are often underrepresented or entirely absent in the training data of generic LLMs. To address this challenge, we propose DomAgent, an autonomous coding agent that bridges this gap by enabling LLMs to generate domain-adapted code through structured reasoning and targeted retrieval. A core component of DomAgent is DomRetriever, a novel retrieval module that emulates how humans learn domain-specific knowledge, by combining conceptual understanding with experiential examples. It dynamically integrates top-down knowledge-graph reasoning with bottom-up case-based reasoning, enabling iterative retrieval and synthesis of structured knowledge and representative cases to ensure contextual relevance and broad task coverage. DomRetriever can operate as part of DomAgent or independently with any LLM for flexible domain adaptation. We evaluate DomAgent on an open benchmark dataset in the data science domain (DS-1000) and further apply it to real-world truck software development tasks. Experimental results show that DomAgent significantly enhances domain-specific code generation, enabling small open-source models to close much of the performance gap with large proprietary LLMs in complex, real-world applications. The code is available at: https://github.com/Wangshuaiia/DomAgent.

代码生成知识图谱案例推理领域适配

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。