File size: 3,311 Bytes
b94988d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
---
base_model: unsloth/Qwen2.5-Coder-3B-Instruct-bnb-4bit
library_name: peft
license: other
license_name: qwen-research
license_link: https://huggingface.co/Qwen/Qwen2.5-Coder-3B-Instruct/blob/main/LICENSE
language:
  - en
tags:
  - lora
  - qlora
  - computercraft
  - cc-tweaked
  - minecraft
  - lua
  - code
  - unsloth
pipeline_tag: text-generation
---

# cc-coder — a CC: Tweaked (ComputerCraft) Lua coding model

A QLoRA adapter for **Qwen2.5-Coder-3B-Instruct** specialized in writing
[CC: Tweaked](https://tweaked.cc) Lua programs for Minecraft — turtles,
peripherals, rednet, monitors, and the wider CC library ecosystem — while
retaining general programming ability.

Trained entirely on a single RTX 5060 (8GB) using
[Unsloth](https://github.com/unslothai/unsloth), and iterated against an
**executable benchmark**: every evaluation generation is run inside a real
[CraftOS-PC](https://www.craftos-pc.cc/) emulator with syntax + runtime
checking, and every hand-written training example was validated the same
way before it was allowed into the dataset.

## Evaluation (executable, in-emulator)

70 held-out prompts; a pass = the generated program parses **and** runs
cleanly in CraftOS-PC (with stub turtle API and installed community libs):

| Metric | Training-loop start (iter 1) | This model (iter 9) |
|---|---|---|
| Everyday CC tasks (50 prompts, clean-run %) | 44% | **74%** |
| Full set incl. library tasks (70 prompts) | — | **60%** |
| Syntax-valid generations | 94% | **97%** |

(3 of the 20 library prompts are unwinnable in the harness — broken
vendored dependency, internet-requiring font, nonexistent module — so the
effective library ceiling is 17/20.)

## Training data

- The CC: Tweaked ROM, official docs, and ~130 community repositories
  (Basalt, Pine3D, PixelUI, Opus OS, artist, ccryptolib, metis, and many
  more), each file validated in the emulator before inclusion; licenses of
  source repos include MPL-2.0, MIT, and LicenseRef-CCPL
- 112 hand-written, emulator-validated canonical examples targeting
  observed failure modes (nil-guards, yield-correct event loops, exact API
  signatures, library `require` idioms)
- ~5,000 general programming samples (Magicoder-OSS-Instruct) to retain
  non-Lua skills

## Usage

With PEFT / transformers (the adapter also loads onto the full-precision
`Qwen/Qwen2.5-Coder-3B-Instruct` base):

```python
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer

base = AutoModelForCausalLM.from_pretrained("unsloth/Qwen2.5-Coder-3B-Instruct-bnb-4bit")
model = PeftModel.from_pretrained(base, "minecartchris/cc-coder")
tokenizer = AutoTokenizer.from_pretrained("minecartchris/cc-coder")
```

Prompt in plain chat format, e.g. *"Write a CC: Tweaked turtle program
that digs a 1x2 tunnel 16 blocks long and returns home."*

A GGUF build (q4_k_m, runs in Ollama / LM Studio on ~2GB) is planned as a
companion repo.

## Limitations

- 3B parameters: logic on complex multi-step tasks can be wrong even when
  the code runs; always review before letting a turtle loose on your base
- Library coverage (Basalt, Pine3D, etc.) is functional but weaker than
  vanilla-API coverage
- Inherits the Qwen Research license from its base model (non-commercial
  restrictions apply — see license link)