Views
No views yet
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.
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4# Replace with your merged-weights repo on Hugging Face
5model_id = "ICSFR-HF-ORG-01/Valuoty-industry-plc-3B"
6
7tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
8model = AutoModelForCausalLM.from_pretrained(
9 model_id,
10 device_map="auto",
11 torch_dtype=torch.bfloat16 if torch.cuda.is_available() else "auto",
12 trust_remote_code=True,
13)
14
15messages = [
16 {"role": "system", "content": "You are a senior PLC engineer. Follow IEC 61131-3 best practices."},
17 {"role": "user", "content": "Write a PID function block in Structured Text with anti-windup and usage notes."}
18]
19
20inputs = tokenizer.apply_chat_template(
21 messages, add_generation_prompt=True, return_tensors="pt"
22).to(model.device)
23
24with torch.no_grad():
25 outputs = model.generate(
26 inputs,
27 max_new_tokens=512,
28 do_sample=True,
29 temperature=0.2,
30 top_p=0.9,
31 repetition_penalty=1.05,
32 pad_token_id=tokenizer.eos_token_id,
33 eos_token_id=tokenizer.eos_token_id,
34 )
35
36print(tokenizer.decode(outputs[0], skip_special_tokens=True))
37System: 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 exampleSystem: 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.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.System: Use Instruction List. Comment each instruction briefly.
User: Create IL to compute a moving average over N samples with overflow protection.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.Qwen/Qwen2.5-3Blora (r=24, alpha=32, dropout=0.05)['q_proj', 'k_proj', 'v_proj', 'o_proj', 'gate_proj', 'up_proj', 'down_proj']['lm_head']1024bfloat16adamw_torch, LR 3e-5, weight decay 0.01, max grad norm 1.0cosine, warmup 0.084, grad-accum 8, epochs 3True, Flash-Attention Truesteps, eval steps 100, logging 75, load best at end True
temperature=0.2–0.4, top_p=0.9.temperature=0.0; relax for brainstorming.1@software{Valuoty-industry-plc-3B,
2 title = {PLC Agentic Assistant (IEC 61131-3) — LoRA on Qwen/Qwen2.5-3B},
3 author = Laurent MAILLE SPIE ICS,
4 year = {2025},
5 publisher = {Hugging Face},
6 note = {Fine-tuned with Axolotl on PLC instruction-following tasks (ST, LD, FBD, IL, SFC).}
7}