Table of Contents
Fetching ...

Vendor-Aware Industrial Agents: RAG-Enhanced LLMs for Secure On-Premise PLC Code Generation

Joschka Kersting, Michael Rummel, Gesa Benndorf

TL;DR

The paper addresses the challenge of generating vendor-specific PLC code in a low-data domain by introducing a RAG-enhanced coding assistant tailored to Mitsubishi Electric ST and the GX Works3 environment, enabling secure on-premise usage without large-scale fine-tuning. It employs directed retrieval from three MEL-focused knowledge streams, compiler feedback, and competitive multi-model orchestration to produce compilable ST programs, validated through a GX Works3 compiler loop. Key contributions include the first MEL-focused RAG coding assistant, a competitive multi-model architecture with compiler-driven repair, and a thorough evaluation in a real MEL environment with code-compile statistics and expert assessments. This approach demonstrates that RAG, guided by vendor-specific prompts and constraints, can deliver practical, secure, high-quality industrial code generation suitable for SMEs and safety-critical settings without cloud exposure.

Abstract

Programmable Logic Controllers are operated by proprietary code dialects; this makes it challenging to train coding assistants. Current LLMs are trained on large code datasets and are capable of writing IEC 61131-3 compatible code out of the box, but they neither know specific function blocks, nor related project code. Moreover, companies like Mitsubishi Electric and their customers do not trust cloud providers. Hence, an own coding agent is the desired solution to cope with this. In this study, we present our work on a low-data domain coding assistant solution for industrial use. We show how we achieved high quality code generation without fine-tuning large models and by fine-tuning small local models for edge device usage. Our tool lets several AI models compete with each other, uses reasoning, corrects bugs automatically and checks code validity by compiling it directly in the chat interface. We support our approach with an extensive evaluation that comes with code compilation statistics and user ratings. We found that a Retrieval-Augmented Generation (RAG) supported coding assistant can work in low-data domains by using extensive prompt engineering and directed retrieval.

Vendor-Aware Industrial Agents: RAG-Enhanced LLMs for Secure On-Premise PLC Code Generation

TL;DR

The paper addresses the challenge of generating vendor-specific PLC code in a low-data domain by introducing a RAG-enhanced coding assistant tailored to Mitsubishi Electric ST and the GX Works3 environment, enabling secure on-premise usage without large-scale fine-tuning. It employs directed retrieval from three MEL-focused knowledge streams, compiler feedback, and competitive multi-model orchestration to produce compilable ST programs, validated through a GX Works3 compiler loop. Key contributions include the first MEL-focused RAG coding assistant, a competitive multi-model architecture with compiler-driven repair, and a thorough evaluation in a real MEL environment with code-compile statistics and expert assessments. This approach demonstrates that RAG, guided by vendor-specific prompts and constraints, can deliver practical, secure, high-quality industrial code generation suitable for SMEs and safety-critical settings without cloud exposure.

Abstract

Programmable Logic Controllers are operated by proprietary code dialects; this makes it challenging to train coding assistants. Current LLMs are trained on large code datasets and are capable of writing IEC 61131-3 compatible code out of the box, but they neither know specific function blocks, nor related project code. Moreover, companies like Mitsubishi Electric and their customers do not trust cloud providers. Hence, an own coding agent is the desired solution to cope with this. In this study, we present our work on a low-data domain coding assistant solution for industrial use. We show how we achieved high quality code generation without fine-tuning large models and by fine-tuning small local models for edge device usage. Our tool lets several AI models compete with each other, uses reasoning, corrects bugs automatically and checks code validity by compiling it directly in the chat interface. We support our approach with an extensive evaluation that comes with code compilation statistics and user ratings. We found that a Retrieval-Augmented Generation (RAG) supported coding assistant can work in low-data domains by using extensive prompt engineering and directed retrieval.

Paper Structure

This paper contains 5 sections, 2 figures, 1 table.

Figures (2)

  • Figure 1: Example of generated ST code using our GeneriST web app (built with Streamlit streamlit2025).
  • Figure 2: System architecture for Mitsubishi Electric ST coding assistant with RAG, competitive multi-model orchestration, and compiler-driven iterative repair.