Implements the MCTS pipeline that produces the training data for CodeRM-NT.
Both step-data rewriting (step 2) and MCTS (step 5) require a local OpenAI-compatible LLM server. We use Qwen2.5-Coder-32B-Instruct:
python -m vllm.entrypoints.openai.api_server \
--model Qwen/Qwen2.5-Coder-32B-Instruct \
--port 8000 \
--tensor-parallel-size 2Create a config_models.yaml file listing one or more OpenAI-compatible endpoints:
models:
- name: "Qwen/Qwen2.5-Coder-32B-Instruct"
url: "http://localhost:8000/v1"
# Add more entries to fan out across additional servers, e.g.:
# - name: "Qwen/Qwen2.5-Coder-32B-Instruct"
# url: "http://192.168.0.2:8000/v1"Rewrite Python problems from Magicoder-OSS-Instruct-75K into the step-by-step format for MCTS:
python convert_to_step_data_magicoder.py --num_items 12000This produces data_train_rm/python-0-12000.jsonl.
The execution server runs code inside Docker containers:
docker pull python:3.11
python server_execute.py --port 5000 --num_workers 4Run:
python gather_execution_result.pyThis produces data_train_rm/exec_results.jsonl.
# args: max_branches num_rollout model_config
bash run_treesearch_magicoder.sh 4 10 config_models.yamlThis produces search tree JSON files under data_train_rm/tree/treesearch-qwen32b-branch{max_branches}-{num_rollout}/.
# Scalar data for MSE training
python convert_tree_to_scalar_reward_data.py
# Pairwise data for contrastive training
python convert_tree_to_pairwise_reward_data.pyOutput files:
- scalar data:
data_train_rm/reward_data-{train,valid}.jsonl - pairwise data:
data_train_rm/reward_data_contrastive-{train,valid}.jsonl