Skip to content
AlaaLabPublic

About

Official Codebase for "Reducing Hallucinations in Multimodal LLMs with Modality-Aware Sparse Autoencoders"

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Reducing Hallucinations in Multimodal LLMs with Modality-Aware Sparse Autoencoders

Zhongyuan Liang, Thomas Hartvigsen, Irene Y. Chen, Ahmed M. Alaa

[Paper]

Code for training MA-SAE on multimodal LLM activations and for using its cross-modal bank to label preference pairs for DPO, mDPO and on-policy DPO.

Supported backbones: LLaVA-1.5-7B, LLaVA-1.5-13B, InternVL3-8B.

Setup

scripts/setup_env.sh
conda activate masae
source env.sh
scripts/download.sh

Data, checkpoints and activations go under MASAE_DATA_ROOT, MASAE_ARTIFACTS_ROOT and MASAE_WORK_ROOT; export them before sourcing env.sh to override.

Stage 1: MA-SAE

# 1. Extract activations
scripts/extract/llava.sh --workers 4
scripts/extract/llava.sh --model llava-1.5-13b --workers 4
scripts/extract/internvl.sh --workers 4
scripts/extract/clip_cache.sh

# 2. Train (Top-K by default; add --variant moe for the MoE router)
scripts/sae/train.sh --model llava-1.5-7b

# 3. Evaluate
scripts/sae/evaluate.sh --model llava-1.5-7b --run <run name printed by train.sh>

--variant sets how each token's K = 64 active features are split between its own modality bank and the cross-modal bank:

  • topk (default): a fixed split proportional to bank size.
  • moe: a learned per-token router gates the two banks.

Stage 2: Preference optimization

# 1. Score candidates with MA-SAE and build preference pairs
scripts/dpo/build_pairs.sh --model llava-1.5-7b \
    --checkpoint "$SAE_CKPT_DIR/<run>/final.pt" --gpus 0,1,2,3

# 2. Train DPO, then evaluate
scripts/dpo/train.sh --model llava-1.5-7b --gpus 0,1,2,3

# mDPO
scripts/dpo/train.sh --model llava-1.5-7b --mdpo --gpus 0,1,2,3

# On-policy DPO
scripts/dpo/onpolicy.sh --model llava-1.5-7b \
    --checkpoint "$SAE_CKPT_DIR/<run>/final.pt" --gpus 0,1,2,3

Pass --label <name> (default masae) to keep runs from different SAEs apart.

Evaluation

scripts/dpo/train.sh evaluates each trained model on AMBER, Object HalBench and MSCOCO. To evaluate separately:

scripts/dpo/evaluate.sh --model llava-1.5-7b --run masae
scripts/bench/baseline.sh --model llava-1.5-7b   # untuned backbone

Citation

@article{liang2026reducing,
  title={Reducing Hallucinations in Multimodal LLMs with Modality-Aware Sparse Autoencoders},
  author={Liang, Zhongyuan and Hartvigsen, Thomas and Chen, Irene Y and Alaa, Ahmed},
  journal={arXiv preprint arXiv:2611.36866},
  year={2026}
}

About

Official Codebase for "Reducing Hallucinations in Multimodal LLMs with Modality-Aware Sparse Autoencoders"

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages