🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content
evidencerlPublic

About

Evidence-RL: counterfactual visual evidence reward for VLM RL post-training (NeurIPS 2026)

Resources

Stars

5 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Evidence-RL: Towards Evidence-intensive Visual Reasoning

Official PyTorch implementation of Evidence-RL and Answer-CED (NeurIPS 2026).


πŸ“Œ Overview

Vision-Language Models (VLMs) frequently suffer from visual hallucinations and shortcut reasoning by relying on language priors or scene context rather than inspecting relevant visual evidence.

Evidence-RL introduces Counterfactual Evidence Disentanglement (CED), an outcome-conditioned causal intervention reward integrated with Group Relative Policy Optimization (GRPO). By evaluating counterfactual likelihood margins under localized feature interventions, Evidence-RL encourages the model to ground its predictions in visual evidence rather than language shortcuts.

Model Framework License


πŸš€ Released Models

The post-trained checkpoint based on Qwen3.5-9B is available on Hugging Face:

Model Base Backbone Method Hugging Face Checkpoint
Evidence-RL-9B Qwen3.5-9B Answer-CED + Gated GRPO πŸ€— hhj-ai/Evidence-RL-9B

πŸ› οΈ Environment Setup

1. Clone & Environment

git clone https://github.com/evidencerl/code.git
cd code

# Option A: Conda environment
conda env create -f environment.yml
conda activate evidence_rl

# Option B: Pip installation
pip install -r requirements.txt

2. (Optional) FlashAttention-2

For optimal training throughput:

pip install flash-attn --no-build-isolation

πŸ“¦ Quickstart: Inference Demo

You can run inference using the Hugging Face transformers library directly:

import torch
from transformers import AutoModelForImageTextToText, AutoProcessor
from PIL import Image

model_id = "hhj-ai/Evidence-RL-9B"

processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForImageTextToText.from_pretrained(
    model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto",
    trust_remote_code=True,
)

# Load your image
image = Image.open("example.jpg").convert("RGB")
prompt = "Look at the image carefully and count the objects. Answer with just a number, without any additional text."

messages = [
    {
        "role": "user",
        "content": [
            {"type": "image", "image": image},
            {"type": "text", "text": prompt},
        ],
    }
]

text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(text=[text], images=[image], return_tensors="pt").to(model.device)

with torch.inference_mode():
    outputs = model.generate(**inputs, max_new_tokens=256)

response = processor.batch_decode(outputs[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)[0]
print(response)

Or run the bundled demo script:

python demo.py --image path/to/image.jpg --prompt "How many dogs are in the image?"

πŸ‹οΈ Training Pipeline

1. Data Preparation

The training annotations are provided in data/vg_brutal_pairs.jsonl. Download the corresponding Visual Genome images:

python scripts/download_vg_images.py \
  --names-file data/vg_brutal_image_names.txt \
  --out-dir data/visual_genome

2. Multi-GPU Training (DDP)

Launch 2-GPU (or multi-GPU) distributed training with Gated GRPO:

bash scripts/train_qwen35_9b_ddp.sh \
  --gpus 0,1 \
  --model Qwen/Qwen3.5-9B \
  --output-dir checkpoints/qwen35_9b_answer_ced \
  --steps 2000

3. Single-GPU Training

For single-card setups:

bash scripts/train_qwen35_9b_single.sh \
  --gpu 0 \
  --model Qwen/Qwen3.5-9B \
  --output-dir checkpoints/qwen35_9b_answer_ced_single \
  --steps 2000

4. Merging Checkpoint

After training completes, merge the trained LoRA adapter into a standalone Hugging Face directory:

python scripts/merge_checkpoint.py \
  --base Qwen/Qwen3.5-9B \
  --checkpoint checkpoints/qwen35_9b_answer_ced/checkpoints/step_002000.pt \
  --dest checkpoints/qwen35_9b_answer_ced/merged_hf

πŸ“‚ Repository Structure

evidence-rl/
β”œβ”€β”€ README.md                      # Documentation
β”œβ”€β”€ demo.py                        # Standalone inference demo
β”œβ”€β”€ requirements.txt               # Dependencies
β”œβ”€β”€ environment.yml                # Conda environment
β”œβ”€β”€ data/                          # Training annotations & data list
β”‚   β”œβ”€β”€ vg_brutal_pairs.jsonl      # Visual Genome brutal pairs
β”‚   └── vg_brutal_image_names.txt  # Image filename list
β”œβ”€β”€ src/                           # Core training engine
β”‚   β”œβ”€β”€ train_main_experiment.py   # Training loop & GRPO optimization
β”‚   β”œβ”€β”€ ced_core.py                # Counterfactual Evidence Disentanglement (CED) intervention operator
β”‚   β”œβ”€β”€ mini_grpo_smoke.py         # Rollout sampling & LoRA model setup
β”‚   β”œβ”€β”€ model_loader.py            # VLM architecture loading utilities
β”‚   β”œβ”€β”€ visual_token_map.py        # 2x2 spatial merge & visual token indexing
β”‚   β”œβ”€β”€ answer_format_utils.py     # Two-line format parsing
β”‚   β”œβ”€β”€ anti_hacking.py            # Length & format penalty verifiers
β”‚   └── reward/                    # CED reward components
β”‚       β”œβ”€β”€ action_logprob_ate.py  # Counterfactual margin computation
β”‚       β”œβ”€β”€ preference_gate.py     # Routed gate function g(m)
β”‚       └── causal_margin.py       # Margin statistics & bounds
└── scripts/                       # Training & utility scripts
    β”œβ”€β”€ train_qwen35_9b_ddp.sh     # Multi-GPU training entry
    β”œβ”€β”€ train_qwen35_9b_single.sh  # Single-GPU training entry
    β”œβ”€β”€ merge_checkpoint.py        # LoRA to HF checkpoint merge script
    └── download_vg_images.py      # Visual Genome downloader

πŸ“– Citation

If you find this work or code useful, please cite:

@misc{huang2026evidencerlevidenceintensivevisualreasoning,
      title={Evidence-RL: Towards Evidence-intensive Visual Reasoning}, 
      author={Haojie Huang and Xinlei Yu and Chengming Xu and Zhangquan Chen and Cheng Yang and Qingdong He and Yu Yang and Jiangning Zhang and Xiaobin Hu},
      year={2026},
      eprint={2608.08021},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2608.08021}, 
}

πŸ“„ License

This repository is licensed under the Apache 2.0 License.

About

Evidence-RL: counterfactual visual evidence reward for VLM RL post-training (NeurIPS 2026)

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages