SpireMind Defect 2B (SFT)
Qwen3.5-2B fine-tuned to make the out-of-combat decisions for the Defect in Slay the Spire 2 (game version v0.113.1, public-beta branch; Ascension 10; no save-load). It covers card rewards, the shop, events, rest sites, map paths, card selection (upgrade / remove / transform / enchant), combat rewards, treasure chests and starting bundles. It does not play cards in combat: combat is handled by AlphaDefect's RL network student e.
The model was distilled from the out-of-combat policy of AlphaDefect, a PPO agent, using soft labels over lettered options. Code, data pipeline and evaluation: github.com/yutengzhang03/SpireMind.
简介:这是《杀戮尖塔 2》v0.113.1 故障机器人的局外决策模型(选卡、商店、事件、休息处、路线、选牌等),由 Qwen3.5-2B 蒸馏 AlphaDefect 的 RL 老师得到。战斗里出牌不是它做的,而是由 AlphaDefect 的 student e 负责。目前没有公开的办法让它在游戏窗口里实时操作(见下文“在真实游戏里用”);能用的是无头引擎上的整局模拟。
Results
All numbers are for Defect, A10, game v0.113.1. Evaluation seeds were never used for training.
Offline agreement with the RL teacher. V1 is 2,198 decisions from held-out games, about 300 per decision type. Scores use vLLM, constrained to the legal letters.
| Model | Agrees with teacher's top choice | KL(teacher ‖ model) | Contested decisions (teacher top < 0.9, n = 1,132) |
|---|---|---|---|
| Uniform random | 33.0% | — | 26.8% |
| Qwen3.5-2B zero-shot | 40.7% | 1.06 | 31.9% |
| SFT pilot (2% of the data) | 75.4% | 0.29 | 60.9% |
| This model | 92.0% | 0.041 | 84.5% |
By decision type: map 96.3%, event 95.0%, rest site 95.0%, card reward 94.0%, combat rewards 90.7%, card selection 90.3%, shop 80.0%, treasure 100%.
Full games. First 1,000 seeds of AlphaDefect's RV1 evaluation pool. This model makes the out-of-combat decisions and student e plays every combat greedily.
| Out-of-combat decisions by | Wins / 1,000 | Mean floor reached |
|---|---|---|
| Uniform random | 0 | 12.1 |
| Qwen3.5-2B zero-shot | 0 | 18.8 |
| This model | 722 | 46.8 |
| AlphaDefect's own policy (the teacher) | 756 | 47.3 |
Paired against the teacher on the same seeds, 104 seeds were won only by this model and 138 only by the teacher (exact McNemar p = 0.034). The model therefore recovers about 95% of the teacher's wins.
Training
| Base | Qwen/Qwen3.5-2B, full fine-tune, text only. The vision tower is unchanged and kept so the checkpoint loads like the base. |
| Data | 1,028,146 decisions from 10,000 games played by the teacher on the project's own seeds. Each decision is the rendered game state, lettered options, and the teacher's probabilities summed per letter. |
| Loss | KL(teacher ‖ model) over the legal letters, plus 0.1 × cross-entropy on the teacher's top letter. Computed only at the answer position. |
| Schedule | 1 epoch, 4,017 steps × 256 decisions, lr 1e-5 (cosine, 3% warm-up), bf16 |
| Hardware | 8 × NVIDIA L40S, FSDP2 |
Prompt format
Each decision is one user message wrapped in the Qwen chat template, with thinking turned off. The answer is one letter.
The message must be produced by the SpireMind renderer: spiremind/render/render.py, format r3, or r4, which fixes a few unfilled numbers in card text and is recommended. Agreement under r4 is the same (91.9%). The renderer only uses what a player can see on screen and fills card, relic and event text from your own copy of the game. The message looks like this:
You are the out-of-combat decision maker for the Defect in Slay the Spire 2 (Ascension 10, no save-scumming). Combat is played by a separate controller; … Read the state and reply with the letter of exactly one option.
<state: act, floor, HP, gold, potions, relics, deck with card text, map, …>
<decision type and context>
A. <option>
B. <option>
…
Answer with the letter of the single best option.
Constrain decoding to the legal letters and take the most probable one. With vLLM:
from vllm import LLM, SamplingParams
from transformers import AutoTokenizer
repo = "yutengz/SpireMind-Defect-2B-SFT"
tok = AutoTokenizer.from_pretrained(repo)
llm = LLM(repo, max_model_len=16384, enable_prefix_caching=True, limit_mm_per_prompt={"image": 0, "video": 0},
max_logprobs=64, logprobs_mode="processed_logprobs")
text = "..." # one rendered decision (spiremind.render.render.render(obs, GameData()).text)
letters = "ABCD" # the legal letters of this decision
prompt = tok.apply_chat_template([{"role": "user", "content": text}], tokenize=False,
add_generation_prompt=True, enable_thinking=False)
ids = [tok.encode(L, add_special_tokens=False)[0] for L in letters]
out = llm.generate([prompt], SamplingParams(max_tokens=1, temperature=0.0, logprobs=len(ids), allowed_token_ids=ids))
print(out[0].outputs[0].text) # e.g. "B"
Without the renderer the model has no reason to work: it has only seen this exact format.
How to run it
What you need
- Your own copy of Slay the Spire 2 on Steam, at v0.113.1 from the
public-betabranch. Neither this repository nor SpireMind contains game files. The public branch is currently v0.111.1 and the beta has moved on to v0.114.0, so v0.113.1 has to be downloaded by manifest, e.g. with DepotDownloader (app 2868840, depot 2868841, manifest 8445808044584180628,-branch public-beta). This is whatscripts/babel/fetch_game.shin SpireMind does with your own Steam login. - Linux or WSL, the .NET 9 SDK in
~/.dotnet, Python 3.12, a GPU for vLLM (12 GB or more is comfortable for the 2B model with 16k context), and several CPU cores for the game engine.
Full games on the headless engine (supported)
The game logic runs headless through AlphaDefect's engine (Sts2Headless, built against your game files). The model makes the out-of-combat decisions and student e plays the fights. This is how the results above were produced. The commands below follow the repository's scripts, which were run on a Linux cluster; adjust the paths for your machine.
git clone --recurse-submodules https://github.com/yutengzhang03/SpireMind && cd SpireMind
AD=third_party/AlphaDefect-Public; V=v0.113.1
export STS2_GAME_VERSION=$V STS2_GAME_DIR=$HOME/.local/share/sls2/game/$V SPIREMIND_STORE=$HOME/spiremind-store
# 1. game files and localization: AlphaDefect README, "Quick start", step 1 (copy from your install, or use fetch_game.sh)
# 2. engine: apply SpireMind's patch (adds event option text to the engine's labels), then build and self-check
git -C $AD apply ../../patches/alphadefect/0001-event-option-text-labels.patch
(cd $AD/engine/Sts2Headless && dotnet build -c Release -p:Sts2GameVersion=$V -p:Sts2GameDir=$STS2_GAME_DIR \
&& dotnet bin/Release/net9.0/Sts2Headless.dll selfcheck)
# 3. tables the renderer fills card and relic text from (exported from your game files)
mkdir -p $SPIREMIND_STORE/gamedata/$V
(cd $AD/engine/Sts2Headless && dotnet bin/Release/net9.0/Sts2Headless.dll sim-tables $SPIREMIND_STORE/gamedata/$V/sim_tables.json)
# 4. the combat network: AlphaDefect release weights-v1 (student_e_v165018.pt; check it against the release's SHA256SUMS)
gh release download weights-v1 -R hmty-CHEN/AlphaDefect-Public -D weights
# 5. Python: torch, numpy, vllm, transformers in one environment
python3.12 -m venv .venv && .venv/bin/pip install numpy torch vllm transformers
# 6. serve this model and play 10 games on the RV1 seeds
.venv/bin/vllm serve yutengz/SpireMind-Defect-2B-SFT --port 8000 --max-model-len 16384 --enable-prefix-caching \
--limit-mm-per-prompt '{"image": 0, "video": 0}' &
.venv/bin/python -m spiremind.eval.hybrid --macro llm --model yutengz/SpireMind-Defect-2B-SFT --server http://127.0.0.1:8000 \
--seeds-file $AD/seeds/RV1.json --runs 10 --ckpt weights/student_e_v165018.pt --out out/demo
Each game becomes one line in out/demo/runs_s0.jsonl. A line has the win, the floor reached, every action, and how often the model agreed with the teacher. --macro teacher and --macro random run the reference policies on the same seeds. spiremind.eval.paired compares two output folders seed by seed.
In the real game (not supported yet)
There is currently no public way to have this model play inside the game window. AlphaDefect played the released game on a livestream through a bridge mod: the mod read the game state, sent it to the networks, and applied their actions. That mod and its driver are not released (see AlphaDefect's NOTICE.md).
To run this model live, a mod would have to do four things:
- read the same information the headless engine encodes;
- turn it into the renderer's text;
- ask this model at out-of-combat decisions and a combat policy in fights;
- click the chosen option.
Neither project provides that.
Limitations
- Narrow scope: only the Defect, only game v0.113.1, only Ascension 10. It was not evaluated on v0.114.0 (whose Defect-relevant changes are small) or on other characters.
- Imitation, not planning: the model copies the RL teacher's choices. It does not reason in text, and it is slightly weaker than the teacher in full games. Shop decisions are its weakest category (80% agreement).
- Fixed input format: it only works with the SpireMind renderer's prompt format, and it does not play combat.
- No affiliation: Slay the Spire 2 is a game by Mega Crit. This project is not affiliated with or endorsed by Mega Crit, and no game files or game text are distributed here.
License and credits
- License: weights under Apache-2.0, following the base model Qwen/Qwen3.5-2B.
- Credits: the teacher policy, the headless engine and the combat network come from AlphaDefect (MIT). SpireMind extends that project with a small language model.