A LoRA adapter for Qwen/Qwen3.8-27B that makes it better at Bitcoin Script: writing scripts from an English spending policy, making scripts smaller, recognizing what protocol a script belongs to, and designing Taproot script trees. It was trained with reinforcement learning (GRPO) against automatic graders that check answers with rust-miniscript and Bitcoin Core. There was no supervised fine-tuning stage.
On a 246-task Bitcoin Script test set, the adapter scores 0.401. The base model scores 0.262: +0.139 absolute, 95% CI [+0.086, +0.195].
vllm serve nvidia/Qwen3.8-27B-NVFP4 \
--enable-lora --max-lora-rank 32 \
--lora-modules btc-script=benthecarman/Qwen3.8-27B-BTC-Script-RL
Then request the model btc-script. All scores on this card come from
this setup: the NVFP4 checkpoint plus the adapter, in vLLM 0.27.1. The
bf16 base model with the adapter was not evaluated separately.
from peft import PeftModel
from transformers import AutoModelForImageTextToText, AutoProcessor
base = AutoModelForImageTextToText.from_pretrained(
"Qwen/Qwen3.8-27B", torch_dtype="bfloat16", device_map="auto"
)
model = PeftModel.from_pretrained(base, "benthecarman/Qwen3.8-27B-BTC-Script-RL")
processor = AutoProcessor.from_pretrained("Qwen/Qwen3.8-27B")
To get standalone weights, call model.merge_and_unload().
Evaluation used temperature 1.0, top-p 0.95, top-k 20, thinking on,
and no output-token limit. The model thinks for a long time: the median
answer was about 24k tokens, and some used more than 100k. A low
max_tokens will cut off many answers before they finish.
246 tasks, one attempt each, no output-token limit. The base model and the adapter used the same quantized checkpoint, sampling settings and seed. Each task scores from 0 to 1.
| Task | What the model does | n | Base | LoRA |
|---|---|---|---|---|
| Write | Write a script for an English spending policy | 48 | 0.104 | 0.250 |
| Optimize | Make a working script smaller | 48 | 0.052 | 0.208 |
| Identify | Name the protocol a script belongs to (HTLC, multisig, vault, ...) | 52 | 0.538 | 0.596 |
| Taproot tree | Design a Taproot output (internal key + script tree) | 50 | 0.440 | 0.695 |
| Contract | Write a script from a full spending contract with examples | 48 | 0.146 | 0.229 |
| Overall | 246 | 0.262 | 0.401 |
The adapter also used fewer output tokens across the test set: 7.5M, against 12.3M for the base model.
For scale, larger models on the same test set: GLM 5.3 Flash 0.559, GLM 5.3 0.687, Claude Sonnet 5.5 0.893, Claude Opus 5.5 0.971.
nvidia/Qwen3.8-27B-NVFP4 with the adapter loaded in vLLM. Training
ran in bf16.in_proj_qkv, in_proj_z, out_proj), the
attention projections (q/k/v/o_proj) and the MLP
(gate/up/down_proj). Vision and MTP modules are excluded.The whole run used two local machines, with no rented or cloud GPUs:
The two ran as a pipeline: the 5090 generated the next batch while the Spark trained on the current one, so samples came from an adapter up to two steps old.
The 40 steps took about 6.5 days of wall-clock time (September 30 to October 6, 2026), including restarts. This checkpoint, step 28, was ready after about 3.7 days.
This is the checkpoint after step 28. It scored highest on a separate 80-task validation set:
| Checkpoint | Validation score | Median answer |
|---|---|---|
| base | 0.314 | 17k tokens |
| step 18 | 0.399 | 21k |
| step 28 | 0.491 | 24k |
| step 38 | 0.429 | 43k |
| step 40 | 0.434 | 49k |
After step 28 the score fell while answers doubled in length. Nothing in the reward penalized length.
Qwen/Qwen3.8-27B