๐ VL-Uncertainty
March 18, 2025 ยท View on GitHub
๐ VL-Uncertainty
Ruiyang Zhang, Hu Zhang, Zhedong Zheng*
๐ฅ News
- 2025.3.16: โจ Welcome to check out our newest work: Uncertainty-o, unveiling uncertainty in Large Multimodal Models (LMMs) in a model-agnostic manner, supporting both Large Comprehension Models and Large Generation Models.
- 2024.12.19: ๐ฃ Source code of VL-Uncertainty is released!
โก Overview

๐ ๏ธ Install
- Create conda environment.
conda create -n VL-Uncertainty python=3.11;
conda activate VL-Uncertainty;
- Install denpendency.
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121;
pip install transformers datasets flash-attn accelerate timm numpy sentencepiece protobuf qwen_vl_utils;
(Tested on NVIDIA H100 PCIe-80G, NVIDIA A100-PCIE-40GB, and A6000-48G)
๐ Quick Start
- Run our demo code.
python demo.py;
- This should produce the results below. VL-Uncertainty can successfully estimate high uncertainty for wrong LVLM answer and thereby detect hallucination!
--------------------------------------------------
- Demo image: .asset/img/titanic.png
- Question: What is the name of this movie?
- GT answer: Titanic.
--------------------------------------------------
- LVLM answer: The movie in the image is "Coco."
- LVLM answer accuracy: Wrong
--------------------------------------------------
- Estimated uncertianty: 2.321928094887362
- Uncertianty threshold: 1.0
--------------------------------------------------
- Hallucination prediction: Is hallucination
- Hallucination detection: Success!
--------------------------------------------------
๐ Run
- For MM-Vet (Free-form benchmark)
bash run/run_MMVet.sh;
- For LLaVABench (Free-form benchmark)
bash run/run_LLaVABench.sh;
- For MMMU (Mutli-choice benchmark)
bash run/run_MMMU.sh;
- For ScienceQA (Mutli-choice benchmark)
bash run/run_ScienceQA.sh;
๐ Examples
- VL-Uncertainty successfully detects LVLM hallucination:

- VL-Uncertainty can also assign low uncertainty for correct answer and identify it as non-hallucinatory:

- VL-Uncertainty effectively generalizes to physical-world scenario. (The following picture is my laptop captured by iPhone)

โจ๏ธ Code Structure
- Code strucuture of this repostory is as follow:
โโโ VL-Uncertainty/
โ โโโ .asset/
โ โ โโโ img/
โ โ โ โโโ logo.png
โ โ โ โโโ titanic.png # For demo
โ โโโ benchmark/
โ โ โโโ LLaVABench.py # Free-form benchmark
โ โ โโโ MMMU.py # Multi-choice benchmark
โ โ โโโ MMVet.py # Free-form benchmark
โ โ โโโ ScienceQA.py # Multi-choice benchmark
โ โโโ llm/
โ โ โโโ Qwen.py # LLM class
โ โโโ lvlm/
โ โ โโโ InternVL.py # Support 26B, 8B, and 1B
โ โ โโโ LLaVA.py # Support 13B, 7B
โ โ โโโ LLaVANeXT.py # Support 13B, 7B
โ โ โโโ Qwen2VL.py # Support 72B, 7B, 2B
โ โโโ run/
โ โ โโโ run_LLaVABench.sh # Benchmark VL-Uncertainty on LLaVABench
โ โ โโโ run_MMMU.sh # Benchmark VL-Uncertainty on MMMU
โ โ โโโ run_MMVet.sh # Benchmark VL-Uncertainty on MMVet
โ โ โโโ run_ScienceQA.sh # Benchmark VL-Uncertainty on ScienceQA
โ โโโ util/
โ โ โโโ misc.py # Helper function
โ โ โโโ textual_perturbation.py # Various textural perturbation
โ โ โโโ visual_perturbation.py # Various visual perturbation
โ โโโ .gitignore
โ โโโ README.md
โ โโโ VL-Uncertainty.py # Include semantic-equvialent perturbation, uncertainty estimation, and hallucination detection
โ โโโ demo.py # Quick start demo
โจ Acknowledgement
- LLaVA, LLaVA-NeXT, InternVL, Qwen2-VL: Thanks a lot for those foundamental efforts!
- semantic_uncertainty: We are inspired a lot by this work!
๐ Citation
If you find our work useful for your research and application, please cite using this BibTeX:
@article{zhang2024vl,
title={VL-Uncertainty: Detecting Hallucination in Large Vision-Language Model via Uncertainty Estimation},
author={Zhang, Ruiyang and Zhang, Hu and Zheng, Zhedong},
journal={arXiv preprint arXiv:2411.11919},
year={2024}
}