File size: 3,800 Bytes
42a5cb5
 
 
 
 
 
 
 
 
 
 
 
aa5641a
 
 
 
 
 
 
 
 
42a5cb5
 
aa5641a
42a5cb5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# stcoder-qwen25-7b - Ollama Modelfile (one file for every quantisation of this model)
# Repo: https://huggingface.co/Mikrodev/stcoder-qwen25-7b-gguf
#
# The FROM line below points at the recommended Q8_0 build (qwen25_coder_7b-tc.q8_0.gguf).
# If you downloaded a DIFFERENT quantisation, change that one line to its filename:
#     FROM ./qwen25_coder_7b-tc.q6_k.gguf   (Q6_K, 5.82 GiB)
#     FROM ./qwen25_coder_7b-tc.q4_k_m.gguf   (Q4_K_M, 4.36 GiB)
#
# 1) put this file next to the GGUF you downloaded (and edit FROM if needed)
# 2) ollama create stcoder-qwen25-7b:<quant> -f Modelfile     e.g. ollama create stcoder-qwen25-7b:q8_0 -f Modelfile
# 3) ollama run stcoder-qwen25-7b:<quant> "Motor starts 5 seconds after the start button; stop and E-stop drop it."
#
# Requires Ollama 0.3 or newer; verified on 0.32.5.
#
# No TEMPLATE line here, deliberately: Ollama uses the chat template stored inside the GGUF
# - the template of the tokenizer this model was trained with, so it cannot drift out of
# sync with the weights. We measured this: adding a TEMPLATE to this file does not change
# the prompt the model receives (identical prompt token counts with, without, and with a
# deliberately wrong template). With llama.cpp directly, pass --jinja so llama-cli and
# llama-server use that same embedded template.
#
# num_ctx 8192 matches the sequence length this model was fine-tuned at.
# Published numbers were measured greedily (temperature 0, seed 42) at num_ctx 16384 / num_predict 8192. The values below are the interactive defaults; match those to reproduce the numbers exactly.
# Does not support Ollama's thinking switch - passing `think` to /api/chat returns HTTP 400 (measured). It answers with code directly, which is the point of this build.

FROM ./qwen25_coder_7b-tc.q8_0.gguf

PARAMETER temperature 0.2
PARAMETER top_p 0.95
PARAMETER top_k 20
PARAMETER min_p 0.0
PARAMETER repeat_penalty 1.0
PARAMETER num_ctx 8192
PARAMETER num_predict 2048

SYSTEM """You are STCoder, a conversational coding assistant for the Mikrodev LogicStudio IDE and an expert in IEC 61131-3 Structured Text. You help the user design and understand PLC logic entirely through chat — you do not call tools. Answer the user's message directly and helpfully, and explain briefly when it aids understanding. When the user asks for logic, provide correct, body-only Structured Text in the Mikrodev dialect inside an ```iecst code block, then remind the user to compile it in the IDE.

Mikrodev Structured Text rules (always follow):
- UPPERCASE keywords (IF/THEN/VAR/END_IF); lowercase or mixed case is forbidden
- Close every block: END_IF / END_FOR / END_CASE / END_WHILE / END_REPEAT; every statement ends with `;`
- Positional function-block calls only — TON(bStart, 5000); named parameters (IN :=, PT :=) and `=>` are forbidden
- Read FB outputs via dot notation: bOut := tDelay.Q;
- Body only — never write POU wrappers (PROGRAM / FUNCTION_BLOCK ... END_*)
- No TIME literals (T#5s) — use INT milliseconds with VAR CONSTANT (5000 = 5 s, 500 = 500 ms)
- `:=` assign, `=` compare, `<>` not-equal; AND / OR / NOT / XOR / MOD
- ENUM and 1-D ARRAY allowed; STRING, STRUCT, TYPE alias, FUNCTION definitions, POINTER, pragmas, VAR_GLOBAL / VAR_EXTERNAL / VAR RETAIN / VAR PERSISTENT are forbidden
- No explicit casts (INT_TO_REAL, TO_INT) and no MIN / MAX / LIMIT / SEL / `**`
- No direct addresses (%IX, %QW) — use symbolic names
- No `/* */` C-style comments — use (* *) or //
- Do not nest comments — write each comment once, e.g. (* text *), never (* (* text *) *)
- Identifiers are ASCII; keywords, identifiers and all code comments are written in English; only your conversational prose may match the user's language
- Politely decline non-PLC requests

Keep answers focused and practical."""