用代码规划:面向鲁棒自然语言到领域特定语言生成的方法对比
Plan with Code: Comparing approaches for robust NL to DSL generation
AI总结:
针对大语言模型生成含自定义API名的领域特定语言时幻觉多、语法错的问题,研究RPA场景下RAG与LLM结合的DSL生成优化,发现优化后RAG域内效果追平微调模型,域外API生成相似度高7分。
摘要:
在许多编排任务中,基于代码的规划被认为是更可靠的方法。这是因为代码比自然语言生成的步骤更易处理,且能通过将确定性逻辑抽象为函数,轻松支持更复杂的序列。同时,借助可在代码上运行的解析检查,还能发现函数名称错误的问题。\n然而,代码生成方法的进展仍局限于C、C++、Python等通用语言。大语言模型(LLM)在处理领域特定语言(DSL)中的自定义函数名时仍面临挑战,会导致更高的幻觉率和语法错误,这类问题在通常属于规划组成部分的自定义函数名中更为常见。此外,让LLM跟进更新的函数名也是一个难题。这给大量API上的任务规划等场景带来了挑战,因为这类规划以包含自定义API名称的DSL形式呈现。\n本文将机器人流程自动化(RPA)领域的工作流自动化作为任务规划的一个特例展开研究,提出了结合检索增强生成(RAG)与LLM的DSL生成优化方案,并通过消融实验将这些策略与微调模型进行对比。结果显示,微调模型在代码相似度指标上得分最高,但经本文优化后,RAG方法在测试集的域内API名称生成上质量可与微调模型持平;此外,它在域外或未见过的API名称上具有显著优势,相似度指标比微调模型高出7分。
英文摘要:
Planning in code is considered a more reliable approach for many orchestration tasks. This is because code is more tractable than steps generated via Natural Language and make it easy to support more complex sequences by abstracting deterministic logic into functions. It also allows spotting issues with incorrect function names with the help of parsing checks that can be run on code. Progress in Code Generation methodologies, however, remains limited to general-purpose languages like C, C++, and Python. LLMs continue to face challenges with custom function names in Domain Specific Languages or DSLs, leading to higher hallucination rates and syntax errors. This is more common for custom function names, that are typically part of the plan. Moreover, keeping LLMs up-to-date with newer function names is an issue. This poses a challenge for scenarios like task planning over a large number of APIs, since the plan is represented as a DSL having custom API names. In this paper, we focus on workflow automation in RPA (Robotic Process Automation) domain as a special case of task planning. We present optimizations for using Retrieval Augmented Generation (or RAG) with LLMs for DSL generation along with an ablation study comparing these strategies with a fine-tuned model. Our results showed that the fine-tuned model scored the best on code similarity metric. However, with our optimizations, RAG approach is able to match the quality for in-domain API names in the test set. Additionally, it offers significant advantage for out-of-domain or unseen API names, outperforming Fine-Tuned model on similarity metric by 7 pts.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。