bond005 commited on
Commit
12348e2
1 Parent(s): 68a37b5

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +43 -4
README.md CHANGED
@@ -6,18 +6,39 @@ license: apache-2.0
6
  pipeline_tag: text-classification
7
  ---
8
 
9
- # LLM hallucination detector
10
 
11
- The LLM hallucination detector based on the hierarchical [XLM-RoBERTa-XL](https://huggingface.co/facebook/xlm-roberta-xl) was developed to participate in the [SemEval-2024 Task-6 - SHROOM, a Shared-task on Hallucinations and Related Observable Overgeneration Mistakes](https://helsinki-nlp.github.io/shroom) (model-agnostic track).
12
 
13
  ## Model description
14
 
15
- Text...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  ## Intended uses & limitations
18
 
19
  This model is primarily aimed at being reference-based detected of hallucination in LLM without any additional information about LLM type and architecture (i.e. in model-agnostic mode). The reference-based detection means that the hallucination detector considers not only the human question and the answer generated by the verified LLM, but also the reference answer to the human question. Therefore, in a situation where the reference answer is not known, this hallucination detector is not applicable. But in some cases (for example, when we analyze the LLM's responses on an annotated test set and want to separate hallucinations from usual errors such as undergeneration, errors related to part of speech, and so on), we know information about the standards, and then the proposed detector will be extremely useful.
20
 
 
 
 
 
 
 
21
  ## Usage
22
 
23
  You need to install the [pytorch-metric-library](https://github.com/KevinMusgrave/pytorch-metric-learning) to use this model. After that, you can use this model directly with a pipeline for text classification:
@@ -64,6 +85,9 @@ def sample_to_str(sample: Dict[str, str]) -> str:
64
 
65
  # The input data format is based on data for the model-agnostic track of SHROOM
66
  # https://helsinki-nlp.github.io/shroom
 
 
 
67
  input_data = [
68
  {
69
  "hyp": "Resembling or characteristic of a weasel.",
@@ -185,4 +209,19 @@ PREDICTED
185
  p(Hallucination): 0.487
186
  ```
187
 
188
- The Google Colaboratory version of [this script](https://colab.research.google.com/drive/1T5LOuYfLNI3bqz6W-Y6kEajk3SumxyqU?usp=sharing) is available too.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  pipeline_tag: text-classification
7
  ---
8
 
9
+ # The reference-based LLM hallucination detector
10
 
11
+ The LLM hallucination detector based on the self-adaptive hierarchical [XLM-RoBERTa-XL](https://huggingface.co/facebook/xlm-roberta-xl) was developed to participate in the [SemEval-2024 Task-6 - SHROOM, a Shared-task on Hallucinations and Related Observable Overgeneration Mistakes](https://helsinki-nlp.github.io/shroom) (model-agnostic track).
12
 
13
  ## Model description
14
 
15
+ This model was component of my solution for the [SemEval-2024 Task-6 - SHROOM, a Shared-task on Hallucinations and Related Observable Overgeneration Mistakes](https://helsinki-nlp.github.io/shroom). The competition goal was to develop of the best algorithm to detect a LLM's hallucination, i.e. grammatically sound output that contains incorrect semantic information (unsupported or inconsistent with the source input). The competition organizers prepared two different setups:
16
+
17
+ - the model-aware track, where the developed detector can have access to the LLM that produced the output;
18
+
19
+ - the model-agnostic track, where the developed detector have not any access to the verified LLM, and it uses only the source input of this LLM and generated output.
20
+
21
+ This model was designed to detect hallucinations in the model-agnostic track. It was based on **fourth simple ideas**:
22
+
23
+ 1. **The detector is a Transformer-encoder** based on [XLM-RoBERTa-XL](https://huggingface.co/facebook/xlm-roberta-xl). The hallucination detection is a binary classification problem, and we don't need any decoder like as [SelfCheckGPT](https://arxiv.org/abs/2303.08896) to solve this problem. Make encoder great again!
24
+
25
+ 2. **The prompt engineering matters for encoders too** (not for decoders only). A specially designed text prompt is a good inductive bias for a text classifier.
26
+
27
+ 3. **The text classifier needs a self-adaptive hierarchy of encoder's hidden layers**. The classifier does not have to be built on top of the last hidden layer. Perhaps one of the earlier hidden layers would be more useful. We don't know this for sure, so we use a special gating network to automatically estimate the importance of encoder's various hidden layers during training.
28
+
29
+ 4. **A two-stage fine-tuning is all you need**. At the first stage we fine-tune our self-adaptive hierarchical encoder as a sentence embedder using contrastive learning. At the second stage we fine-tune this model as a usual classifier from the embedder's checkpoint. This approach was proposed in the paper "Contrastive fine-tuning to improve generalization in deep NER" (DOI: [10.28995/2075-7182-2022-21-70-80](https://www.dialog-21.ru/media/5751/bondarenkoi113.pdf)), but it works for other NLU tasks too.
30
+
31
 
32
  ## Intended uses & limitations
33
 
34
  This model is primarily aimed at being reference-based detected of hallucination in LLM without any additional information about LLM type and architecture (i.e. in model-agnostic mode). The reference-based detection means that the hallucination detector considers not only the human question and the answer generated by the verified LLM, but also the reference answer to the human question. Therefore, in a situation where the reference answer is not known, this hallucination detector is not applicable. But in some cases (for example, when we analyze the LLM's responses on an annotated test set and want to separate hallucinations from usual errors such as undergeneration, errors related to part of speech, and so on), we know information about the standards, and then the proposed detector will be extremely useful.
35
 
36
+ This model is capable of detecting LLM hallucinations that occur when solving the following NLG tasks: paraphrase generation, machine translation, and definition modeling.
37
+
38
+ ## Evaluation
39
+
40
+ The final ranking of all model-agnostic solutions on the test data is available in [the ranking agnostic CSV file](https://drive.google.com/file/d/1J-iRpZ1LQSkTnTKJaSFfJHa5zxoHd__K/view?usp=sharing) on the [SHROOM web-page](https://helsinki-nlp.github.io/shroom). The accuracy score of my solution is 0.77, and it ranks 28th out of 49. The abovementioned model is a component of my solution, and the accuracy of this model as an independent algorithm is 0.7153. For comparison, the accuracy of the baseline system based on SelfCheckGPT is 0.6967.
41
+
42
  ## Usage
43
 
44
  You need to install the [pytorch-metric-library](https://github.com/KevinMusgrave/pytorch-metric-learning) to use this model. After that, you can use this model directly with a pipeline for text classification:
 
85
 
86
  # The input data format is based on data for the model-agnostic track of SHROOM
87
  # https://helsinki-nlp.github.io/shroom
88
+ # "src" is a verified LLM's input to start generation
89
+ # "hyp" is an output generated by this LLM
90
+ # "tgt" is a reference output from the point of view of human assessors
91
  input_data = [
92
  {
93
  "hyp": "Resembling or characteristic of a weasel.",
 
209
  p(Hallucination): 0.487
210
  ```
211
 
212
+ The Google Colaboratory version of [this script](https://colab.research.google.com/drive/1T5LOuYfLNI3bqz6W-Y6kEajk3SumxyqU?usp=sharing) is available too.
213
+
214
+ ## Citation
215
+
216
+ If you want to cite this model you can use this:
217
+
218
+ ```bibtex
219
+ @misc{bondarenko2024hallucination,
220
+ title={The reference-based detector of LLM hallucinations by Ivan Bondarenko},
221
+ author={Bondarenko, Ivan},
222
+ publisher={Hugging Face},
223
+ journal={Hugging Face Hub},
224
+ howpublished={\url{https://huggingface.co/bond005/xlm-roberta-xl-hallucination-detector}},
225
+ year={2024}
226
+ }
227
+ ```