# Training LLMs for Generating IEC 61131-3 Structured Text with Online Feedback

arXiv: https://arxiv.org/abs/2410.22159 · HTML: https://mlsanity.com/paper/2410.22159/

## Key facts

- Cited by 3 papers in the map (data through 14 Oct 2026).
- First posted on arXiv 29 Oct 2024.

## Built on by (most cited first, 3 of 3)

- [AutoPLC: Generating Vendor-Aware Structured Text for Programmable Logic Controllers](https://mlsanity.com/paper/2412.02410/) (2024)
- [Vendor-Aware Industrial Agents: RAG-Enhanced LLMs for Secure On-Premise PLC Code Generation](https://mlsanity.com/paper/2511.09122/) (2025)
- [IndustryCode: A Benchmark for Industry Code Generation](https://mlsanity.com/paper/2604.02729/) (2026)

## Abstract (arXiv)

IEC 61131-3 Structured Text (ST) is a widely used programming language for programmable logic controllers (PLCs) in automation systems. However, generating ST code with LLMs poses unique challenges due to limited data in public training datasets and the complexity of ST language syntax. This paper proposes an approach to fine-tune LLMs for the generation of ST code that leverages a preference-based learning method through an online process involving compiler feedback and evaluation from an LLM-based ST expert. In this framework, the model is iteratively refined and generates new training samples, which are subsequently evaluated by a compiler for syntactical correctness and by a specialized LLM that excels at assessing semantic accuracy, though it is not optimized for code generation itself. This approach results in marked improvements for the trained LLM, leading to higher compilation success rates and better semantic precision. As a result, the framework proves highly suitable for industrial automation applications and outperforms state-of-the-art models.
