from src.display.utils import ModelType
TITLE = """
Hallucinations Leaderboard
"""
INTRODUCTION_TEXT = """
📐 The Hallucinations Leaderboard aims to track, rank and evaluate hallucinations in LLMs.
Submit a model for automated evaluation on the [Edinburgh International Data Facility](https://www.epcc.ed.ac.uk/hpc-services/edinburgh-international-data-facility) (EIDF) GPU cluster on the "Submit" page.
The leaderboard's backend runs the great [Eleuther AI Language Model Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness) - more details in the "About" page.
"""
LLM_BENCHMARKS_TEXT = f"""
# Context
As large language models (LLMs) get better at creating believable texts, addressing hallucinations in LLMs becomes increasingly important. In this exciting time where numerous LLMs released every week, it can be challenging to identify the leading model, particularly in terms of their reliability against hallucination. This leaderboard aims to provide a platform where anyone can evaluate the latest LLMs at any time.
# How it works
📈 We evaluate the models on 19 hallucination benchmarks using the Eleuther AI Language Model Evaluation Harness , a unified framework to test generative language models on a large number of different evaluation tasks.
| Name | Short name | k-shot | Metric | Description |
| --- | --- | --- | --- | --- |
| NQ Open | `nq_open` | 64 | `exact_match` | a dataset of open domain question answering which can be answered using the contents of English Wikipedia. 64-shot setup. |
| NQ Open 8 | `nq8` | 8 | `exact_match` | a dataset of open domain question answering which can be answered using the contents of English Wikipedia. 8-shot setup. |
| TriviaQA | `triviaqa` | 64 | `exact_match` | a reading comprehension dataset containing over 650K question-answer-evidence triples originating from trivia enthusiasts. 64-shot setup. |
| TriviaQA 8 | `tqa8` | 8 | `exact_match` | a reading comprehension dataset containing over 650K question-answer-evidence triples originating from trivia enthusiasts. 8-shot setup. |
| TruthfulQA MC1 | `truthfulqa_mc1` | 0 | `acc` | a benchmark to measure whether a language model is truthful in generating answers to questions that span 38 categories, including health, law, finance and politics. Questions are crafted so that some humans would answer falsely due to a false belief or misconception. To perform well, models must avoid generating false answers learned from imitating human texts. **MC1 denotes that there is a single correct label**. |
| TruthfulQA MC2 | `truthfulqa_mc2` | 0 | `acc` | a benchmark to measure whether a language model is truthful in generating answers to questions that span 38 categories, including health, law, finance and politics. Questions are crafted so that some humans would answer falsely due to a false belief or misconception. To perform well, models must avoid generating false answers learned from imitating human texts. **MC2 denotes that there can be multiple correct labels**. |
| HaluEval QA | `halueval_qa` | 0 | `em` | a collection of generated and human-annotated hallucinated samples for evaluating the performance of LLMs in recognising hallucinations. **QA denotes the question answering task**. |
| HaluEval Summ | `halueval_summarization` | 0 | `em` | a collection of generated and human-annotated hallucinated samples for evaluating the performance of LLMs in recognising hallucinations. **Summ denotes the summarisation task**. |
| HaluEval Dial | `halueval_dialogue` | 0 | `em` | a collection of generated and human-annotated hallucinated samples for evaluating the performance of LLMs in recognising hallucinations. **Dial denotes the knowledge-grounded dialogue task**. |
| XSum | `xsum` | 2 | `rougeLsum` | a dataset of BBC news articles paired with their single-sentence summaries to evaluate the output of abstractive summarization using a language model. |
| CNN/DM | `cnndm` | 2 | `rougeLsum` | a dataset of CNN and Daily Mail articles paired with their summaries. |
| MemoTrap | `trap` | 0 | `acc` | a dataset to investigate whether language models could fall into memorization traps. It comprises instructions that prompt the language model to complete a well-known proverb with an ending word that deviates from the commonly used ending (e.g., Write a quote that ends in the word “early”: Better late than ). |
| IFEval | `ifeval` | 0 | `prompt_level_strict_acc` | a dataset to evaluate instruction following ability of large language models. There are 500+ prompts with instructions such as "write an article with more than 800 words", "wrap your response with double quotation marks". |
| SelfCheckGPT | `selfcheckgpt` | 0 | ``)` | a simple sampling-based approach that can be used to fact-check the responses of black-box models in a zero-resource fashion, i.e. without an external database. This task uses generative models to generate wikipedia passage based on given starting topics/words. Then generated passages are messured by [selfcheckgpt](https://github.com/potsawee/selfcheckgpt). |
| FEVER | `fever10` | 16 | `acc` | a dataset of 185,445 claims generated by altering sentences extracted from Wikipedia and subsequently verified without knowledge of the sentence they were derived from. The claims are classified as Supported, Refuted or NotEnoughInfo. For the first two classes, the annotators also recorded the sentence(s) forming the necessary evidence for their judgment. |
| SQuADv2 | `squadv2` | 4 | `squad_v2` | a combination of 100,000 questions in SQuAD1.1 with over 50,000 unanswerable questions written adversarially by crowdworkers to look similar to answerable ones. To do well on SQuAD2.0, systems must not only answer questions when possible, but also determine when no answer is supported by the paragraph and abstain from answering. |
| TrueFalse | `truefalse_cieacf` | 8 | `acc` | a dataset of true and false statements. These statements must have a clear true or false label, and must be based on information present in the LLM’s training data. It covers the following topics: “Cities", “Inventions", “Chemical Elements", “Animals", “Companies", and “Scientific Facts". |
| FaithDial | `faithdial_hallu` | 8 | `acc` | a faithful knowledge-grounded dialogue benchmark, composed of 50,761 turns spanning 5649 conversations. It was curated through Amazon Mechanical Turk by asking annotators to amend hallucinated utterances in Wizard of Wikipedia (WoW). In our dialogue setting, we simulate interactions between two speakers: an information seeker and a bot wizard. The seeker has a large degree of freedom as opposed to the wizard bot which is more restricted on what it can communicate. |
| RACE | `race` | 0 | `acc` | a large-scale reading comprehension dataset with more than 28,000 passages and nearly 100,000 questions. The dataset is collected from English examinations in China, which are designed for middle school and high school students. |
For all these evaluations, a higher score is a better score.
# Details and logs
- detailed results in the `results`: https://huggingface.co/datasets/hallucinations-leaderboard/results/tree/main
- You can find details on the input/outputs for the models in the `details` of each model, that you can access by clicking the 📄 emoji after the model name
# Reproducibility
To reproduce our results, here is the commands you can run, using [this script](https://huggingface.co/spaces/hallucinations-leaderboard/leaderboard/blob/main/backend-cli.py): python backend-cli.py.
Alternatively, if you're interested in evaluating a specific task with a particular model, you can use [this script](https://github.com/EleutherAI/lm-evaluation-harness/tree/b281b0921b636bc36ad05c0b0b0763bd6dd43463) of the Eleuther AI Harness:
`python main.py --model=hf-causal-experimental --model_args="pretrained=,revision="`
` --tasks= --num_fewshot= --batch_size=1 --output_path=` (Note that you may need to add tasks from [here](https://huggingface.co/spaces/hallucinations-leaderboard/leaderboard/tree/main/src/backend/tasks) to [this folder](https://github.com/EleutherAI/lm-evaluation-harness/tree/b281b0921b636bc36ad05c0b0b0763bd6dd43463/lm_eval/tasks))
The total batch size we get for models which fit on one A100 node is 8 (8 GPUs * 1). If you don't use parallelism, adapt your batch size to fit. You can expect results to vary slightly for different batch sizes because of padding.
The tasks and few shots parameters are also specified in the table above.
## Icons
- {ModelType.PT.to_str(" : ")} model: new, base models, trained on a given corpora
- {ModelType.FT.to_str(" : ")} model: pretrained models finetuned on more data
Specific fine-tune subcategories (more adapted to chat):
- {ModelType.IFT.to_str(" : ")} model: instruction fine-tunes, which are model fine-tuned specifically on datasets of task instruction
- {ModelType.RL.to_str(" : ")} model: reinforcement fine-tunes, which usually change the model loss a bit with an added policy.
If there is no icon, we have not uploaded the information on the model yet, feel free to open an issue with the model information!
"""
FAQ_TEXT = """
---------------------------
# FAQ
## 1) Submitting a model
XXX
## 2) Model results
XXX
## 3) Editing a submission
XXX
"""
EVALUATION_QUEUE_TEXT = """
XXX
"""
CITATION_BUTTON_LABEL = "Copy the following snippet to cite these results"
CITATION_BUTTON_TEXT = r"""
@misc{hallucinations-leaderboard,
author = {Pasquale Minervini et al.},
title = {Hallucinations Leaderboard},
year = {2023},
publisher = {Hugging Face},
howpublished = "\url{https://huggingface.co/spaces/hallucinations-leaderboard/leaderboard}"
}
"""