arXiv:2512.06787cs.CL2025-12

用大模型将自然语言转为可执行的工业流程图代码

LLM4SFC: Sequential Function Chart Generation via Large Language Models

  • 将自然语言描述转化为结构化图表,保留关键逻辑与文本动作
  • 生成成功率75%~94%,确保代码符合工业标准可直接使用
  • 适合自动化产线编程人员快速生成PLC流程图

尽管大型语言模型(LLMs)已用于生成结构化文本型可编程逻辑控制器(PLC)语言如结构化文本(ST),但其他符合IEC 61131-3标准的图形化语言如顺序功能图(SFC)仍研究不足。由于SFC具有图形特性且嵌入了ST代码,难以直接适配传统生成方法,常导致生成非可执行代码,与工业工具链不兼容。本文提出LLM4SFC,首个能接收工业流程自然语言描述并生成可执行SFC的框架。该框架包含三个部分:(i) 精简的结构化表示,保留核心拓扑和内联ST代码,减少冗余文本;(ii) 基于微调与少量样本检索增强生成(RAG),对齐SFC编程规范;(iii) 结构化生成策略,实时剔除非法标记,确保格式合规。我们在来自自动化制造项目的实际SFC数据集上评估,使用开源与专有LLMs,结果表明LLM4SFC能可靠生成语法正确的SFC程序,成功率达75%–94%,有效打通图形与文本型PLC语言的鸿沟,推动工业自动化编程自动化。

原文摘要 · Abstract (English)

While Large Language Models (LLMs) are increasingly used for synthesizing textual PLC programming languages like Structured Text (ST) code, other IEC 61131-3 standard graphical languages like Sequential Function Charts (SFCs) remain underexplored. Generating SFCs is challenging due to graphical nature and ST actions embedded within, which are not directly compatible with standard generation techniques, often leading to non-executable code that is incompatible with industrial tool-chains In this work, we introduce LLM4SFC, the first framework to receive natural-language descriptions of industrial workflows and provide executable SFCs. LLM4SFC is based on three components: (i) A reduced structured representation that captures essential topology and in-line ST and reduced textual verbosity; (ii) Fine-tuning and few-shot retrieval-augmented generation (RAG) for alignment with SFC programming conventions; and (iii) A structured generation approach that prunes illegal tokens in real-time to ensure compliance with the textual format of SFCs. We evaluate LLM4SFC on a dataset of real-world SFCs from automated manufacturing projects, using both open-source and proprietary LLMs. The results show that LLM4SFC reliably generates syntactically valid SFC programs effectively bridging graphical and textual PLC languages, achieving a generation generation success of 75% - 94%, paving the way for automated industrial programming.

工业AIPLC编程大模型应用

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。