Update README.md
Browse files
README.md
CHANGED
@@ -11,27 +11,119 @@ model-index:
|
|
11 |
results: []
|
12 |
---
|
13 |
|
14 |
-
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
15 |
-
should probably proofread and complete it, then remove this comment. -->
|
16 |
-
|
17 |
[<img src="https://raw.githubusercontent.com/wandb/assets/main/wandb-github-badge-28.svg" alt="Visualize in Weights & Biases" width="200" height="32"/>](https://wandb.ai/josh-longenecker1-groundedai/phi3.5-hallucination/runs/re0kg3gs)
|
18 |
# outputs
|
19 |
|
20 |
-
This model is a fine-tuned version of [microsoft/Phi-3.5-mini-instruct](https://huggingface.co/microsoft/Phi-3.5-mini-instruct) on the
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
## Model description
|
25 |
|
26 |
-
|
27 |
|
28 |
## Intended uses & limitations
|
29 |
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
## Training and evaluation data
|
33 |
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
## Training procedure
|
37 |
|
@@ -67,7 +159,6 @@ The following hyperparameters were used during training:
|
|
67 |
| 0.3138 | 6.3158 | 60 | 1.2195 |
|
68 |
| 0.5315 | 6.8421 | 65 | 1.3147 |
|
69 |
|
70 |
-
|
71 |
### Framework versions
|
72 |
|
73 |
- PEFT 0.12.0
|
|
|
11 |
results: []
|
12 |
---
|
13 |
|
|
|
|
|
|
|
14 |
[<img src="https://raw.githubusercontent.com/wandb/assets/main/wandb-github-badge-28.svg" alt="Visualize in Weights & Biases" width="200" height="32"/>](https://wandb.ai/josh-longenecker1-groundedai/phi3.5-hallucination/runs/re0kg3gs)
|
15 |
# outputs
|
16 |
|
17 |
+
This model is a fine-tuned version of [microsoft/Phi-3.5-mini-instruct](https://huggingface.co/microsoft/Phi-3.5-mini-instruct) on the HaluEval dataset for hallucination detection.
|
18 |
+
|
19 |
+
## Merged Model Performance
|
20 |
+
|
21 |
+
This repository contains our hallucination evaluation PEFT adapter model.
|
22 |
+
|
23 |
+
### Hallucination Detection Metrics
|
24 |
+
|
25 |
+
Our merged model achieves the following performance on a binary classification task for detecting hallucinations in language model outputs:
|
26 |
+
|
27 |
+
```
|
28 |
+
precision recall f1-score support
|
29 |
+
|
30 |
+
0 0.77 0.91 0.83 100
|
31 |
+
1 0.89 0.73 0.80 100
|
32 |
+
|
33 |
+
accuracy 0.82 200
|
34 |
+
macro avg 0.83 0.82 0.82 200
|
35 |
+
weighted avg 0.83 0.82 0.82 200
|
36 |
+
```
|
37 |
+
|
38 |
+
### Model Usage
|
39 |
+
For best results, we recommend starting with the following prompting strategy (and encourage tweaks as you see fit):
|
40 |
+
|
41 |
+
```python
|
42 |
+
def format_input(reference, query, response):
|
43 |
+
prompt = f"""Your job is to evaluate whether a machine learning model has hallucinated or not.
|
44 |
+
A hallucination occurs when the response is coherent but factually incorrect or nonsensical
|
45 |
+
outputs that are not grounded in the provided context.
|
46 |
+
You are given the following information:
|
47 |
+
####INFO####
|
48 |
+
[Knowledge]: {reference}
|
49 |
+
[User Input]: {query}
|
50 |
+
[Model Response]: {response}
|
51 |
+
####END INFO####
|
52 |
+
Based on the information provided is the model output a hallucination? Respond with only "yes" or "no"
|
53 |
+
"""
|
54 |
+
return input
|
55 |
+
|
56 |
+
text = format_input(reference="The apple mac has the best hardware",
|
57 |
+
query='"What computer has the best software?",
|
58 |
+
response='Apple mac')
|
59 |
+
|
60 |
+
messages = [
|
61 |
+
{"role": "user", "content": text}
|
62 |
+
]
|
63 |
+
|
64 |
+
pipe = pipeline(
|
65 |
+
"text-generation",
|
66 |
+
model=base_model,
|
67 |
+
model_kwargs={"attn_implementation": attn_implementation, "torch_dtype": torch.float16},
|
68 |
+
tokenizer=tokenizer,
|
69 |
+
)
|
70 |
+
generation_args = {
|
71 |
+
"max_new_tokens": 2,
|
72 |
+
"return_full_text": False,
|
73 |
+
"temperature": 0.01,
|
74 |
+
"do_sample": True,
|
75 |
+
}
|
76 |
+
|
77 |
+
output = pipe(messages, **generation_args)
|
78 |
+
print(f'Hallucination: {output['generated_text'].strip().lower()}')
|
79 |
+
# Hallucination: yes
|
80 |
+
```
|
81 |
+
|
82 |
+
### Comparison with Other Models
|
83 |
+
|
84 |
+
We compared our merged model's performance on the hallucination detection benchmark against several other state-of-the-art language models:
|
85 |
+
|
86 |
+
| Model | Precision | Recall | F1 |
|
87 |
+
|---------------------- |----------:|-------:|-------:|
|
88 |
+
| Our Merged Model | 0.77 | 0.91 | 0.83 |
|
89 |
+
| GPT-4 | 0.93 | 0.72 | 0.82 |
|
90 |
+
| GPT-4 Turbo | 0.97 | 0.70 | 0.81 |
|
91 |
+
| Gemini Pro | 0.89 | 0.53 | 0.67 |
|
92 |
+
| GPT-3.5 | 0.89 | 0.65 | 0.75 |
|
93 |
+
| GPT-3.5-turbo-instruct| 0.89 | 0.80 | 0.84 |
|
94 |
+
| Palm 2 (Text Bison) | 1.00 | 0.44 | 0.61 |
|
95 |
+
| Claude V2 | 0.80 | 0.95 | 0.87 |
|
96 |
+
|
97 |
+
Scores from arize/phoenix
|
98 |
+
|
99 |
+
As shown in the table, our merged model achieves competitive performance, with an F1 score of 0.82, matching or outperforming several state-of-the-art language models on this hallucination detection task.
|
100 |
|
101 |
## Model description
|
102 |
|
103 |
+
This model is a fine-tuned version of the Phi-3.5-mini-instruct model, specifically adapted for hallucination detection. It has been trained on the HaluEval dataset to identify when language model outputs contain hallucinations - responses that are coherent but factually incorrect or not grounded in the provided context.
|
104 |
|
105 |
## Intended uses & limitations
|
106 |
|
107 |
+
This model is intended for use in evaluating the outputs of language models to detect potential hallucinations. It can be integrated into pipelines for content validation, fact-checking, or as a component in larger systems aimed at improving the reliability of AI-generated content.
|
108 |
+
|
109 |
+
Limitations:
|
110 |
+
- The model's performance may vary depending on the domain and complexity of the input.
|
111 |
+
- It may not catch all types of hallucinations, especially those that are subtle or require extensive domain knowledge.
|
112 |
+
- The model should be used as part of a broader strategy for ensuring AI output quality, not as a sole arbiter of truth.
|
113 |
|
114 |
## Training and evaluation data
|
115 |
|
116 |
+
This model was trained using the HaluEval dataset:
|
117 |
+
|
118 |
+
@misc{HaluEval,
|
119 |
+
author = {Junyi Li and Xiaoxue Cheng and Wayne Xin Zhao and Jian-Yun Nie and Ji-Rong Wen },
|
120 |
+
title = {HaluEval: A Large-Scale Hallucination Evaluation Benchmark for Large Language Models},
|
121 |
+
year = {2023},
|
122 |
+
journal={arXiv preprint arXiv:2305.11747},
|
123 |
+
url={https://arxiv.org/abs/2305.11747}
|
124 |
+
}
|
125 |
+
|
126 |
+
The HaluEval dataset is specifically designed for evaluating hallucinations in large language models, making it an ideal choice for training our hallucination detection model.
|
127 |
|
128 |
## Training procedure
|
129 |
|
|
|
159 |
| 0.3138 | 6.3158 | 60 | 1.2195 |
|
160 |
| 0.5315 | 6.8421 | 65 | 1.3147 |
|
161 |
|
|
|
162 |
### Framework versions
|
163 |
|
164 |
- PEFT 0.12.0
|