Skip to content
aimagelabPublic

About

[NeurIPS 2026] BFS-PO: Best-First Search for Large Reasoning Models

Resources

Stars

2 stars

Watchers

1 watching

Forks

Repository files navigation

BFS-PO overview

BFS-PO: Best-First Search for Large Reasoning Models

Fiorenzo Parascandolo1,2, Wenhui Tan3, Enver Sangineto1, Xiaoyi Yu3, Ruihua Song3, Rita Cucchiara1

1 University of Modena and Reggio Emilia, Modena, Italy
2 University of Pisa, Pisa, Italy
3 Gaoling School of Artificial Intelligence, Renmin University of China, Beijing, China

Abstract

Large Reasoning Models (LRMs) have shown excellent performance in reasoning tasks using long Chain of Thought. However, this has also led to a significant increase of computational costs and the generation of verbose output, a phenomenon known as overthinking. The tendency to overthink is often exacerbated by Reinforcement Learning (RL) algorithms such as GRPO/DAPO. In this paper, we propose BFS-PO, an RL algorithm which alleviates this problem using a Best-First Search exploration strategy. Specifically, the reasoning chains generated at training time by BFS-PO are organized into a search tree, within which the shortest correct sequence is selected as the best and expanded using a backtracking mechanism based on maximum entropy nodes. In this way, we bias the exploration of the solution space towards the search for increasingly shorter solutions, training the LRM to generate progressively more concise answers. Using different benchmarks and base LRMs, we show that BFS-PO can simultaneously increase the LRM accuracy and shorten its reasoning chains.

Getting started

Install dependencies

conda create -n bfs-po python=3.10.19 pip -y
conda activate bfs-po
python -m pip install --upgrade pip
python -m pip install -r requirements.txt

Add entropy computation to vLLM

We added entropy computation to vLLM to compute the entropy of the next-token distribution directly during rollout generation. Specifically, sampler.py computes and stores one scalar per sequence and decoding step in LogprobsTensors. These values are then propagated by engine/logprobs.py to the entropy field of the sampled token's Logprob object.

This implementation is based on vllm==0.12.0. After installing this version, run:

python vllm_entropy/add_entropy_to_vllm.py

Download the datasets

The datasets are available on Hugging Face: MetaMathQA-60k, MATH-500, GSM8K, MMLU-STEM, and AMC2023.

python - <<'DATASETS'
from datasets import load_dataset

load_dataset("FiorenzoParascandolo/MetaMathQA-60k", split="train")
load_dataset("math-ai/math500", split="test")
load_dataset("gsm8k", "main", split="test")
load_dataset("TIGER-Lab/MMLU-STEM", split="test")
load_dataset("math-ai/amc23", split="test")
DATASETS

Evaluation

Download the adapter:

hf download FiorenzoParascandolo/Qwen3-1.7B-BFS-PO \
    --local-dir outputs/Qwen3-1.7B-BFS-PO

The script trl/jobs/eval_bfs_po_lora_16_seeds.sh loads the adapter on top of Qwen/Qwen3-1.7B. The base model is downloaded automatically on first use if it is not already cached. Set BASE_MODEL_PATH to an existing local copy of the same base model to reuse it.

Training

The script trl/jobs/train_bfs_po_metamath.sh launches the training of Qwen/Qwen3-1.7B with BFS-PO on MetaMathQA-60k, evaluating on MATH-500 during training.

Citation

@inproceedings{parascandolo2026bfs,
  title={BFS-PO: Best-First Search for Large Reasoning Models},
  author={Parascandolo, Fiorenzo and Tan, Wenhui and Sangineto, Enver and Yu, Xiaoyi and Song, Ruihua and Cucchiara, Rita},
  booktitle={NeurIPS},
  year={2026}
}

Acknowledgements

We thank Hugging Face TRL, vLLM, and PEFT for their open-source libraries.

About

[NeurIPS 2026] BFS-PO: Best-First Search for Large Reasoning Models

Resources

Stars

2 stars

Watchers

1 watching

Forks

Contributors

Languages