SemaPLC:一种基于项目、验证门控的PLC代码生成代理框架

·

研究论文 · 2026/08/20

可编程逻辑控制器(PLC)运行工业工厂,大型语言模型已能为其生成独立的程序组织单元(POU)。但此类逻辑能否集成到现有PLC项目并正确运行,仅在有限测试中验证过。我们提出SemaPLC,一个基于项目、验证门控的代理框架,由常规工具组装,但受严格完成规则约束。SemaPLC仅在外部检查确认后宣布任务完成,而非模型自评。检查涵盖规范、编译和实时运行行为。在117个独立POU任务上,它在所有七个模型上取得最高严格验证通过率(平均72.6%)。在65个需在真实项目中编译运行的任务上,它在集成编译、静态行为和动态行为上取得最高平均值。三层中,动态行为最具揭示性。我们通过将生成和参考逻辑部署到实时PLC运行时并比较执行轨迹来测量。所有方法静态得分相差10分以内,而动态得分显著区分,基线为22.4至31.4,SemaPLC为52.2。总体而言,我们的验证门控框架在每层提升平均值,尤其在运行时。执行而非静态评分,是测试生成控制逻辑是否真正有效的可靠方法。SemaPLC已开源:https://github.com/midea-ai/SemaPLC。

该论文提出了一种新的验证门控框架,强调通过实际执行而非静态评分来评估PLC代码生成,实验表明其显著优于基线,对工业自动化领域具有重要价值。

Programmable logic controllers (PLCs) run industrial plants, and large language models can already generate independent program organization units (POUs) for them. Whether such logic integrates into an existing PLC project and then runs correctly has been checked only in limited tests. We present SemaPLC, a project-grounded and verification-gated agent harness assembled from conventional tools but governed by a strict completion rule. Rather than stopping when the model judges its own output adequate, SemaPLC declares a task complete only when logged external checks confirm it. Those checks cover the specification, the compilation, and the behavior on a live runtime. On 117 independent-POU tasks matching existing benchmarks, it attains the highest strict verified pass rate on all seven models (72.6\% mean). On a project-context track of 65 tasks whose generated logic must compile and run inside a real project, it attains the highest mean on integrated compilation, static behavior, and dynamic behavior. Of the three layers, dynamic behavior is the most revealing. We measure it by deploying the generated and the reference logic to a live PLC runtime and comparing their executed traces. All methods fall within 10 static points of one another, whereas dynamic scores separate them sharply, from 22.4 to 31.4 for the baselines against 52.2 for SemaPLC. Overall, our verification-gated harness raises the mean at every layer and most sharply at runtime. Execution, not static scoring, is the faithful test of whether generated control logic actually works. SemaPLC is open-sourced at https://github.com/midea-ai/SemaPLC.

阅读原文

参与讨论