SwiReasoning is a training-free method for Pareto-superior reasoning LLMs that dynamically switches between explicit and latent thinking, with a switch count control mechanism to suppress overthinking.
demo.mp4
Comparison of solving the same question with the same reasoning LLM (6s vs. 1min).
git clone https://github.com/sdc17/SwiReasoning.git
cd SwiReasoningconda create -n swir python=3.12
conda activate swir
pip install -r requirements.txtpython run_chat.py --model_name Qwen/Qwen3-8B --method swir --max_switch_count 2- Modify
--model_nameto try different reasoning LLMs. - Increase
--max_switch_countto allow more thinking rounds (default: 2).
Commands:
exit or q -> [Exit]
switch <N|none> -> [Set] swir max_switch_count = N (integer >= 1) or None (disabled)
method <swir|cot|cot_greedy> -> [Set] generation method- Please check run_chat.sh for more examples.
# Evaluate without switch count control
torchrun --nproc_per_node 1 --nnodes 1 --node_rank 0 --master_port $((RANDOM + 20000)) run.py --model_name Qwen/Qwen3-1.7B \
--dataset_name gsm8k --batch_size 512 --max_new_tokens 32768 --method swir --alpha 0.6
python merge.py --model_name Qwen/Qwen3-1.7B --dataset_name gsm8k --max_new_tokens 32768 --method swir
# Evaluate with switch count control
torchrun --nproc_per_node 1 --nnodes 1 --node_rank 0 --master_port $((RANDOM + 20000)) run.py --model_name Qwen/Qwen3-8B \
--dataset_name gsm8k --batch_size 256 --max_new_tokens 32768 --method swir --alpha 0.5 --max_switch_count 2
python merge.py --model_name Qwen/Qwen3-8B --dataset_name gsm8k --max_new_tokens 32768 --method swir
- Increase
--nproc_per_nodeto enable faster evaluation on multiple GPUs. - Modify
--model_nameand--dataset_namefor evaluation with different models and datasets. - Please check run.sh for more examples.
We thank the contributors of open-source projects Transformers, Qwen3, and Soft-Thinking.
@misc{shi2025swireasoningswitchthinkinglatentexplicit,
title={SwiReasoning: Switch-Thinking in Latent and Explicit for Pareto-Superior Reasoning LLMs},
author={Dachuan Shi and Abedelkadir Asi and Keying Li and Xiangchi Yuan and Leyan Pan and Wenke Lee and Wen Xiao},
year={2025},
eprint={2510.05069},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2510.05069},
}