ChemReason-Bench is a chemistry reasoning benchmark and training/inference toolkit for multi-task evaluation on experimental procedure understanding.
This upload package includes:
- benchmark test prompts and answers
- SFT and RL training data
- training code for SFT and GRPO
- local and API-based prediction scripts
- evaluation code and metric configuration
ChemReason_Bench_Upload/
├── .gitignore
├── DATA_LICENSE
├── LICENSE
├── README.md
├── requirements.txt
├── benchmark_data/
│ ├── answers.jsonl
│ └── prompts.jsonl
├── chemreason/
│ ├── __init__.py
│ ├── config.py
│ ├── data_rl.py
│ ├── data_sft.py
│ ├── grpo_unified.py
│ ├── main.py
│ ├── modeling.py
│ ├── rewards.py
│ ├── sft_unified.py
│ ├── trainer_grpo.py
│ └── trainer_sft.py
├── config/
│ ├── ds_zero3_bf16.json
│ └── train_chemreason.yaml
├── eval/
│ ├── eval.py
│ └── eval_config.yaml
├── predict/
│ ├── predict.py
│ ├── predict_claude_api.py
│ ├── predict_ds_api.py
│ ├── predict_grpo.py
│ └── predict_qwen_api.py
├── train_data/
│ ├── rl_dev.jsonl
│ ├── rl_train.jsonl
│ ├── sft_dev.jsonl
│ └── sft_train.jsonl
The benchmark contains six task types:
orderingstep_validationcondition_validationstep_completioncontrastive_choicerationalization
Benchmark test inputs are stored in benchmark_data/prompts.jsonl, and reference answers are stored in benchmark_data/answers.jsonl.
Training data is stored in train_data/.
Use Python 3.10+.
pip install -r requirements.txtIf you plan to train with GPUs, install a torch build that matches your CUDA environment.
The main training entry point is chemreason/main.py.
Example commands from the repository root:
python -m chemreason.main --config config/train_chemreason.yaml --mode sft
python -m chemreason.main --config config/train_chemreason.yaml --mode grpo
python -m chemreason.main --config config/train_chemreason.yaml --mode sft_grpoThe default training config is config/train_chemreason.yaml.
Important notes:
model.base_model_nameandmodel.tokenizer_nameshould point to a valid Hugging Face model name or local path.- Training data paths in the config are relative to the repository root.
resume_from_checkpointisnullby default and should be set explicitly only when resuming.
Useful CLI overrides:
python -m chemreason.main \
--config config/train_chemreason.yaml \
--mode sft \
--output-dir outputs/chemreason_demo \
--set model.base_model_name=Qwen/Qwen2.5-7B-Instruct \
--set model.tokenizer_name=Qwen/Qwen2.5-7B-InstructUse predict/predict.py:
python predict/predict.py \
--prompts benchmark_data/prompts.jsonl \
--out outputs/predictions.jsonl \
--base_model Qwen/Qwen2.5-7B-Instruct \
--adapter /path/to/sft_adapter \
--device cuda \
--dtype bf16 \
--prompt_style json \
--probs_mode lm \
--binary_mode lmKey options:
--prompt_style {json,sft}selects JSON-only prompting or SFT-style prompting.--probs_mode lmis recommended forcontrastive_choiceif you want comparable log-loss style probabilities.--binary_mode lmis recommended for binary tasks if you want score-based metrics such as Brier, ECE, AUROC, and AUPRC.
Use predict/predict_grpo.py:
python predict/predict_grpo.py \
--prompts benchmark_data/prompts.jsonl \
--out outputs/predictions_grpo.jsonl \
--base_model Qwen/Qwen2.5-7B-Instruct \
--adapter_sft /path/to/sft_adapter \
--adapter_grpo /path/to/grpo_adapter \
--device cuda \
--dtype bf16 \
--probs_mode lm \
--binary_mode lmThe repository also includes API-based inference scripts:
predict/predict_qwen_api.pypredict/predict_ds_api.pypredict/predict_claude_api.py
These scripts expect an API key either through CLI flags or environment variables such as:
DASHSCOPE_API_KEYQWEN_API_KEYDEEPSEEK_API_KEYOPENAI_API_KEYANTHROPIC_API_KEY
Example:
python predict/predict_claude_api.py \
--prompts benchmark_data/prompts.jsonl \
--out outputs/predictions_claude.jsonl \
--base_model claude-sonnet-4-20250514 \
--prompt_style jsonUse eval/eval.py with eval/eval_config.yaml:
python eval/eval.py \
--pred outputs/predictions.jsonl \
--gt benchmark_data/answers.jsonl \
--config eval/eval_config.yaml \
--out outputs/report.jsonThe evaluation report includes:
- per-task metrics
- macro-style overall metrics
- segmented results for benchmark IDs
1-400,401-500, and overall
Note on unit normalization:
eval.pycontains a built-in default unit normalization map.- The CLI supports
--ucum /path/to/ucum_map.yamlif you want to override it. - The current evaluator does not automatically read
tasks.step_completion.unit_system.ucum_mapfromeval_config.yaml; only--ucumaffects the external map path.
All benchmark and training files use JSONL.
Typical fields include:
task_idtask_typecontextquestionlegend- task-specific fields such as
steps_to_order,options,ground_truth, andprediction
Prediction files should contain one JSON object per line with:
task_idtask_typeprediction
- Run commands from the repository root so relative paths resolve correctly.
- Check model availability and tokenizer compatibility before training or inference.
bert-scoreis required for the full rationalization evaluation path.- GPU memory requirements depend strongly on the base model, sequence length, and batch size.
The source code, documentation, and configuration files in this repository are licensed under the Apache License 2.0. See LICENSE.
The benchmark and training data under benchmark_data/ and train_data/ are licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0). See DATA_LICENSE.