This is the official implementation of Measuring and Mitigating Post-hoc Rationalization in Reverse Chain-of-Thought Generation, ICML 2026.
UV_CACHE_DIR=.uv-cache uv venv venv --python 3.11
UV_CACHE_DIR=.uv-cache uv pip install --python venv/bin/python -e ".[generation]" \
--extra-index-url https://download.pytorch.org/whl/cu124 \
--index-strategy unsafe-best-matchPlace a local model checkpoint before running generation or metric scoring. The pipeline was tested with Qwen3-8B. For a quick code-path check, use the generated example file:
scripts/examples/examples.jsonlThis file already contains regenerated NEU/SUP/AUG-SUP/SSR RCoT traces, so you
can skip the generation step in the pipeline and start directly from anchoring
metric scoring. You can also pass any metric-format JSONL through --input.
For larger-scale experiments, download the open-sourced public 16k subset, SSR-RCoT-16K, from Hugging Face:
venv/bin/python - <<'PY'
from datasets import load_dataset
ds = load_dataset("Nanbeige/SSR-RCoT-16K")
print(ds)
PYIf you export the dataset to JSONL, convert SSR-format rows to the anchoring metric input format with:
venv/bin/python scripts/prepare_anchoring_input.py convert-ssr-rcot \
--input path/to/ssr_rcot_16k.jsonl \
--output runs/ssr_rcot_16k/inputs/ssr.metric.jsonl \
--method SSRThe code is organized under scripts/. Core anchoring metrics are in
scripts/anchoring_measure/, and RCoT prompt templates are in
scripts/rcot_generation/.
- Optional: generate RCoT traces.
You can skip this step when using scripts/examples/examples.jsonl, because it
already contains generated RCoT traces for all four methods. Run this step only
when you want to regenerate RCoT traces from another input file.
venv/bin/python scripts/generate_vllm.py \
--mode rcot \
--input path/to/input.metric.jsonl \
--output runs/rcot_example/inputs/generated.metric.jsonl \
--raw-output runs/rcot_example/generation/raw_outputs.jsonl \
--model /path/to/Qwen3-8B \
--methods NEU,SUP,AUG-SUP,SSR \
--tensor-parallel-size 4- Run anchoring metric scoring, tables, and plots.
venv/bin/python scripts/run_anchoring_pipeline.py \
--input scripts/examples/examples.jsonl \
--run-dir runs/rcot_example \
--model /path/to/Qwen3-8B \
--python venv/bin/python \
--torchrun-nproc 4 \
--force- Build a report.
venv/bin/python scripts/report_anchoring_results.py \
--run-dir runs/rcot_exampleThe pipeline writes tables, plots, and reports under the selected --run-dir.
Typical outputs include:
figures/methods/methods_table1_metrics.mdfigures/methods/methods_table2_zones.mdfigures/methods/methods.pdffigures/controlled/controlled_table1_metrics.mdfigures/controlled/controlled_table2_zones.mdfigures/controlled/controlled.pdfreport.md
The metric table summarizes Alex, Aent, and Aprob. The zone table
summarizes Reason, Encode, Cloze, and Copy.
@inproceedings{peng2026rcganchoring,
title={Measuring and Mitigating Post-Hoc Rationalization in Reverse Chain-of-Thought Generation},
author={Guangyue Peng and Zongchao Chen and Wen Luo and Yuntao Wen and Wei Li and Ruixiang Feng and Ran Le and Chen Yang and Zhenwei An and Yang Song and Tao Zhang and Houfeng Wang},
booktitle={Forty-third International Conference on Machine Learning},
year={2026},
url={https://openreview.net/forum?id=cY0pi9WHvL}
}