Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 7,595 Bytes
efeee6d 314f91a 95f85ed 58b9de9 156ef43 5bcc476 156ef43 58b9de9 404587d efeee6d 818ee3d 58733e4 efeee6d 8c49cb6 e2aca33 404587d 0227006 efeee6d 58b9de9 dbcffd4 818ee3d d313dbd dbcffd4 404587d e2aca33 818ee3d 404587d dbcffd4 404587d dbcffd4 404587d f0b90cf 818ee3d f0b90cf dbcffd4 f0b90cf dbcffd4 f0b90cf dbcffd4 f0b90cf dbcffd4 f0b90cf dbcffd4 f0b90cf dbcffd4 f0b90cf dbcffd4 d16cee2 dbcffd4 f0b90cf dbcffd4 f0b90cf dbcffd4 f0b90cf dbcffd4 f0b90cf dbcffd4 f0b90cf dbcffd4 f0b90cf dbcffd4 d313dbd 8c49cb6 d313dbd 8c49cb6 b323764 d313dbd b323764 d313dbd 8c49cb6 58733e4 2a73469 217b585 b46b972 9833cdb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
from dataclasses import dataclass
from enum import Enum
@dataclass
class Task:
benchmark: str
metric: str
col_name: str
class Tasks(Enum):
# task_key in the json file, metric_key in the json file, name to display in the leaderboard
hallucination_rate = Task("hallucination_rate",
"hallucination_rate", "Hallucination Rate (%)")
factual_consistency_rate = Task("factual_consistency_rate", "factual_consistency_rate", "Factual Consistency Rate (%)")
answer_rate = Task("answer_rate", "answer_rate", "Answer Rate (%)")
average_summary_length = Task("average_summary_length",
"average_summary_length", "Average Summary Length")
# Your leaderboard name
TITLE = """<h1 align="center" id="space-title">Hughes Hallucination Evaluation Model (HHEM) leaderboard</h1>"""
# What does your leaderboard evaluate?
INTRODUCTION_TEXT = """
This leaderboard evaluates how often an LLM introduces hallucinations when summarizing a document.
"""
# Which evaluations are you running? how can people reproduce what you have?
LLM_BENCHMARKS_TEXT = """
## Introduction
The Hughes Hallucination Evaluation Model (HHEM) Leaderboard is dedicated to assessing the frequency of hallucinations in document summaries generated by Large Language Models (LLMs).
Hallucinations refer to instances where a model introduces factually incorrect or unrelated content in its summaries.
## How it works
Using [Vectara](https://vectara.com)'s HHEM, we measure the occurrence of hallucinations in generated summaries.
Given a source document and a summary generated by an LLM, HHEM outputs a hallucination score between 0 and 1, with 0 indicating complete hallucination and 1 representing perfect factual consistency.
The model card for HHEM can be found [here](https://huggingface.co/vectara/hallucination_evaluation_model).
## Evaluation Dataset
Our evaluation dataset consists of 1006 documents from multiple public datasets, primarily [CNN/Daily Mail Corpus](https://huggingface.co/datasets/cnn_dailymail/viewer/1.0.0/test).
We generate summaries for each of these documents using submitted LLMs and compute hallucination scores for each pair of document and generated summary. (Check the prompt we used [here](https://huggingface.co/spaces/vectara/Hallucination-evaluation-leaderboard))
## Metrics Explained
- Hallucination Rate: Percentage of summaries with a hallucination score below 0.5
- Factual Consistency Rate: The complement of the hallucination rate, expressed as a percentage.
- Answer Rate: Percentage of summaries that are non-empty. This is either the model refuses to generate a response or throws an error due to various reasons. (e.g. the model believes that the document includes inappropriate content)
- Average Summary Length: The average word count of generated summaries
## Note on non-Hugging Face models
On HHEM leaderboard, There are currently models such as GPT variants that are not available on the Hugging Face model hub. We ran the evaluations for these models on our own and uploaded the results to the leaderboard.
If you would like to submit your model that is not available on the Hugging Face model hub, please contact us at minseok@vectara.com.
## Model Submissions and Reproducibility
You can submit your model for evaluation, whether it's hosted on the Hugging Face model hub or not. (Though it is recommended to host your model on the Hugging Face)
### For models not available on the Hugging Face model hub:
1) Access generated summaries used for evaluation [here](https://github.com/vectara/hallucination-leaderboard) in "leaderboard_summaries.csv".
2) The text generation prompt is available under "Prompt Used" section in the repository's README.
3) Details on API Integration for evaluations are under "API Integration Details".
### For models available on the Hugging Face model hub:
To replicate the evaluation result for a Hugging Face model:
1) Clone the Repository
```python
git lfs install
git clone https://huggingface.co/spaces/vectara/leaderboard
```
2) Install the Requirements
```python
pip install -r requirements.txt
```
3) Set Up Your Hugging Face Token
```python
export HF_TOKEN=your_token
```
4) Run the Evaluation Script
```python
python main_backend.py --model your_model_id --precision float16
```
5) Check Results
After the evaluation, results are saved in "eval-results-bk/your_model_id/results.json".
## Results Format
The results are structured in JSON as follows:
```python
{
"config": {
"model_dtype": "float16",
"model_name": "your_model_id",
"model_sha": "main"
},
"results": {
"hallucination_rate": {
"hallucination_rate": ...
},
"factual_consistency_rate": {
"factual_consistency_rate": ...
},
"answer_rate": {
"answer_rate": ...
},
"average_summary_length": {
"average_summary_length": ...
}
}
}
```
For additional queries or model submissions, please contact minseok@vectara.com.
"""
EVALUATION_QUEUE_TEXT = """
## Some good practices before submitting a model
### 1) Make sure you can load your model and tokenizer using AutoClasses:
```python
from transformers import AutoConfig, AutoModel, AutoTokenizer
config = AutoConfig.from_pretrained("your model name", revision=revision)
model = AutoModel.from_pretrained("your model name", revision=revision)
tokenizer = AutoTokenizer.from_pretrained("your model name", revision=revision)
```
If this step fails, follow the error messages to debug your model before submitting it. It's likely your model has been improperly uploaded.
Note: make sure your model is public!
Note: if your model needs `use_remote_code=True`, we do not support this option yet but we are working on adding it, stay posted!
### 2) Convert your model weights to [safetensors](https://huggingface.co/docs/safetensors/index)
It's a new format for storing weights which is safer and faster to load and use. It will also allow us to add the number of parameters of your model to the `Extended Viewer`!
### 3) Make sure your model has an open license!
This is a leaderboard for Open LLMs, and we'd love for as many people as possible to know they can use your model 🤗
### 4) Fill up your model card
When we add extra information about models to the leaderboard, it will be automatically taken from the model card
## In case of model failure
If your model is displayed in the `FAILED` category, its execution stopped.
Make sure you have followed the above steps first.
"""
CITATION_BUTTON_LABEL = "Copy the following snippet to cite these results"
CITATION_BUTTON_TEXT = r"""
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!
cff-version: 1.2.0
title: Vectara Hallucination Leaderboard
message: >-
If you use this dataset, please cite it using the metadata
from this file.
type: dataset
authors:
- email: simon@vectara.com
given-names: Simon
family-names: Hughes
- given-names: Minseok
family-names: Bae
email: minseok@vectara.com
repository-code: 'https://github.com/vectara/hallucination-leaderboard'
url: >-
https://github.com/vectara/hallucination-leaderboard/blob/main/README.md
abstract: >-
A leaderboard comparing LLM performance at maintaining
factual consistency when summarizing a set of facts.
keywords:
- nlp
- llm
- hallucination
- nli
- machine learning
license: Apache-2.0
date-released: '2023-11-01'
"""
|