arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2401.05443cs.SEcs.AIcs.CLcs.PL
收藏

LLM4PLC:利用大型语言模型实现工业控制系统中可验证的PLC编程

LLM4PLC: Harnessing Large Language Models for Verifiable Programming of PLCs in Industrial Control Systems

University of California, Irvine(加州大学尔湾分校);Siemens Technology(西门子技术研究院)

Mohamad Fakih, Rahul Dharmaji, Yasamin Moghaddas, Gustavo Quiros Araya, Oluwatosin Ogundare, Mohammad Abdullah Al Faruque

AI总结:

本文提出用户引导的迭代流水线LLM4PLC,结合外部验证工具、提示工程和LoRA微调,使LLM能为工业PLC生成可验证正确的程序,将生成成功率从47%提升至72%,代码质量从2.25/10提升至7.75/10。

摘要:

尽管大型语言模型(LLMs)在自动化代码生成领域已确立主导地位,但它们并非没有缺陷。相关问题主要涉及生成代码缺乏执行保证、可解释性不足,以及对关键但小众的编程语言支持欠佳。诸如GPT-4和LLaMa2等最先进的LLMs无法为由可编程逻辑控制器(PLC)运行的工业控制系统(ICS)生成有效程序。我们提出LLM4PLC,这是一个用户引导的迭代流水线,利用用户反馈和外部验证工具(包括语法检查器、编译器和SMV验证器)来引导LLM的生成。我们进一步通过采用提示工程(Prompt Engineering)以及通过创建和使用LoRAs进行模型微调来增强LLM的生成潜力。我们使用FischerTechnik制造测试平台(MFTB)验证了该系统,展示了LLMs如何从生成结构上有缺陷的代码演进为生成适用于工业应用的可验证正确程序。我们在GPT-3.5、GPT-4、Code Llama-7B、微调后的Code Llama-7B模型、Code Llama-34B以及微调后的Code Llama-34B模型上运行了完整的测试套件。所提出的流水线将生成成功率从47%提高到72%,并将专家调查(Survey-of-Experts)的代码质量评分从2.25/10提高到7.75/10。为促进开放研究,我们在专门网页上分享了完整的实验设置、LLM微调权重以及不同程序的视频演示。

英文摘要:

Although Large Language Models (LLMs) have established pre-dominance in automated code generation, they are not devoid of shortcomings. The pertinent issues primarily relate to the absence of execution guarantees for generated code, a lack of explainability, and suboptimal support for essential but niche programming languages. State-of-the-art LLMs such as GPT-4 and LLaMa2 fail to produce valid programs for Industrial Control Systems (ICS) operated by Programmable Logic Controllers (PLCs). We propose LLM4PLC, a user-guided iterative pipeline leveraging user feedback and external verification tools including grammar checkers, compilers and SMV verifiers to guide the LLM's generation. We further enhance the generation potential of LLM by employing Prompt Engineering and model fine-tuning through the creation and usage of LoRAs. We validate this system using a FischerTechnik Manufacturing TestBed (MFTB), illustrating how LLMs can evolve from generating structurally flawed code to producing verifiably correct programs for industrial applications. We run a complete test suite on GPT-3.5, GPT-4, Code Llama-7B, a fine-tuned Code Llama-7B model, Code Llama-34B, and a fine-tuned Code Llama-34B model. The proposed pipeline improved the generation success rate from 47% to 72%, and the Survey-of-Experts code quality from 2.25/10 to 7.75/10. To promote open research, we share the complete experimental setup, the LLM Fine-Tuning Weights, and the video demonstrations of the different programs on our dedicated webpage.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑