Papers
Topics
Authors
Recent
Gemini 2.5 Flash
Gemini 2.5 Flash
41 tokens/sec
GPT-4o
59 tokens/sec
Gemini 2.5 Pro Pro
41 tokens/sec
o3 Pro
7 tokens/sec
GPT-4.1 Pro
50 tokens/sec
DeepSeek R1 via Azure Pro
28 tokens/sec
2000 character limit reached

LLM4PLC: Harnessing Large Language Models for Verifiable Programming of PLCs in Industrial Control Systems (2401.05443v1)

Published 8 Jan 2024 in cs.SE, cs.AI, cs.CL, and cs.PL

Abstract: Although LLMs have established pre-dominance in automated code generation, they are not devoid of shortcomings. The pertinent issues primarily relate to the absence of execution guarantees for generated code, a lack of explainability, and suboptimal support for essential but niche programming languages. State-of-the-art LLMs such as GPT-4 and LLaMa2 fail to produce valid programs for Industrial Control Systems (ICS) operated by Programmable Logic Controllers (PLCs). We propose LLM4PLC, a user-guided iterative pipeline leveraging user feedback and external verification tools including grammar checkers, compilers and SMV verifiers to guide the LLM's generation. We further enhance the generation potential of LLM by employing Prompt Engineering and model fine-tuning through the creation and usage of LoRAs. We validate this system using a FischerTechnik Manufacturing TestBed (MFTB), illustrating how LLMs can evolve from generating structurally flawed code to producing verifiably correct programs for industrial applications. We run a complete test suite on GPT-3.5, GPT-4, Code Llama-7B, a fine-tuned Code Llama-7B model, Code Llama-34B, and a fine-tuned Code Llama-34B model. The proposed pipeline improved the generation success rate from 47% to 72%, and the Survey-of-Experts code quality from 2.25/10 to 7.75/10. To promote open research, we share the complete experimental setup, the LLM Fine-Tuning Weights, and the video demonstrations of the different programs on our dedicated webpage.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (62)
  1. T. Ahmed, N. Ledesma and P. Devanbu “SynShine: Improved Fixing of Syntax Errors” In IEEE Transactions on Software Engineering 49.04 Los Alamitos, CA, USA: IEEE Computer Society, 2023, pp. 2169–2181 DOI: 10.1109/TSE.2022.3212635
  2. “Model-Based Design of Complex Aeronautical Systems Through Digital Twin and Thread Concepts” In IEEE Systems Journal 14.2, 2020, pp. 1568–1579 DOI: 10.1109/JSYST.2019.2925627
  3. Jan Olaf Blech and Sidi Ould Biha “On Formal Reasoning on the Semantics of PLC using Coq”, 2013 eprint: arXiv:1301.3047
  4. “Automated generation of PLC code for implementing mode-based control algorithms in buildings” In 2022 30th Mediterranean Conference on Control and Automation (MED), 2022, pp. 1087–1092 DOI: 10.1109/MED54222.2022.9837182
  5. Arquimedes Canedo and Mohammad Abdulah Al-Faruque “Towards parallel execution of IEC 61131 industrial cyber-physical systems applications” In 2012 Design, Automation & Test in Europe Conference & Exhibition (DATE), 2012, pp. 554–557 DOI: 10.1109/DATE.2012.6176530
  6. “The nuXmv symbolic model checker” In Computer Aided Verification: 26th International Conference, CAV 2014, Held as Part of the Vienna Summer of Logic, VSL 2014, Vienna, Austria, July 18-22, 2014. Proceedings 26, 2014, pp. 334–342 Springer
  7. “Evaluating large language models trained on code.(2021)” In arXiv preprint arXiv:2107.03374, 2021
  8. “Mitigation of catastrophic forgetting in recurrent neural networks using a Fixed Expansion Layer” In The 2013 International Joint Conference on Neural Networks (IJCNN), 2013, pp. 1–7 DOI: 10.1109/IJCNN.2013.6707047
  9. “AI-Based Assistance System for Manufacturing” In 2022 IEEE 27th International Conference on Emerging Technologies and Factory Automation (ETFA), 2022, pp. 1–4 IEEE
  10. Alpana Dubey “Evaluating software engineering methods in the context of automation applications” In 2011 9th IEEE International Conference on Industrial Informatics, 2011, pp. 585–590 DOI: 10.1109/INDIN.2011.6034944
  11. “Diversity-Driven Automated Formal Verification” In Proceedings of 44th International Conference on Software Engineering (ICSE 2022), 2022, pp. 749–761 ACM DOI: 10.1145/3510003.3510138
  12. FischerTechnik “Factory Simulation 24V” Product description and specifications, 2023 URL: https://www.fischertechnik.de/en/products/industry-and-universities/training-models/536634-factory-simulation-24v
  13. “Unixcoder: Unified cross-modal pre-training for code representation” In Proceedings of the Annual Meeting of the Association for Computational Linguistics 1, 2022
  14. “Automated Test Generation for IEC 61131-3 ST Programs via Dynamic Symbolic Execution” In 2019 International Symposium on Theoretical Aspects of Software Engineering (TASE), 2019, pp. 200–207 DOI: 10.1109/TASE.2019.00004
  15. “Automated test generation for IEC 61131-3 ST programs via dynamic symbolic execution” In Science of Computer Programming 206 Elsevier, 2021, pp. 102608
  16. “Lora: Low-rank adaptation of large language models” In International Conference on Learning Representations, 2022
  17. “Industrial automation global market report” In International Society of Automation, 2022 URL: https://www.automation.com/en-us/articles/july-2022/industrial-automation-global-market-report-2022
  18. International Electrotechnical Commission “Programmable Controllers – Part 3: Programming Languages”, 2013 URL: http://webstore.iec.ch/publication/4552
  19. Jeff C. Jensen, Danica H. Chang and Edward A. Lee “A model-based design methodology for cyber-physical systems” In 2011 7th International Wireless Communications and Mobile Computing Conference, 2011, pp. 1666–1671 DOI: 10.1109/IWCMC.2011.5982785
  20. E.V. Kuzmin, A.A. Shipov and D.A. Ryabukhin “Construction and verification of PLC programs by LTL specification” In 2013 Tools & Methods of Program Analysis, 2013, pp. 15–22 DOI: 10.1109/TMPA.2013.7163716
  21. “CodeRL: Mastering Code Generation through Pretrained Models and Deep Reinforcement Learning”, 2022 eprint: arXiv:2207.01780
  22. “Few-Shot Parameter-Efficient Fine-Tuning is Better and Cheaper than In-Context Learning”, 2022
  23. “Ro{BERT}a: A Robustly Optimized {BERT} Pretraining Approach”, 2020 eprint: arXiv:1907.11692
  24. “Network as automation platform for collaborative E-car charging at the residential premises” US Patent 8,957,634, Google Patents, 2015 URL: https://patents.google.com/patent/US8957634B2/en
  25. “LLaMA-Reviewer: Advancing Code Review Automation with Large Language Models through Parameter-Efficient Fine-Tuning (Practical Experience Report)” In arXiv preprint arXiv:2308.11148, 2023
  26. “Codexglue: A machine learning benchmark dataset for code understanding and generation” In arXiv preprint arXiv:2102.04664, 2021
  27. “Bringing Semantics to Web Services: the OWL-S approach” In Lecture Notes in Computer Science 3387, 2004, pp. 26–42 DOI: 10.1007/978-3-540-30581-1˙4
  28. Pieter Mosterman “Model-Based Design of Embedded Systems” In 2007 IEEE International Conference on Microelectronic Systems Education (MSE’07), 2007, pp. 3–3 DOI: 10.1109/MSE.2007.65
  29. “Model Based Design in Automotive Open System Architecture” In 2023 7th International Conference on Intelligent Computing and Control Systems (ICICCS), 2023, pp. 1211–1216 DOI: 10.1109/ICICCS56967.2023.10142603
  30. “A Comprehensive Overview of Large Language Models”, 2023 eprint: arXiv:2307.06435
  31. Nucleron “MATIEC” Source code repository, 2017 URL: https://github.com/nucleron/matiec
  32. OpenAI “GPT-4 Technical Report”, 2023 eprint: arXiv:2303.08774
  33. OSCAT “OSCAT BASIC” Product description and specifications, 2023 URL: http://www.oscat.de/de/63-oscat-basic-321.html
  34. “An overview of model checking practices on verification of PLC software” In Software & Systems Modeling 15.4 Springer, 2016, pp. 937–960
  35. “Examining Zero-Shot Vulnerability Repair with Large Language Models”, 2021 eprint: arXiv:2112.02125
  36. “Opportunities and challenges of static code analysis of IEC 61131-3 programs” In Proceedings of 2012 IEEE 17th International Conference on Emerging Technologies & Factory Automation (ETFA 2012), 2012, pp. 1–8 IEEE
  37. “Static code analysis of IEC 61131-3 programs: Comprehensive tool support and experiences from large-scale industrial application” In IEEE Transactions on Industrial Informatics 13.1 IEEE, 2016, pp. 37–47
  38. Juha Puttonen, Andrei Lobov and José L Martinez Lastra “Semantics-based composition of factory automation processes encapsulated by web services” In IEEE Transactions on industrial informatics 9.4 IEEE, 2012, pp. 2349–2359
  39. “Language models are unsupervised multitask learners” In OpenAI blog 1.8, 2019, pp. 9
  40. Ossama Rashad, Omneya Attallah and Iman Morsi “A PLC-SCADA Pipeline for Managing Oil Refineries” In 2022 5th International Conference on Computing and Informatics (ICCI), 2022, pp. 216–220 DOI: 10.1109/ICCI54321.2022.9756108
  41. “Code llama: Open foundation models for code” In arXiv preprint arXiv:2308.12950, 2023
  42. “Understanding the Effectiveness of Early Weight Averaging for Training Large Language Models”, 2023 eprint: arXiv:2306.03241
  43. Frank Schumacher, Sebastian Schröck and Alexander Fay “Tool support for an automatic transformation of GRAFCET specifications into IEC 61131-3 control code” In 2013 IEEE 18th Conference on Emerging Technologies & Factory Automation (ETFA), 2013, pp. 1–4 IEEE
  44. Mohammed Latif Siddiq, Beatrice Casey and Joanna C.S. Santos “A Lightweight Framework for High-Quality Code Generation”, 2023 eprint: arXiv:2307.08220
  45. Aleksandar J. Spasić and Dragan S. Janković “Using ChatGPT Standard Prompt Engineering Techniques in Lesson Preparation: Role, Instructions and Seed-Word Prompts” In 2023 58th International Scientific Conference on Information, Communication and Energy Systems and Technologies (ICEST), 2023, pp. 47–50 DOI: 10.1109/ICEST58410.2023.10187269
  46. “Model-Based Design Automation of Hardware/Software Co-Designs for Xilinx Zynq PSoCs” In 2018 International Conference on ReConFigurable Computing and FPGAs (ReConFig), 2018, pp. 1–8 DOI: 10.1109/RECONFIG.2018.8641736
  47. “Interactive and Visual Prompt Engineering for Ad-hoc Task Adaptation with Large Language Models” In IEEE Transactions on Visualization and Computer Graphics 29.1, 2023, pp. 1146–1156 DOI: 10.1109/TVCG.2022.3209479
  48. “Domain Adaptive Code Completion via Language Models and Decoupled Domain Databases” In ACM International Conference on Automated Software Engineering, 2023
  49. Artur Tarassow “The potential of LLMs for coding with low-resource and domain-specific programming languages”, 2023 eprint: arXiv:2307.13018
  50. “VeriGen: A Large Language Model for Verilog Code Generation” In arXiv preprint arXiv:2308.00708, 2023
  51. “AutoML in the Age of Large Language Models: Current Challenges, Future Opportunities and Risks”, 2023 eprint: arXiv:2306.08107
  52. “Llama 2: Open Foundation and Fine-Tuned Chat Models”, 2023 eprint: arXiv:2307.09288
  53. “LLaMA: open and efficient foundation language models, 2023” In URL https://arxiv. org/abs/2302.13971, 2023
  54. “Attention is all you need” In Advances in neural information processing systems 30, 2017
  55. B. Vogel-Heuser, D. Witsch and U. Katzke “Automatic code generation from a UML model to IEC 61131-3 and system configuration tools” In 2005 International Conference on Control and Automation 2, 2005, pp. 1034–1039 Vol. 2 DOI: 10.1109/ICCA.2005.1528274
  56. “Chain of Thought Prompting Elicits Reasoning in Large Language Models” In Advances in Neural Information Processing Systems Vol. 35, 2022
  57. “Finetuned Language Models Are Zero-Shot Learners”, 2021 eprint: arXiv:2109.01652
  58. “Supporting troubleshooting in machine and plant manufacturing by backstepping of PLC-control software” In 2020 IEEE Conference on Industrial Cyberphysical Systems (ICPS) 1, 2020, pp. 242–249 DOI: 10.1109/ICPS48405.2020.9274778
  59. “DoctorGLM: Fine-tuning your Chinese Doctor is not a Herculean Task”, 2023 eprint: arXiv:2304.01097
  60. “Parameter-Efficient Tuning Makes a Good Classification Head”, 2022 eprint: arXiv:2210.16771
  61. “A Comprehensive Capability Analysis of GPT-3 and GPT-3.5 Series Models”, 2023 eprint: arXiv:2303.10420
  62. “CFG2VEC: Hierarchical Graph Neural Network for Cross-Architectural Software Reverse Engineering” In 2023 IEEE/ACM 45th International Conference on Software Engineering: Software Engineering in Practice (ICSE-SEIP), 2023, pp. 281–291 DOI: 10.1109/ICSE-SEIP58684.2023.00031
User Edit Pencil Streamline Icon: https://streamlinehq.com
Authors (6)
  1. Mohamad Fakih (4 papers)
  2. Rahul Dharmaji (2 papers)
  3. Yasamin Moghaddas (2 papers)
  4. Gustavo Quiros Araya (6 papers)
  5. Oluwatosin Ogundare (8 papers)
  6. Mohammad Abdullah Al Faruque (51 papers)
Citations (11)