Instructions to use benthecarman/Qwen3.8-27B-BTC-Script-RL with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use benthecarman/Qwen3.8-27B-BTC-Script-RL with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.8-27B") model = PeftModel.from_pretrained(base_model, "benthecarman/Qwen3.8-27B-BTC-Script-RL") - Notebooks
- Google Colab
- Kaggle
Qwen3.8-27B Bitcoin Script LoRA
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].
Usage
vLLM
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.
Transformers + PEFT
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().
Sampling
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.
Results
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.
Training
- Base: Qwen3.8-27B. Training samples were generated by
nvidia/Qwen3.8-27B-NVFP4with the adapter loaded in vLLM. Training ran in bf16. - LoRA rank 32, alpha 32, fp32 adapter weights. Targets: the Gated
DeltaNet projections (
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. - GRPO: 8 prompts Γ 8 samples per step, learning rate 1e-4, 40 steps. Advantages are centred on the group mean, without std normalization, and groups where every sample scored the same are dropped. Truncated importance-sampling REINFORCE (cap 2), no KL term.
- The training tasks were generated separately from the test tasks.
- Steps 1β24 limited samples to 32,768 tokens; steps 25β40 had no limit.
Hardware
The whole run used two local machines, with no rented or cloud GPUs:
- Sampling: one NVIDIA RTX 5090 (32 GB, power-capped at 400 W) served the NVFP4 base model with the current adapter in vLLM, and generated all training samples.
- Training: one NVIDIA DGX Spark (GB10, 128 GB unified memory) held the bf16 base model and trained the adapter. Its GPU clock was locked at 1,700 MHz to keep it below thermal throttling.
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.
Limitations
- Each model had one attempt per test task. The overall gain is clear; the Identify and Contract gains are within noise.
- Most of the training (steps 1β24) used a 32k-token sample limit.
- The adapter was trained on one prompt format for these tasks. It is not tested on general chat or on other kinds of Bitcoin questions.
- Bitcoin Script mistakes can lose funds. Check any script from this model with real tooling (rust-miniscript, Bitcoin Core) before you use it on mainnet.
- Downloads last month
- 24
Model tree for benthecarman/Qwen3.8-27B-BTC-Script-RL
Base model
Qwen/Qwen3.8-27B