用自然语言注释增强代码语义,让AI更懂开发者意图。
Prompt Less, Smile More: MTP with Semantic Engineering in Lieu of Prompt Engineering
- 通过自然语言注释嵌入上下文,动态扩展代码语义。
- 在真实场景中提升提示生成准确率,性能接近手动调优。
- 适合希望降低提示工程成本的开发人员使用。
人工智能集成编程正成为基于大语言模型构建智能系统的核心范式。现有方法如语义类型编程(MTP)通过利用代码中已有的语义自动生提示,但许多实际应用依赖于上下文线索、开发者意图和领域特定推理,这些仅靠静态代码语义难以表达。为此,我们提出轻量级的语义工程方法,通过增强程序语义,使基于LLM的系统能更准确反映开发者意图,无需全手工设计提示。我们引入语义上下文注释(SemTexts),一种语言级机制,允许开发者将自然语言上下文直接嵌入程序结构。该方法集成于Jac编程语言,扩展了MTP,在提示生成阶段融入这些增强后的语义。此外,我们构建了一个反映真实AI集成应用情景的评测套件。评估结果表明,语义工程显著提升了提示保真度,在性能上达到与提示工程相当水平,同时大幅降低开发者工作量。
原文摘要 · Abstract (English)
AI-Integrated programming is emerging as a foundational paradigm for building intelligent systems with large language models (LLMs). Recent approaches such as Meaning Typed Programming (MTP) automate prompt generation by leveraging the semantics already present in code. However, many real-world applications depend on contextual cues, developer intent, and domain-specific reasoning that extend beyond what static code semantics alone can express. To address this limitation, we introduce Semantic Engineering, a lightweight method for enriching program semantics so that LLM-based systems can more accurately reflect developer intent without requiring full manual prompt design. We present Semantic Context Annotations (SemTexts), a language-level mechanism that allows developers to embed natural-language context directly into program constructs. Integrated into the Jac programming language, Semantic Engineering extends MTP to incorporate these enriched semantics during prompt generation. We further introduce a benchmark suite designed to reflect realistic AI-Integrated application scenarios. Our evaluation shows that Semantic Engineering substantially improves prompt fidelity, achieving performance comparable to Prompt Engineering while requiring significantly less developer effort.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。