arXiv:2412.08842cs.SEcs.AI2024-12被引 1

用大模型自动提取领域语言语法,省去人工编写耗时

Kajal: Extracting Grammar of a Source Code Using Large Language Models

  • 通过提示工程和少量样本学习,让大模型生成代码语法规则
  • 少量样本下准确率达60%,无样本时为45%
  • 适合需要快速构建语言解析器的开发团队

理解并提取领域特定语言(DSL)的语法对多种软件工程任务至关重要;然而,手动创建这些语法既耗时又易出错。本文提出Kajal,一种利用大语言模型(LLMs)通过提示工程和少样本学习,从DSL代码片段中自动推断语法的新方法。Kajal动态构建输入提示,利用上下文信息引导LLM生成对应语法,并通过反馈驱动的方式迭代优化。实验表明,采用少样本学习时,Kajal准确率达60%;未使用少样本时,准确率为45%,凸显了少样本学习对工具有效性的重要影响。该方法为自动化DSL语法提取提供了可行方案,未来工作将探索使用更小的开源LLM及在更大数据集上的测试,以进一步验证Kajal的性能。

原文摘要 · Abstract (English)

Understanding and extracting the grammar of a domain-specific language (DSL) is crucial for various software engineering tasks; however, manually creating these grammars is time-intensive and error-prone. This paper presents Kajal, a novel approach that automatically infers grammar from DSL code snippets by leveraging Large Language Models (LLMs) through prompt engineering and few-shot learning. Kajal dynamically constructs input prompts, using contextual information to guide the LLM in generating the corresponding grammars, which are iteratively refined through a feedback-driven approach. Our experiments show that Kajal achieves 60% accuracy with few-shot learning and 45% without it, demonstrating the significant impact of few-shot learning on the tool's effectiveness. This approach offers a promising solution for automating DSL grammar extraction, and future work will explore using smaller, open-source LLMs and testing on larger datasets to further validate Kajal's performance.

代码生成大模型语法提取

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