https://github.com/vectara/halu_control
Methods for controlling hallucinations for LLM
https://github.com/vectara/halu_control
Last synced: 6 months ago
JSON representation
Methods for controlling hallucinations for LLM
- Host: GitHub
- URL: https://github.com/vectara/halu_control
- Owner: vectara
- License: apache-2.0
- Created: 2024-05-07T03:12:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-25T22:19:35.000Z (about 1 year ago)
- Last Synced: 2025-03-27T20:41:06.810Z (6 months ago)
- Language: Jupyter Notebook
- Size: 75.2 KB
- Stars: 38
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# halu_control
Methods for controlling hallucinations for LLM in SummarizationBlog post: https://vectara.com/blog/reducing-hallucinations-in-llms/
# Benchmark settings
| MODEL | Strategy | Consistency Rate | Answer Rate | Average Length |
| - | - | - | - | - |
| Mistral-7B-Instruct-v0.1 | Greedy | 93.2 | 100.0 | 93.5 |
| Mistral-7B-Instruct-v0.1 | num_beam = 10 | 95.3 | 100.0 | 127.7 |
| Mistral-7B-Instruct-v0.1 | Greedy + DoLA | 93.7 | 100.0 | 93.6 |
| Mistral-7B-Instruct-v0.1 | Greedy + DPO(LoRA) | 95.8 | 100.0 | 97.0 |
| Mistral-7B-Instruct-v0.1 | Greedy + Fava | 93.7 | 100.0 | 93.3 |
| Mistral-7B-Instruct-v0.1 | DPO(LoRA) + num_beam=10 | 96.9 | 100.0 | 123.7 |
| Mistral-7B-Instruct-v0.1 | Best_of_N + Temperature=0.7 + n=10 | 99.3 | 100.0 | 89.6 |Note: Prompt slightly different from the orginal [HHEM](https://huggingface.co/spaces/vectara/leaderboard) benchmark, causing different numbers.
# How to reproduce the experiments
1. Download the leaderboard dataset (https://huggingface.co/spaces/vectara/leaderboard/raw/main/src/datasets/leaderboard_dataset.csv)
2. Generate the model response ``generated.csv``, see methods below
3. Run evaluation on the reposnse file
```bash
python -c "from leaderboard import run_eval;run_eval('generated.csv')"
```# Methods
## Baselines
1. [Greedy/Beam Search](https://huggingface.co/blog/how-to-generate)
- Notebook: [1_decoding.ipynb](1_decoding.ipynb)2. [Best of N sampling](https://huggingface.co/docs/trl/main/en/best_of_n)
- Notebook: [5_best_of_n.ipynb](5_best_of_n.ipynb)## DoLa: Decoding by Contrasting Layers Improves Factuality in Large Language Models
- [Paper Link](https://arxiv.org/abs/2309.03883)
- Notebook: [2_dola.ipynb](2_dola.ipynb)## Fine-tuning Language Models for Factuality
- [Paper Link](https://arxiv.org/abs/2311.08401)
- Notebook: [3_dpo.ipynb](3_dpo.ipynb)
- Training code: [dpo_training.py](dpo_training.py)
- Note: our setting is different from the original paper, we used CNN/Dailymail+XSum+VitaminC as the source dataset and [HHEM](https://huggingface.co/vectara/hallucination_evaluation_model) model as the reference metric for factuality.## Fine-grained Hallucination Detection and Editing For Language Models
- [Web Link](https://fine-grained-hallucination.github.io/)
- Notebook: [4_fava.ipynb](4_fava.ipynb)