arXiv:2603.12712cs.SEcs.LG2026-03

通过拆解设计需求提升CAD代码生成效果

Design-Specification Tiling for ICL-based CAD Code Generation

  • 将设计规格分解为多粒度组件,按覆盖度选例
  • 在多个模型上显著提升代码生成质量
  • 适合需要精准满足复杂设计要求的工程师

大型语言模型在代码生成方面表现卓越,但在计算机辅助设计(CAD)等特定领域仍受限于高质量训练数据稀缺。上下文学习(ICL)通过提供任务相关示例实现零训练生成,但其效果高度依赖示例选择策略。现有方法多基于相似性或单点多样性,忽视了CAD设计规格的组合特性——查询常含多项功能需求、几何约束与设计基元。导致所选示例虽个体相关,但整体冗余,难以覆盖复杂需求。本文提出“知识充分性”作为示例选择的理论目标,旨在选取紧凑且能最大程度满足目标设计规格中各类要求的示例集合。为此,我们引入设计规格分块(Design-Specification Tiling, DST),通过将设计规格分解为多粒度成分,并测量所选示例覆盖查询成分的比例,估算知识充分性。我们进一步证明该优化问题可建模为子模最大化问题,设计了一种具有(1−1/e)近似保证的多项式时间贪心算法。在多个LLM上的大量实验表明,DST显著提升CAD代码生成质量,持续优于现有ICL示例选择策略,凸显了需求层面知识覆盖对领域代码生成的重要性。

原文摘要 · Abstract (English)

Large language models~(LLMs) have demonstrated remarkable capabilities in code generation, yet their performance remains limited on domain-specific tasks such as Computer-Aided Design~(CAD) code generation, largely due to the scarcity of high-quality training data. In-Context Learning~(ICL) provides a training-free alternative by prompting LLMs with task-specific exemplars, but its effectiveness critically depends on how exemplars are selected. Existing selection strategies mainly rely on similarity or point-wise diversity, often overlooking the compositional nature of CAD design specifications, where a query may involve multiple functional requirements, geometric constraints, and design primitives. As a result, selected exemplars can be individually relevant but collectively redundant, providing insufficient coverage for complex design requirements. In this work, we propose \emph{knowledge sufficiency} as a principled objective for exemplar selection, aiming to select a compact set of exemplars that maximally satisfies the requirements contained in a target design specification. To instantiate this objective, we introduce \emph{Design-Specification Tiling~(DST)}, which estimates knowledge sufficiency through a surrogate tiling ratio by decomposing design specifications into multi-granular components and measuring the proportion of query components covered by selected exemplars. We further show that optimizing this objective can be formulated as a submodular maximization problem, and develop a polynomial-time greedy algorithm tailored to this setting with a $(1-1/e)$-approximation guarantee. Extensive experiments across multiple LLMs demonstrate that DST substantially improves CAD code generation quality and consistently outperforms existing ICL exemplar selection strategies, highlighting the importance of requirement-level knowledge coverage for domain-specific code generation.

CAD生成ICL示例选择设计规范

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