Giter VIP home page Giter VIP logo

woodpecker's Introduction

Woodpecker: Hallucination Correction for Multimodal Large Language Models


Hallucination is a big shadow hanging over the rapidly evolving Multimodal Large Language Models (MLLMs), referring to the phenomenon that the generated text is inconsistent with the image content. In order to mitigate hallucinations, existing studies mainly resort to an instruction-tuning manner that requires retraining the models with specific data. In this paper, we pave a different way, introducing a training-free method named Woodpecker. Like a woodpecker heals trees, it picks out and corrects hallucinations from the generated text. Concretely, Woodpecker consists of five stages: key concept extraction, question formulation, visual knowledge validation, visual claim generation, and hallucination correction. Implemented in a post-remedy manner, Woodpecker can easily serve different MLLMs, while being interpretable by accessing intermediate outputs of the five stages. We evaluate Woodpecker both quantitatively and qualitatively and show the huge potential of this new paradigm. On the POPE benchmark, our method obtains a 30.66%/24.33% improvement in accuracy over the baseline MiniGPT-4/mPLUG-Owl.

This is the first work to correct hallucination in multimodal large language models. If you have any question, please feel free to email [email protected] or add weChat ID xjtupanda.

Evaluation

We perform experiments based on four baseline models:

The experimental results are shown below. For more details, please check out our paper.

POPE Result

This part mainly focuses on benchmarking levels of object-level hallucinations.

MME Result

This part focuses on both object- and attribute-level hallucinations.

LLaVA-QA90 Result

We also propose to perform open-ended evaluation directly via the recently opened GPT-4V interface. We design two metrics: accuracy and detailedness.

Demo

Please feel free to try our Online Demo!

Preliminary

  1. Create conda environment
conda create -n corrector python=3.10
conda activate corrector
pip install -r requirements.txt
  1. Install required packages and models
  • Install spacy and relevant model packages, following the instructions in Link. This is used for some text processing operations.
pip install -U spacy
python -m spacy download en_core_web_lg
python -m spacy download en_core_web_md
python -m spacy download en_core_web_sm
  • For our Open-set Detector. Install GroundingDINO following the instructions in Link.

Usage

1. Inference

To make corrections based on an image and a text output from MLLM, run the inference code as follows:

python inference.py \
        --image-path {path/to/image} \
        --query "Some query.(e.x. Describe this image.)" \
        --text "Some text to be corrected." \
        --detector-config "path/to/GroundingDINO_SwinT_OGC.py" \
        --detector-model "path/to/groundingdino_swint_ogc.pth" \
        --api-key "sk-xxxxxxx" \

The output text will be printed in the terminal, and intermediate results saved by default as ./intermediate_view.json.


2. Demo setup

We use mPLUG-Owl as our default MLLM in experiments. If you wish to replicate the online demo, please clone the project and modify the variables in https://github.com/BradyFU/Woodpecker/blob/e3fcac307cc5ff5a3dc079d9a94b924ebcdc2531/gradio_demo.py#L7 and https://github.com/BradyFU/Woodpecker/blob/e3fcac307cc5ff5a3dc079d9a94b924ebcdc2531/gradio_demo.py#L35-L36

Then simply run:

CUDA_VISIBLE_DEVICES=0,1 python gradio_demo.py

Here we put the corrector components on GPU with id 0 and mPLUG-Owl on GPU with id 1.

Acknowledgement

This repository benefits from mPLUG-Owl, GroundingDINO, BLIP-2, and LLaMA-Adapter. Thanks for their awesome works.

📑Citation

If you find our project helpful to your research, please consider citing:

@article{yin2023woodpecker,
  title={Woodpecker: Hallucination Correction for Multimodal Large Language Models},
  author={Yin Shukang and Fu Chaoyou and Zhao Sirui and Xu Tong and Wang Hao and Sui Dianbo and Shen Yunhang and Li Ke and Sun Xing and Chen Enhong},
  journal={arXiv preprint arXiv:2310.16045},
  year={2023}
}

woodpecker's People

Contributors

bradyfu avatar xjtupanda avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.