SemaPLC:一個以專案為基礎、驗證門控的 PLC 程式碼生成智慧體框架
SemaPLC: A Project-Grounded, Verification-Gated Agent Harness for PLC Code Generation
August 19, 2026
作者: Yanlun Tu, Huacan Wang, Ziyue Zhou, Jie Zhou, Ningyan Zhu, Ge Chen, Wangyi Chen, Tengfei Zhou, Yifan Zhou, Dasheng Yang, Xiaofeng Mou, Hui Zhang, Yi Xu
cs.AI
摘要
可程式邏輯控制器(PLC)驅動工業廠房,而大型語言模型已能為其生成獨立的程式組織單元(POU)。然而,此類邏輯是否能整合至既有 PLC 專案並正確運行,目前僅在有限的測試中受到檢驗。我們提出 SemaPLC:一個以專案為根基、以驗證為閘控的代理程式框架;它由既有工具組裝而成,但受嚴格的完成規則所支配。SemaPLC 不會在模型自認輸出已足夠時停止,而是僅在記錄的外部檢查確認後才宣告任務完成。這些檢查涵蓋規格、編譯,以及即時執行環境中的行為。在符合既有基準的 117 項獨立 POU 任務中,SemaPLC 於全部七個模型上達到最高的嚴格驗證通過率(平均值 72.6%)。在包含 65 項任務的專案情境軌道中(其生成的邏輯必須在真實專案內編譯並運行),SemaPLC 在整合編譯、靜態行為與動態行為上均取得最高平均值。三層之中,動態行為最具啟發性。我們將生成的邏輯與參考邏輯部署至即時 PLC 執行環境,並比較其執行軌跡,藉此加以衡量。所有方法的靜態分數彼此差距在 10 分以內;相反地,動態分數則將它們明顯區隔開來:各基準方法介於 22.4 至 31.4 分,而 SemaPLC 為 52.2 分。整體而言,我們的驗證閘控框架在各層級均提升平均值,且在執行階段提升最為顯著。實際執行而非靜態評分,才是檢驗所生成控制邏輯是否真正可行的可靠測試。SemaPLC 已開源於 https://github.com/midea-ai/SemaPLC。
English
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.