Abstract
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: this https URL.
Abstract (translated)
大语言模型(LLMs)在代码生成方面展现出卓越能力。然而,由于大多数LLMs基于公共领域语料训练,直接将其应用于实际软件开发往往成功率较低,因为这些场景通常需要领域特定知识。特别是,领域特定任务通常需要高度专业化的解决方案,而这些方案在通用LLMs的训练数据中往往代表性不足或完全缺失。为应对这一挑战,我们提出了DomAgent——一个自主编码代理,它通过结构化推理和定向检索,使LLMs能够生成领域适配代码,从而弥合这一差距。DomAgent的核心组件是DomRetriever,这是一个新颖的检索模块,通过结合概念理解与经验案例,模拟人类学习领域特定知识的方式。它动态整合自上而下的知识图谱推理与自下而上的基于案例的推理,实现结构化知识与代表性案例的迭代检索与综合,以确保上下文相关性和广泛的任务覆盖。DomRetriever既可作为DomAgent的组成部分运行,也可独立与任何LLM配合使用,实现灵活的领域适配。我们在数据科学领域的开放基准数据集(DS-1000)上评估了DomAgent,并将其进一步应用于真实的卡车软件开发任务。实验结果表明,DomAgent显著提升了领域特定代码生成能力,使小型开源模型在复杂现实应用中大幅缩小了与大型专有LLMs的性能差距。代码已公开于:此https链接。
URL
https://arxiv.org/abs/2603.21430