This is the code repo for our work "Code over Words: Overcoming Semantic Inertia via Code-Grounded Reasoning."
LLMs struggle with Semantic Inertia: the inability to inhibit pre-trained priors (e.g., "Lava is Dangerous") when dynamic, in-context rules contradict them. We probe this phenomenon using Baba Is You, where physical laws are mutable text rules, enabling precise evaluation of models’ ability to override learned priors when rules change.
We quantatively observe that larger models can exhibit inverse scaling. Our analysis attributes this to natural language encoding, which entangles descriptive semantics and logical rules, leading to persistent hallucinations of familiar physics despite explicit contradictory rules.Here we show that representing dynamics as executable code, rather than descriptive text, reverses this trend and enables effective prior inhibition.
Our work provide fine-tunes models on counterfactual pairs and identifies states with contradictory rules, thereby forcing attention to logical constraints rather than visual semantics. This training-time approach outperforms expensive inference-time search methods in both efficiency and accuracy.
You should firstly install baba-is-auto locally based on the instructions in baba-is-auto/README.md. We use vllm to help accelerate our inference. Our model is based on Qwen2.5-7B-Instruct.
Training:
tbd.
Inference:
Download our SFT Lora from . You should also download the original Qwen2.5-7b-Instruct model. By default, you should put these checkpoints in
src/lcv/ft.
Then in your bash, run
cd src/lcv && bash inference.sh
Arvi "Hempuli" Teikari
baba-is-auto
TheoryCoder
If you find our work useful, please cite us at
@article{xu2026code,
title={Code over Words: Overcoming Semantic Inertia via Code-Grounded Reasoning},
author={Xu, Manjie and Isabella Yin and Tu, Xinyi and Zhang, Chi and Zhu, Yixin},
journal={arXiv preprint arXiv:2601.18352},
year={2026}
}










