XufengDuan commited on
Commit
ccb627d
1 Parent(s): 56bf4e8

Update space

Browse files
Files changed (1) hide show
  1. src/display/about.py +162 -0
src/display/about.py ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dataclasses import dataclass
2
+ from enum import Enum
3
+
4
+ @dataclass
5
+ class Task:
6
+ benchmark: str
7
+ metric: str
8
+ col_name: str
9
+
10
+
11
+ class Tasks(Enum):
12
+ # task_key in the json file, metric_key in the json file, name to display in the leaderboard
13
+ hallucination_rate = Task("hallucination_rate",
14
+ "hallucination_rate", "Humanlike Score (%)")
15
+ # factual_consistency_rate = Task("factual_consistency_rate", "factual_consistency_rate", "Factual Consistency Rate (%)")
16
+ # answer_rate = Task("answer_rate", "answer_rate", "Answer Rate (%)")
17
+ # average_summary_length = Task("average_summary_length",
18
+ # "average_summary_length", "Average Summary Length")
19
+
20
+
21
+ # Your leaderboard name
22
+ TITLE = """<h1 align="center" id="space-title">Humanlike Evaluation Model (HEM) leaderboard</h1>"""
23
+
24
+ # What does your leaderboard evaluate?
25
+ INTRODUCTION_TEXT = """
26
+ This leaderboard (by [Vectara](https://vectara.com)) evaluates how often an LLM introduces hallucinations when summarizing a document. <br>
27
+ The leaderboard utilizes [HHEM](https://huggingface.co/vectara/hallucination_evaluation_model), an open source hallucination detection model.<br>
28
+ An improved version (HHEM v2) is integrated into the [Vectara platform](https://console.vectara.com/signup/?utm_source=huggingface&utm_medium=space&utm_term=integration&utm_content=console&utm_campaign=huggingface-space-integration-console).
29
+
30
+ """
31
+
32
+ # Which evaluations are you running? how can people reproduce what you have?
33
+ LLM_BENCHMARKS_TEXT = """
34
+ ## Introduction
35
+
36
+ The Hughes Hallucination Evaluation Model (HHEM) Leaderboard is dedicated to assessing the frequency of hallucinations in document summaries generated by Large Language Models (LLMs).
37
+
38
+ Hallucinations refer to instances where a model introduces factually incorrect or unrelated content in its summaries.
39
+
40
+ ## How it works
41
+
42
+ Using [Vectara](https://vectara.com)'s HHEM, we measure the occurrence of hallucinations in generated summaries.
43
+ 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.
44
+ The model card for HHEM can be found [here](https://huggingface.co/vectara/hallucination_evaluation_model).
45
+
46
+ ## Evaluation Dataset
47
+
48
+ 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).
49
+ 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))
50
+
51
+ ## Metrics Explained
52
+ - Hallucination Rate: Percentage of summaries with a hallucination score below 0.5
53
+ - Factual Consistency Rate: The complement of the hallucination rate, expressed as a percentage.
54
+ - 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)
55
+ - Average Summary Length: The average word count of generated summaries
56
+
57
+ ## Note on non-Hugging Face models
58
+ 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.
59
+ 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.
60
+
61
+ ## Model Submissions and Reproducibility
62
+ 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)
63
+
64
+ ### For models not available on the Hugging Face model hub:
65
+ 1) Access generated summaries used for evaluation [here](https://github.com/vectara/hallucination-leaderboard) in "leaderboard_summaries.csv".
66
+ 2) The text generation prompt is available under "Prompt Used" section in the repository's README.
67
+ 3) Details on API Integration for evaluations are under "API Integration Details".
68
+
69
+ ### For models available on the Hugging Face model hub:
70
+ To replicate the evaluation result for a Hugging Face model:
71
+
72
+ 1) Clone the Repository
73
+ ```python
74
+ git lfs install
75
+ git clone https://huggingface.co/spaces/vectara/leaderboard
76
+ ```
77
+ 2) Install the Requirements
78
+ ```python
79
+ pip install -r requirements.txt
80
+ ```
81
+ 3) Set Up Your Hugging Face Token
82
+ ```python
83
+ export HF_TOKEN=your_token
84
+ ```
85
+ 4) Run the Evaluation Script
86
+ ```python
87
+ python main_backend.py --model your_model_id --precision float16
88
+ ```
89
+ 5) Check Results
90
+ After the evaluation, results are saved in "eval-results-bk/your_model_id/results.json".
91
+
92
+ ## Results Format
93
+ The results are structured in JSON as follows:
94
+ ```python
95
+ {
96
+ "config": {
97
+ "model_dtype": "float16",
98
+ "model_name": "your_model_id",
99
+ "model_sha": "main"
100
+ },
101
+ "results": {
102
+ "hallucination_rate": {
103
+ "hallucination_rate": ...
104
+ },
105
+ "factual_consistency_rate": {
106
+ "factual_consistency_rate": ...
107
+ },
108
+ "answer_rate": {
109
+ "answer_rate": ...
110
+ },
111
+ "average_summary_length": {
112
+ "average_summary_length": ...
113
+ }
114
+ }
115
+ }
116
+ ```
117
+ For additional queries or model submissions, please contact minseok@vectara.com.
118
+ """
119
+
120
+ EVALUATION_QUEUE_TEXT = """
121
+ ## Some good practices before submitting a model
122
+
123
+ ### 1) Make sure you can load your model and tokenizer using AutoClasses:
124
+ ```python
125
+ from transformers import AutoConfig, AutoModel, AutoTokenizer
126
+ config = AutoConfig.from_pretrained("your model name", revision=revision)
127
+ model = AutoModel.from_pretrained("your model name", revision=revision)
128
+ tokenizer = AutoTokenizer.from_pretrained("your model name", revision=revision)
129
+ ```
130
+ If this step fails, follow the error messages to debug your model before submitting it. It's likely your model has been improperly uploaded.
131
+
132
+ Note: make sure your model is public!
133
+ 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!
134
+
135
+ ### 2) Convert your model weights to [safetensors](https://huggingface.co/docs/safetensors/index)
136
+ 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`!
137
+
138
+ ### 3) Make sure your model has an open license!
139
+ This is a leaderboard for Open LLMs, and we'd love for as many people as possible to know they can use your model 🤗
140
+
141
+ ### 4) Fill up your model card
142
+ When we add extra information about models to the leaderboard, it will be automatically taken from the model card
143
+
144
+ ## In case of model failure
145
+ If your model is displayed in the `FAILED` category, its execution stopped.
146
+ Make sure you have followed the above steps first.
147
+ """
148
+
149
+ CITATION_BUTTON_LABEL = "Copy the following snippet to cite these results"
150
+ CITATION_BUTTON_TEXT = r"""
151
+ @dataset{HughesBae2023,
152
+ author = {Simon Hughes and Minseok Bae},
153
+ title = {Vectara Hallucination Leaderboard},
154
+ year = {2023},
155
+ month = {11},
156
+ publisher = {Vectara, Inc},
157
+ doi = {},
158
+ url = {https://github.com/vectara/hallucination-leaderboard},
159
+ abstract = {A leaderboard comparing LLM performance at maintaining factual consistency when summarizing a set of facts.},
160
+ keywords = {nlp, llm, hallucination, nli, machine learning},
161
+ license = {Apache-2.0},
162
+ }"""