🧠 PLC Agentic Assistant (IEC 61131-3)

A compact assistant model specialized for industrial PLC programming.
Fine-tuned with Axolotl using QLoRA to follow instructions and generate logic across the five IEC 61131-3 languages: Structured Text (ST), Ladder Diagram ASCII (LD), Function Block Diagram ASCII (FBD), Instruction List (IL), and GRAFCET / SFC.

✨ Highlights

  • Domain focus: Industrial automation & PLC engineering
  • Skills: Instruction following, code generation, refactoring, SFC design, diagnostics, and troubleshooting
  • Languages: ST Β· LD (ASCII) Β· FBD (ASCII) Β· IL Β· SFC/GRAFCET
  • Deployment: Lightweight adapter suitable for edge/on-prem setups

πŸš€ Quick Start

from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model_id = "ICSFR-HF-ORG-01/Valuoty-industry-plc-4B"

tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    device_map="auto",
    torch_dtype=torch.bfloat16 if torch.cuda.is_available() else "auto",
    trust_remote_code=True,
)

messages = [
    {"role": "system", "content": "You are a senior PLC engineer. Follow IEC 61131-3 best practices."},
    {"role": "user", "content": "Write a PID function block in Structured Text with anti-windup and usage notes."}
]

inputs = tokenizer.apply_chat_template(
    messages, add_generation_prompt=True, return_tensors="pt"
).to(model.device)

with torch.no_grad():
    outputs = model.generate(
        inputs,
        max_new_tokens=512,
        do_sample=True,
        temperature=0.2,
        top_p=0.9,
        repetition_penalty=1.05,
        pad_token_id=tokenizer.eos_token_id,
        eos_token_id=tokenizer.eos_token_id,
    )

print(tokenizer.decode(outputs[0], skip_special_tokens=True))

πŸ—£οΈ Prompting Cheatsheet (per IEC 61131-3)

Structured Text (ST)

System: You are a PLC expert. Use IEC 61131-3 Structured Text with clear comments.
User: Create FB ConveyorInterlock in ST.
Requirements:
- Inputs: StartCmd, StopCmd, EStop, GuardDoorClosed
- Output: ConveyorRun
- Latch start; drop on EStop or open guard door
- Add diagnostics strings and a test example

Ladder Diagram ASCII (LD)

System: Output Ladder Diagram in clean ASCII. Include rung titles and comments.
User: Build a motor start/stop circuit with seal-in, E-Stop, and overload trip.

Function Block Diagram ASCII (FBD)

System: Output Function Block Diagram in ASCII with clear blocks and signal names.
User: Implement a ramp-up speed profile: TON pre-delay, then PID speed control with setpoint tracking.

Instruction List (IL)

System: Use Instruction List. Comment each instruction briefly.
User: Create IL to compute a moving average over N samples with overflow protection.

GRAFCET / SFC

System: Output SFC (GRAFCET) text with steps S0..Sx, transitions T1..Tx, actions, and safety interlocks.
User: Batch filling: Idle β†’ Fill β†’ Hold β†’ Drain; include E-Stop and LevelHi/Lo interlocks.

Datasets

  • Synthetic dataset produce by SPIE ICS.

πŸ“Š Performance

Industry PLC MMLU-style benchmark. Our fine-tuned 4B (reasoning) model reaches 58.2%, surpassing generalist baselines such as Llama 3.1-18B (48.8%)) and Mistral Small-24B (48.9%), and clearly ahead of Qwen2.5-32B (non-reasoning, 42.4%). It also outperforms our Valuoty-3B (non-reasoning, 51.4%), while a larger Llama 3.1-70B remains higher at 61.02%.

πŸ§ͺ Inference Tips

  • Start with temperature=0.2–0.4, top_p=0.9.
  • For deterministic scaffolds set temperature=0.0; relax for brainstorming.
  • Provide PLC family and safety constraints in the system message to tailor outputs.

⚠️ Limitations & Safety

  • Outputs may require adaptation to vendor-specific syntax (Codesys, TwinCAT, Studio 5000, TIA Portal, etc.).
  • Ladder/FBD ASCII is illustrative; import into your IDE and verify.
  • Not a substitute for standards compliance, FMEA, or SIL/PL validation.
  • Always simulate, peer-review, and follow plant safety procedures (IEC 60204-1, ISO 13849).

πŸ“„ License

Valuoty AI Model License Agreement 1.0. Review the licenses agreements before commercial use.

πŸ“š Citation

@software{Valuoty-industry-plc-4B,
  title        = {PLC Agentic Assistant (IEC 61131-3) β€” LoRA on Qwen/Qwen3-4B},
  author       = Laurent MAILLE SPIE ICS,
  year         = {2025},
  publisher    = {Hugging Face},
  note         = {Fine-tuned with Axolotl on PLC instruction-following tasks (ST, LD, FBD, IL, SFC).}
}
Downloads last month
68
Safetensors
Model size
4B params
Tensor type
BF16
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for ICSFR-HF-ORG-01/Valuoty-industry-plc-4B

Finetuned
(138)
this model