๐ Uncertainty-o
March 13, 2025 ยท View on GitHub
๐ Uncertainty-o
Ruiyang Zhang, Hu Zhang, Hao Fei, Zhedong Zheng*
โก Overview
๐ฅ News
- 2025.3.11: ๐ฃ Source code of Uncertainty-o is released!
๐ Contents
- โ๏ธ Method
- ๐ ๏ธ Install
- ๐ป Dependency
- ๐ Data Preparation
- ๐ Run
- ๐ Examples
- โจ๏ธ Code Structure
- โจ Acknowledgement
- ๐ Citation
โ๏ธ Method
Pipeline of Our Uncertainty-o. Given a multimodal prompt and large multimodal models, we perform multimodal prompt perturbation to generate diverse responses. Due to the inherent epistemic uncertainty of these models under perturbation, varied responses are typically obtained. To quantify this uncertainty, we apply semantic clustering on the collected responses and compute their entropy. Specifically, responses are grouped into semantically similar clusters, and the entropy across these clusters is calculated as the final uncertainty measure. Higher entropy indicates greater variability in responses, suggesting lower confidence, while lower entropy reflects higher consistency and thus higher confidence.
๐ ๏ธ Install
- Create conda environment.
conda create -n Uncertainty-o python=3.11;
conda activate Uncertainty-o;
- Install dependency.
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, NVIDIA A100)
๐ป Dependency
Refer to Dependency.md.
๐ Data Preparation
Refer to Data.md.
๐ Run
- For Comprehension Hallucination Detection, Hallucination Detection for Closed-Source LMMs, Hallucination Detection for Safety-Critic Tasks
bash run/comprehension_hallucination_detection.sh;
- For Generation Hallucination Detection
bash run/generation_hallucination_detection.sh;
- For Hallucination Mitigation
bash run/hallucination_mitigation.sh;
- For Uncertainty-Aware Chain-of-Thought
bash run/uncertainty_aware_cot.sh;
๐ Examples
- Uncertainty-o successfully detects both comprehension and generation hallucination:
โจ๏ธ Code Structure
- Code strucuture of this repostory is as follow:
โโโ Uncertainty-o/
โ โโโ .asset/
โ โโโ args/ # Args parser
โ โโโ benchmark/
โ โ โโโ comprehension/ # Benchmark for comprehension task
โ โ โโโ generation/ # Benchmark for generation task
โ โโโ dependency/ # Downstream source code for LMMs
โ โโโ factory/ # Builder for benchmarks, models
โ โโโ llm/
โ โ โโโ Qwen.py # LLM class
โ โโโ metric/ # Metric for hallucination detection
โ โโโ mllm/
โ โ โโโ comprehension/ # LMM for comprehension task
โ โ โโโ generation/ # LMM for generation task
โ โโโ perturbation/ # Multimodal prompt perturbation
โ โโโ run/ # Experiment scripts
โ โโโ uncertainty/ # Multimodal semantic uncertainty
โ โโโ util/
โ โโโ .gitignore
โ โโโ hallucination_detection.py
โ โโโ hallucination_mitigation.py
โ โโโ README.md
โ โโโ uncertainty_aware_cot.py
โจ Acknowledgement
- AnyGPT, OneLLM, InternVL, PointLLM: Thanks a lot for those foundamental efforts!
- semantic_uncertainty: We are inspired a lot by this work!
- VL-Uncertainty: We build our codebase based on this work!
๐ Citation
If you find our work useful for your research and application, please cite using this BibTeX:
@article{zhang2025uncertainty,
title={Uncertainty-o: One Model-agnostic Framework for Unveiling Epistemic Uncertainty in Large Multimodal Models},
author={Zhang, Ruiyang and Zhang, Hu and Hao Fei, and Zheng, Zhedong},
year={2025}
}