Sepalith 2B NES
A small, local-first next-edit-suggestion model for R. You give it the code around your cursor and it rewrites the current region, or says that no edit is needed. It was built for Sepalith and runs on a laptop CPU or iGPU through llama.cpp.
This is a hobby project. It is not a chat model and it does not follow instructions outside its prompt format.
Files
| File | Size | Use |
|---|---|---|
sepalith-2b-nes-Q6_K.gguf | 2.20 GB | Default. Passed the quant gate against bf16. |
sepalith-2b-nes-Q4_K_M-mixB.gguf | 1.66 GB | Small tier. See the no-op note below. |
model.safetensors + configs | 5.03 GB | bf16 weights for transformers. |
SHA256:
- Q6_K:
6593785330b99076b80ae3ac679bda76c5fcff1ebd1873f46f944c1ec43a3261 - Q4_K_M-mixB:
e24fbfbc5ea47c88647445ec682196fc67af9134d4fa36e826beeda045f1c71b - model.safetensors:
4a43ece2c6d86e77b929b0d6771fdb2e42e609e4b6665073851d761f1f5ac055
How it was trained
- Base: openbmb/MiniCPM5-2B-Midtrain.
- Continued pretraining on about 472M tokens of permissively licensed R code: scholzmx/sepalith-2b-cpt, step 11,586.
- Editing SFT on R edit examples built from CRAN packages (finish a block, rewrite to a pipe, rename, no-op, and others).
- Two rounds of GRPO with an execution reward: the model's edit is run against the function's tests in R. This release is checkpoint 100 of the second round.
Architecture: LlamaForCausalLM, 42 layers, hidden size 2048, vocabulary
130,560, about 2.5B parameters.
Use it in VS Code or Positron
The Sepalith extension runs a local llama-server and shows suggestions as
ghost text, or as a diff preview for rewrites. It renders the prompt below
byte for byte. It is not on the marketplace yet, so build it from the
repository:
git clone https://github.com/sims1253/Sepalith
cd Sepalith/extensions/vscode-sepalith
npm ci && npm run build
npx @vscode/vsce package --allow-missing-repository
code --install-extension vscode-sepalith-0.1.0.vsix # Positron: Extensions view, Install from VSIX
Then point it at a llama.cpp llama-server binary (absolute path):
{ "sepalith.serverPath": "/path/to/llama.cpp/build/bin/llama-server" }
On first start the extension downloads sepalith-2b-nes-Q6_K.gguf from this
repo and checks its size and SHA256. To use the small tier, download it and
set sepalith.modelPath to its absolute path.
llama.cpp b10453 (3cb7ffb1a) is the tested build. Open an R file and pause
typing, or press Alt+\ to ask for a suggestion. Tab accepts ghost text and
Alt+Enter applies a previewed rewrite.
The extension was tested end to end against the Q6_K file on CPU: on 8
sample contexts its prompt token IDs matched training exactly, and every
answer parsed. Zed is not supported: its built-in zeta2 prompt is a
different format.
Prompt format
Send raw text to a completion endpoint, not a chat endpoint (see Chat template below).
The prompt (renderer zeta2-prm03-v1) looks like this. <|user_cursor|>
marks the cursor inside the current region, and the prompt ends with a
newline after <[fim-middle]>:
Edit the current region. Output the complete replacement region, preserving whitespace. For no change, output the ordinary line [NO_EDIT] followed by the exact terminal line >>>>>>> UPDATED; an empty body is reserved for deletion of a nonempty range.
<filename>R/example.R
f <- function(x) {
<filename>selected_references
<filename>edit_history
<filename>diagnostics
<filename>retrieval
<[fim-suffix]>
value
}
<<<<<<< CURRENT
value <- sum(x)<|user_cursor|>
=======
<[fim-middle]>
The sections are:
- Header: the fixed instruction line, then
<filename>with the file path and the lines above the region. - Context slots:
selected_references,edit_history,diagnosticsandretrieval. They may be empty, but they must be present. Edit history uses the formUser edited "R/f.R":followed by a diff hunk. - Suffix: the lines below the region, after
<[fim-suffix]>. - Region: the lines to edit, between
<<<<<<< CURRENTand=======. An empty region is an insertion point.
The model answers with the full new region followed by >>>>>>> UPDATED,
or [NO_EDIT] and the same terminal line. An empty body means "delete the
region".
Tokenization rules (the markers are plain text, not special tokens):
- Encode the prompt without parsing special tokens and without adding BOS.
- Prepend exactly one BOS (id 0) yourself.
- Decode greedily with a 1,024-token cap, and stop on id 1 or 130073. Only a stop on id 1 counts as a finished answer.
The reference implementation is render_prompt, encode_prompt and
parse_output in
sepalith.campaign_protocol.
llama.cpp
llama-server -m sepalith-2b-nes-Q6_K.gguf -c 8192 --port 8080
# prompt.txt holds the rendered prompt, ending in "<[fim-middle]>\n"
IDS=$(jq -Rs '{content: ., add_special: false, parse_special: false}' prompt.txt \
| curl -s localhost:8080/tokenize -d @- | jq -c '[0] + .tokens')
jq -n --argjson ids "$IDS" \
'{prompt: $ids, n_predict: 1024, temperature: 0, top_k: 1, samplers: ["top_k"]}' \
| curl -s localhost:8080/completion -d @- | jq -r .content
Sending token IDs keeps the input exact. A plain string prompt gives the
same tokens for ordinary code, because the server adds the same single BOS.
But if your source contains special-token text such as <|im_start|>, the
server would then parse it as a control token.
transformers
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("scholzmx/sepalith-2b-nes")
model = AutoModelForCausalLM.from_pretrained("scholzmx/sepalith-2b-nes", dtype=torch.bfloat16)
ids = torch.tensor([[0] + tok.encode(prompt, add_special_tokens=False, split_special_tokens=True)])
out = model.generate(ids, attention_mask=torch.ones_like(ids), max_new_tokens=1024,
do_sample=False, eos_token_id=[1, 130073])
print(tok.decode(out[0, ids.shape[1]:], skip_special_tokens=True))
Chat template
This model has no chat template of its own, and it was not trained on chat.
- GGUF files: they carry the base model's generic chat template in
tokenizer.chat_template(SHA256cc945752db555d60949b16989df4ccfeb52a313d6b4b5c5229dd786e2e9fcf1c), which llama.cpp's conversion step copies over. It adds role markers, an assistant prefix and tool-calling text. The model never saw these during editing SFT or GRPO. So/v1/chat/completions,llama-clichat mode, Ollama or LM Studio's chat view will give poor results. - transformers files: no template is included, so
apply_chat_templatefails on purpose.
Use a raw completion request as shown above.
Evaluation
Held-out panel (240 cases, built from CRAN packages never used in training or model selection, scored once):
| Model | Correct | Rate (95% CI) |
|---|---|---|
| Editing-SFT parent (before GRPO) | 100 / 240 | 41.7% [32.8, 50.6] |
| This model, bf16 | 98 / 240 | 40.8% [32.4, 49.4] |
| This model, Q6_K | 97 / 240 | 40.4% [31.9, 48.9] |
All three got 39 of 50 no-op cases right. The differences are not significant. GRPO did not improve edit accuracy on this panel.
Execution hold-out (3,803 function-completion tasks, 630 functions): all tests pass for 39.9% [38.1, 41.8] of tasks, against 39.2% for the previous checkpoint.
Quantization (250-case dev panel vs. bf16):
| Tier | Correct / 250 | Mean KLD | Note |
|---|---|---|---|
| bf16 | 112 | 0 | |
| Q6_K | 111 | 0.0037 | Passed all gate checks |
| Q4_K_M-mixB | 110 | 0.0236 | False no-ops rose from 10 to 15 (+2.0 pp), above the 1.0 pp gate |
The small tier says "no edit" a little more often when an edit was wanted. It was accepted anyway, because a missed suggestion costs less than a wrong one.
Latency (AMD Ryzen 5 PRO 5650U notebook, 8 threads, prompts of 131 to 4,227 tokens, p50):
| Tier | CPU first token | Vulkan iGPU first token |
|---|---|---|
| Q6_K | 7.1 s | 2.2 s |
| Q4_K_M-mixB | 5.3 s | 2.1 s |
Time to first token is mostly prompt prefill, so short prompts are much faster than these medians.
Limitations
- R only. Other languages were not trained or tested.
- About 41% of edits on the held-out panel are exactly right. Treat the output as a suggestion.
- Long rewrites (whole function bodies) are rarely correct.
- Editor support: VS Code and Positron through the extension above. Zed is not supported.
License
Apache-2.0, like the base model. The training data was restricted to R packages with permissive licenses; provenance is in the scholzmx/sepalith dataset.