用大模型生成跨文件的工业级领域语言代码,效果显著提升。
Leveraging LLMs for Multi-File DSL Code Generation: An Industrial Case Study

- 将DSL目录结构转为带路径的JSON,支持单次生成多文件代码。
- 微调后准确率高,跨文件依赖和结构一致性达1.00。
- 适合需要自动化生成复杂代码的工业研发团队。
大型语言模型在通用代码生成上表现优异,但在企业级领域特定语言(DSL)上的应用仍不充分,尤其在仅凭自然语言指令即生成跨多个文件与目录结构的项目级变更方面。本文报告宝马公司的一项工业案例研究,将面向代码的大模型适配至基于Xtext的DSL,用于生成和修改驱动下游Java/TypeScript代码的项目根级DSL文件。我们构建了从数据集构建、多文件任务表示、模型适配到评估的端到端流程。通过将DSL目录层级编码为保持路径的结构化JSON,实现单响应式仓库级生成,并学习跨文件依赖关系。评估两种指令微调的代码模型(Qwen2.5-Coder和DeepSeek-Coder,均为7B参数),采用三种配置:基线提示、单样本上下文学习与参数高效微调(QLoRA)。除标准相似度指标外,引入任务专用指标以评估编辑正确性和仓库结构保真度。微调在各模型与指标上均带来最显著提升,达到高精确匹配率、强编辑相似性及1.00的结构保真度。单样本上下文学习也带来小但稳定的改进。通过专家开发者调查与现有代码生成器执行验证,进一步证明其实际可用性。
原文摘要 · Abstract (English)
Large language models (LLMs) perform strongly on general-purpose code generation, yet their applicability to enterprise domain-specific languages (DSLs) remains underexplored, especially for repository-scale change generation spanning multiple files and folder structures from a single natural-language (NL) instruction. We report an industrial case study at BMW that adapts code-oriented LLMs to generate and modify project-root DSL artifacts for an Xtext-based DSL that drives downstream Java/TypeScript code generation. We develop an end-to-end pipeline for dataset construction, multi-file task representation, model adaptation, and evaluation. We encode DSL folder hierarchies as structured, path-preserving JSON, allowing single-response generation at repository scale and learning cross-file dependencies. We evaluate two instruction-tuned code LLMs (Qwen2.5-Coder and DeepSeek-Coder, 7B) under three configurations: baseline prompting, one-shot in-context learning, and parameter-efficient fine-tuning (QLoRA). Beyond standard similarity metrics, we introduce task-specific measures that assess edit correctness and repository structural fidelity. Fine-tuning yields the most significant gains across models and metrics, achieving high exact-match accuracy, substantial edit similarity, and structural fidelity of 1.00 on our held-out set for multi-file outputs. At the same time, one-shot in-context learning provides smaller but consistent improvements over baseline prompting. We further validate practical utility via an expert developer survey and an execution-based check using the existing code generator.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。