Unlike general-purpose coding models, ST-Coder-14B has been trained on high-quality, domain-specific data to understand:
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4# Load the model
5model_id = "RnniaSnow/ST-Coder-14B"
6tokenizer = AutoTokenizer.from_pretrained(model_id)
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 torch_dtype="auto",
10 device_map="auto"
11)
12
13# Prepare the prompt
14system_prompt = "You are an expert industrial automation engineer specializing in IEC 61131-3 Structured Text."
15user_prompt = "Write a Function Block for a 3-axis motion control system with error handling."
16
17messages = [
18 {"role": "system", "content": system_prompt},
19 {"role": "user", "content": user_prompt}
20]
21
22text = tokenizer.apply_chat_template(
23 messages,
24 tokenize=False,
25 add_generation_prompt=True
26)
27
28# Generate
29model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
30generated_ids = model.generate(
31 **model_inputs,
32 max_new_tokens=2048,
33 temperature=0.2, # Low temperature is recommended for code generation
34 top_p=0.9
35)
36
37# Decode output
38output = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
39print(output)
40
1vllm serve RnniaSnow/ST-Coder-14B --tensor-parallel-size 1 --max-model-len 8192
2
This model was trained using
LLaMA-Factory with the following configuration:
This model is licensed under the
MIT License.