Skip to main content
QUICK REVIEW

[论文解读] nl2spec: Interactively Translating Unstructured Natural Language to Temporal Logics with Large Language Models

Matthias Cosler, Christopher Hahn|arXiv (Cornell University)|Mar 8, 2023
Software Engineering Research被引用 6
一句话总结

nl2spec 是一种框架,利用大型语言模型(LLMs)通过将输入分解为用户可编辑的子翻译,实现交互式地将非结构化的自然语言需求转化为形式化的时序逻辑规范(例如 LTL)。该框架通过迭代优化,在形式化复杂且模糊的需求时实现了 86.11% 的准确率,减少了手动重写工作,并提高了错误纠正效率。

ABSTRACT

A rigorous formalization of desired system requirements is indispensable when performing any verification task. This often limits the application of verification techniques, as writing formal specifications is an error-prone and time-consuming manual task. To facilitate this, we present nl2spec, a framework for applying Large Language Models (LLMs) to derive formal specifications (in temporal logics) from unstructured natural language. In particular, we introduce a new methodology to detect and resolve the inherent ambiguity of system requirements in natural language: we utilize LLMs to map subformulas of the formalization back to the corresponding natural language fragments of the input. Users iteratively add, delete, and edit these sub-translations to amend erroneous formalizations, which is easier than manually redrafting the entire formalization. The framework is agnostic to specific application domains and can be extended to similar specification languages and new neural models. We perform a user study to obtain a challenging dataset, which we use to run experiments on the quality of translations. We provide an open-source implementation, including a web-based frontend.

研究动机与目标

  • 为解决手动编写形式化、易出错的系统规范所面临的挑战,从而限制形式化验证技术的采用。
  • 通过支持 LLM 生成的翻译进行交互式、增量式优化,降低形式化规范编写的认知负荷和错误率。
  • 通过子翻译编辑检测并解决自然语言需求中的模糊性,特别是关于运算符优先级和语义模糊性的问题。
  • 设计一种与特定 LLM 和规范语言无关的框架,支持扩展至 STL 或 SVA 等领域。
  • 通过专家用户研究的基准数据集评估框架的有效性,证明其在准确率和可用性方面的提升。

提出的方法

  • 该框架将自然语言输入分解为子翻译,其中每个公式片段均映射回对应的自然语言短语。
  • 采用交互式 few-shot 提示方案与 LLM 配合生成这些子翻译,允许用户在不重写整个形式化内容的前提下添加、编辑或删除子翻译。
  • 每个子翻译均附带置信度分数和替代建议,使用户能够迭代修正错误并解决模糊性问题。
  • 系统通过显式语法修改(如添加括号)支持用户编辑,以解决优先级模糊问题,例如在 'a holds until b holds or always a holds' 中。
  • 后端使用 LLM(如 Codex)生成初始翻译,用户通过最多三轮翻译循环进行优化。
  • 该框架实现为基于 Web 的工具并开源,支持与多种时序逻辑语言集成。

实验结果

研究问题

  • RQ1LLM 是否能有效将自然语言需求分解为语义上有意义的子翻译,以支持交互式优化?
  • RQ2与整体翻译相比,子翻译的交互式编辑是否显著提升了形式化规范生成的准确率和可用性?
  • RQ3子翻译方法在解决自然语言需求中的模糊性(特别是运算符优先级和语义模糊性)方面有多有效?
  • RQ4用户在多大程度上可以通过对子翻译进行最小修改纠正错误的形式化,而非重写整个公式?
  • RQ5该框架在具有挑战性的、经专家验证的模糊且复杂需求基准数据集上的端到端翻译准确率是多少?

主要发现

  • nl2spec 在 36 个经专家验证的自然语言需求基准上实现了 86.11% 的端到端翻译准确率,成功形式化了 31 个实例。
  • 平均仅需 1.4 轮翻译循环即可实现正确形式化,其中 20 个错误翻译实例中有 15 个在 ≤3 轮内被修正。
  • 子翻译方法通过编辑子翻译明确了运算符优先级,成功修正了如 'a holds until b holds or always a holds' 这类模糊案例。
  • 通过将子翻译 'b must hold in the next two steps' 修改为 'b | X b',解决了初始公式中嵌套错误的语义模糊性问题。
  • 该框架显著减少了手动重写的需求:36 个实例中仅有 5 个需要完整手动重编码,其余 31 个均通过子翻译编辑修复。
  • 即使使用性能较弱的模型(如 Codex),子翻译方法相比直接提示仍提升了 4 个实例的翻译成功率,证明了该方法的鲁棒性。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。