# EasyDetect **Repository Path**: openkg/EasyDetect ## Basic Information - **Project Name**: EasyDetect - **Description**: 开源大模型幻觉检测框架 - **Primary Language**: Python - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 1 - **Created**: 2024-02-07 - **Last Updated**: 2024-02-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: 幻觉, 大模型, 幻觉检测, 知识, 多模态 ## README
**An Easy-to-Use Multimodal Hallucination Detection Framework for MLLMs**
---
🤗Benchmark • 🍎Demo • 🌟Overview • 🔧Installation • ⏩Quickstart • 🚩Citation • 🎉Contributors
 [](https://opensource.org/licenses/MIT)  
**Table 1:** *A comparison of benchmarks with respect to existing fact-checking or hallucination evaluation.* "Check." indicates verifying factual consistency, "Eval." denotes evaluating hallucinations generated by different LLMs, and its response is based on different LLMs under test, while "Det." embodies the evaluation of a detector’s capability in identifying hallucinations.
**Figure 4:** *The specific illustration of UniHD for unified multimodal hallucination detection.*
---
## 🔧Installation
**Installation for local development:**
```
git clone https://github.com/OpenKG-ORG/EasyDetect.git
cd EasyDetect
pip install -r requirements.txt
```
**Installation for tools(GroundingDINO and MAERec):**
```
# install GroundingDINO
git clone https://github.com/IDEA-Research/GroundingDINO.git
cp -r GroundingDINO EasyDetect/GroundingDINO
cd EasyDetect/GroundingDINO/
pip install -e .
cd ..
# install MAERec
git clone https://github.com/Mountchicken/Union14M.git
cp -r Union14M/mmocr-dev-1.x EasyDetect/mmocr
cd EasyDetect/mmocr/
pip install -U openmim
mim install mmengine
mim install mmcv
mim install mmdet
pip install timm
pip install -r requirements/albu.txt
pip install -r requirements.txt
pip install -v -e .
cd ..
mkdir weights
cd weights
wget -q https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth
wget https://download.openmmlab.com/mmocr/textdet/dbnetpp/dbnetpp_resnet50-oclip_fpnc_1200e_icdar2015/dbnetpp_resnet50-oclip_fpnc_1200e_icdar2015_20221101_124139-4ecb39ac.pth -O dbnetpp.pth
wget https://github.com/Mountchicken/Union14M/releases/download/Checkpoint/maerec_b_union14m.pth -O maerec_b.pth
cd ..
```
---
## ⏩Quickstart
We provide example code for users to quickly get started with EasyDetect.
#### Step1: Write a configuration file in yaml format
Users can easily configure the parameters of EasyDetect in a yaml file or just quickly use the default parameters in the configuration file we provide. The path of the configuration file is EasyDetect/pipeline/config/config.yaml
```yaml
openai:
api_key: Input your openai api key
base_url: Input base_url, default is None
temperature: 0.2
max_tokens: 1024
tool:
detect:
groundingdino_config: the path of GroundingDINO_SwinT_OGC.py
model_path: the path of groundingdino_swint_ogc.pth
device: cuda:0
BOX_TRESHOLD: 0.35
TEXT_TRESHOLD: 0.25
AREA_THRESHOLD: 0.001
ocr:
dbnetpp_config: the path of dbnetpp_resnet50-oclip_fpnc_1200e_icdar2015.py
dbnetpp_path: the path of dbnetpp.pth
maerec_config: the path of maerec_b_union14m.py
maerec_path: the path of maerec_b.pth
device: cuda:0
content: word.number
cachefiles_path: the path of cache_files to save temp images
BOX_TRESHOLD: 0.2
TEXT_TRESHOLD: 0.25
google_serper:
serper_api_key: Input your serper api key
snippet_cnt: 10
prompts:
claim_generate: pipeline/prompts/claim_generate.yaml
query_generate: pipeline/prompts/query_generate.yaml
verify: pipeline/prompts/verify.yaml
```
#### Step2: Run with the Example Code
Example Code
```python
from pipeline.run_pipeline import *
pipeline = Pipeline()
text = "The cafe in the image is named \"Hauptbahnhof\""
image_path = "./examples/058214af21a03013.jpg"
type = "image-to-text"
response, claim_list = pipeline.run_pipeline(text=text, image_path=filepath, type=type)
print(response)
print(claim_list)
```
---
### 🚩Citation
Please cite our repository if you use EasyDetect in your work.
```bibtex
@article{chen2024factchd,
title={FactCHD: Benchmarking Fact-Conflicting Hallucination Detection},
author={Xiang Chen and Duanzheng Song and Honghao Gui and Chenxi Wang and Ningyu Zhang
and Jiang Yong and Fei Huang and Chengfei Lv and Dan Zhang and Huajun Chen},
year={2024},
eprint={2310.12086},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
@article{chen2024unified,
title={Unified Hallucination Detection for Multimodal Large Language Models},
author={Xiang Chen and Chenxi Wang and Yida Xue and Ningyu Zhang and Xiaoyan Yang and Qiang Li and Yue Shen and Jinjie Gu and Huajun Chen},
year={2024},
eprint={2402.03190},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
```
---
## 🎉Contributors