Safetensors
English
Files changed (1) hide show
  1. README.md +142 -101
README.md CHANGED
@@ -1,200 +1,241 @@
1
  ---
2
- # For reference on model card metadata, see the spec: https://github.com/huggingface/hub-docs/blob/main/modelcard.md?plain=1
3
- # Doc / guide: https://huggingface.co/docs/hub/model-cards
4
- {}
5
  ---
6
 
7
- # Model Card for Model ID
8
 
9
- <!-- Provide a quick summary of what the model is/does. -->
 
 
10
 
11
- This modelcard aims to be a base template for new models. It has been generated using [this raw template](https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/templates/modelcard_template.md?plain=1).
12
 
13
- ## Model Details
14
 
15
- ### Model Description
16
 
17
- <!-- Provide a longer summary of what this model is. -->
18
 
19
 
 
20
 
21
- - **Developed by:** [More Information Needed]
22
- - **Funded by [optional]:** [More Information Needed]
23
- - **Shared by [optional]:** [More Information Needed]
24
- - **Model type:** [More Information Needed]
25
- - **Language(s) (NLP):** [More Information Needed]
26
- - **License:** [More Information Needed]
27
- - **Finetuned from model [optional]:** [More Information Needed]
28
 
29
- ### Model Sources [optional]
30
 
31
- <!-- Provide the basic links for the model. -->
32
 
33
- - **Repository:** [More Information Needed]
34
- - **Paper [optional]:** [More Information Needed]
35
- - **Demo [optional]:** [More Information Needed]
36
 
37
- ## Uses
38
 
39
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
40
 
41
- ### Direct Use
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
44
 
45
- [More Information Needed]
46
 
47
- ### Downstream Use [optional]
48
 
49
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
50
 
51
- [More Information Needed]
52
 
53
- ### Out-of-Scope Use
54
 
55
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
56
 
57
- [More Information Needed]
58
 
59
- ## Bias, Risks, and Limitations
60
 
61
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
 
 
 
 
 
62
 
63
- [More Information Needed]
64
 
65
- ### Recommendations
 
 
 
 
 
 
 
 
 
66
 
67
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
68
 
69
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
70
 
71
  ## How to Get Started with the Model
72
 
73
  Use the code below to get started with the model.
74
 
75
- [More Information Needed]
76
 
77
- ## Training Details
78
 
79
- ### Training Data
80
 
81
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
82
 
83
- [More Information Needed]
84
 
85
- ### Training Procedure
86
 
87
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
88
 
89
- #### Preprocessing [optional]
90
 
91
- [More Information Needed]
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
 
94
- #### Training Hyperparameters
95
 
96
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
 
97
 
98
- #### Speeds, Sizes, Times [optional]
99
 
100
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
 
 
 
 
101
 
102
- [More Information Needed]
103
 
104
- ## Evaluation
 
 
 
 
 
 
 
 
 
 
 
105
 
106
- <!-- This section describes the evaluation protocols and provides the results. -->
107
 
108
- ### Testing Data, Factors & Metrics
109
 
110
- #### Testing Data
111
 
112
- <!-- This should link to a Dataset Card if possible. -->
 
 
113
 
114
- [More Information Needed]
115
 
116
- #### Factors
117
 
118
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
119
 
120
- [More Information Needed]
121
 
122
- #### Metrics
123
 
124
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
125
 
126
- [More Information Needed]
127
 
128
- ### Results
129
 
130
- [More Information Needed]
131
 
132
- #### Summary
133
 
 
134
 
135
 
136
- ## Model Examination [optional]
 
 
137
 
138
- <!-- Relevant interpretability work for the model goes here -->
139
 
140
- [More Information Needed]
141
 
142
- ## Environmental Impact
143
 
144
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
145
 
146
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
147
 
148
- - **Hardware Type:** [More Information Needed]
149
- - **Hours used:** [More Information Needed]
150
- - **Cloud Provider:** [More Information Needed]
151
- - **Compute Region:** [More Information Needed]
152
- - **Carbon Emitted:** [More Information Needed]
153
 
154
- ## Technical Specifications [optional]
155
 
156
- ### Model Architecture and Objective
157
 
158
- [More Information Needed]
159
 
160
- ### Compute Infrastructure
161
 
162
- [More Information Needed]
163
 
164
- #### Hardware
165
 
166
- [More Information Needed]
167
 
168
- #### Software
169
 
170
- [More Information Needed]
171
 
172
- ## Citation [optional]
173
 
174
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
175
 
176
- **BibTeX:**
177
 
178
- [More Information Needed]
179
 
180
- **APA:**
181
 
182
- [More Information Needed]
183
 
184
- ## Glossary [optional]
185
 
186
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
187
 
188
- [More Information Needed]
189
 
190
- ## More Information [optional]
191
 
192
- [More Information Needed]
193
 
194
- ## Model Card Authors [optional]
195
 
196
- [More Information Needed]
197
 
198
  ## Model Card Contact
199
 
200
- [More Information Needed]
 
1
  ---
2
+ license: cc-by-nc-sa-4.0
 
 
3
  ---
4
 
5
+ # Model Card for Hallucination Detection Model (HDM-2-3B)
6
 
7
+ **Paper:**
8
+ [![Read full-text on arXiv](https://img.shields.io/badge/arXiv-2504.07069-b31b1b.svg)](https://arxiv.org/abs/2504.07069)
9
+ *HalluciNot: Hallucination Detection Through Context and Common Knowledge Verification.*
10
 
 
11
 
12
+ **Notebook:** [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https\://colab.research.google.com/drive/1HclyB06twZVIxuK6AlyifRaf77vO5Yz#scrollTo=UVvBvBMWrDiv)
13
 
 
14
 
15
+ **HDM-Bench Dataset:** 🤗 [HuggingFace Dataset](https\://huggingface.co/datasets/AimonLabs/HDM-Bench)
16
 
17
 
18
+ ## Introduction
19
 
20
+ Most judge models used in the industry today are not specialized for Hallucination evaluation tasks.
21
+ Developers using them often struggle with score inconsistency, variance, high latencies, high costs, and prompt sensitivity.
22
+ HDM-2 solves these challenges and at the same time, provides industry-first, state-of-the-art features.
 
 
 
 
23
 
 
24
 
25
+ ## Highlights:
26
 
27
+ - Outperforms existing baselines on RagTruth, TruthfulQA, and our new HDM-Bench benchmark.
 
 
28
 
29
+ - **Context-based** hallucination evaluations based on user-provided or retrieved documents.
30
 
31
+ - **Common knowledge** contradictions based on widely-accepted common knowledge facts.
32
 
33
+ - **Phrase, token, and sentence-level** Hallucination identification with token-level probability **scores**
34
+
35
+ - Generalized model that works well across a variety of domains such as Finance, Healthcare, Legal, and Insurance.
36
+
37
+ - Operates within a **latency** budget of **500ms** on a single L4 GPU, especially beneficial for Agentic use cases.
38
+
39
+ ## Model Overview:
40
+
41
+ HDM-2 is a modular, production-ready, multi-task hallucination (or inaccuracy) evaluation model designed to validate the factual groundedness of LLM outputs in enterprise environments, for both **contextual** and **common knowledge** evaluations.
42
+ HDM-2 introduces a novel taxonomy-guided, span-level validation architecture focused on precision, explainability, and adaptability.
43
+ The figure below shows the workflow (on the left) in which we determine whether a certain LLM response is hallucinated or not and an example (on the right) that shows the taxonomy of an LLM response.
44
+
45
+ HDM-2 Model Workflow | Example of Enterprise LLM Response Taxonomy
46
+ --- | ---
47
+ ![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXdpn0qSjx_A3ax0qXZ3BIBTXAbMphuN1gLPXRQ4m_aTCSaN_hMMS27d0hJeQaZhc0P_iCpnktRsCyT_xB5V7-ofqQwjAvNWkRka_fJAGKfD466PK-jgGoRpDPqT9Ag3MT8XVSGscQ?key=x9HqmDQsJmBeqyuiakDxe8Cs) | ![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfJzyMnYVlR9sNIV7cDKmY3d_RnQYUBj7Ass6RWfhTt5ds2OJ5os2uPv7loECI_ao7_To3H4WV9UoHhnbJ2Ux-XSFQK76NJzOkiWNuDQQxuaojzgazujJ45KPSyhbtbfNe3msyl6w?key=x9HqmDQsJmBeqyuiakDxe8Cs)
48
 
 
49
 
50
+ ### Enterprise Models
51
 
52
+ - The Enterprise version offers a way to incorporate “Enterprise knowledge” into Hallucination evaluations. This means knowledge that is specific to your company (or domain or industry) that might not be present in your context!!
53
 
54
+ - Another important feature covered in the Enterprise version are explanations. Please reach out to us for Enterprise licensing. 
55
 
56
+ - Other premium capabilities that will be included in the Enterprise version include improved accuracies, even lower latencies, and additional use cases such as Math and Code.
57
 
58
+ - Apart from Hallucinations, we have SOTA models for Prompt/Instruction adherence, RAG Relevance, Reranking (Promptable). The instruction adherence model is general-purpose and extremely low-latency. It performs well with a wide variety of instructions, including safety, style, and format constraints.
59
 
 
60
 
61
+ ### Performance - Model Accuracy
62
 
63
+ See paper (linked on top) for more details.
64
 
65
+ | | | | |
66
+ | :---------: | :-----------: | :--------: | :----------: |
67
+ | **Dataset** | **Precision** | **Recall** | **F1 Score** |
68
+ | HDMBENCH | 0.87 | 0.84 | 0.855 |
69
+ | TruthfulQA | 0.82 | 0.78 | 0.80 |
70
+ | RagTruth | 0.85 | 0.81 | 0.83 |
71
 
 
72
 
73
+ ### Latency
74
+
75
+
76
+ | | | | | |
77
+ | ----------------------- | -------------------- | ---------------------- | ----------------------- | ------------------- |
78
+ | **Device** | **Avg. Latency (s)** | **Median Latency (s)** | **95th Percentile (s)** | **Max Latency (s)** |
79
+ | Nvidia A100 | 0.204 | 0.201 | 0.208 | 1.32 |
80
+ | Nvidia L4 (recommended) | 0.207 | 0.203 | 0.220 | 1.29 |
81
+ | Nvidia T4 | 0.935 | 0.947 | 1.487 | 1.605 |
82
+ | CPU | 261.92 | 242.76 | 350.76 | 356.96 |
83
 
 
84
 
 
85
 
86
  ## How to Get Started with the Model
87
 
88
  Use the code below to get started with the model.
89
 
90
+ Install the Inference Code
91
 
92
+ !pip install hdm2 --quiet
93
 
94
+ Run the HDM-2 model
95
 
96
+ # Load the model from HuggingFace into the GPU
97
 
98
+ <!---->
99
 
100
+ from hdm2 import HallucinationDetectionModel
101
 
102
+ <!---->
103
 
104
+ hdm_model = HallucinationDetectionModel()
105
 
106
+ <!---->
107
 
108
+ prompt = "Explain how the heart functions"
109
+ context = """
110
+ The heart is a muscular organ that pumps blood throughout the body.
111
+ It has four chambers: two atria and two ventricles.
112
+ """
113
+ response = """The heart is a vital six-chambered organ that pumps blood throughout the human body.
114
+ It contains three atria and three ventricles that work in harmony to circulate blood.
115
+ The heart primarily runs on glucose for energy and typically beats at a rate of 20-30 beats per minute in adults.
116
+ Located in the center-left of the chest, the heart is protected by the ribcage.
117
+ The average human heart weighs about 5 pounds and will beat approximately 2 million times in a lifetime.
118
+ """
119
+ # Ground truth:
120
+ # Hearts have 4 chambers (not 6), have 2 atria and 2 ventricles (not 3 each),
121
+ # normal heart rate is 60-100 BPM (not 20-30),
122
+ # average heart weighs ~10 oz (not 5 pounds),
123
+ # and beats ~2.5 billion times (not 2 million) in a lifetime
124
 
125
+ <!---->
126
 
127
+ # Detect hallucinations with default parameters
128
+ results = hdm_model.apply(prompt, context, response)
129
 
130
+ Print the results
131
 
132
+ # Utility function to help with printing the model output
133
+ def print_results(results):
134
+  #print(results)
135
+  # Print results
136
+  print(f"\nHallucination severity: {results['adjusted_hallucination_severity']:.4f}")
137
 
138
+ <!---->
139
 
140
+  # Print hallucinated sentences
141
+  if results['candidate_sentences']:
142
+      print("\nPotentially hallucinated sentences:")
143
+      is_ck_hallucinated = False
144
+      for sentence_result in results['ck_results']:
145
+          if sentence_result['prediction'] == 1:  # 1 indicates hallucination
146
+              print(f"- {sentence_result['text']} (Probability: {sentence_result['hallucination_probability']:.4f})")
147
+              is_ck_hallucinated = True
148
+      if not is_ck_hallucinated:
149
+        print("No hallucinated sentences detected.")
150
+  else:
151
+      print("\nNo hallucinated sentences detected.")
152
 
153
+ <!---->
154
 
155
+ print_results(results)
156
 
 
157
 
158
+ ### Model Description
159
+
160
+ - Model ID: HDM-2-3B
161
 
162
+ - Developed by: AIMon Labs, Inc.
163
 
164
+ - Model type:
165
 
166
+ - Language(s) (NLP): English
167
 
168
+ - License: CC BY-NC-SA 4.0
169
 
170
+ - License URL: <https://creativecommons.org/licenses/by-nc-sa/4.0/> 
171
 
 
172
 
173
+ ### Model Sources
174
 
175
+ - Code repository: [GitHub](https://github.com/aimonlabs/hallucination-detection-model)
176
 
177
+ - Model weights: [HuggingFace](https://huggingface.co/AimonLabs/hallucination-detection-model/)
178
 
179
+ - Paper: [arXiv](https://arxiv.org/abs/2504.07069)
180
 
181
+ - Demo: [Google Colab](https://colab.research.google.com/drive/1HclyB06twZVIxuK6AlyifRaf77vO5Yz#scrollTo=UVvBvBMWrDiv)
182
 
183
 
184
+ ## Uses
185
+
186
+ ### Direct Use
187
 
188
+ 1. Automating Hallucination or Inaccuracy Evaluations
189
 
190
+ 2. Assisting humans evaluating LLM responses for Hallucinations
191
 
192
+ 3. Phrase, word or sentence-level identification of where Hallucinations lie
193
 
194
+ 4. Selecting the best LLM with the least hallucinations for specific use cases
195
 
196
+ 5. Automatic re-prompting for better LLM responses
197
 
 
 
 
 
 
198
 
199
+ ## Limitations
200
 
201
+ - Annotations of "common knowledge" may still contain subjective judgments
202
 
 
203
 
204
+ ## Technical Specifications 
205
 
206
+ See paper for [more details](https://arxiv.org/abs/2504.07069)
207
 
 
208
 
209
+ ## Citation:
210
 
211
+ @misc {hdm-2-3b,
212
 
213
+     author       = {Paudel, A. and Lyzhov, A. and AIMon Labs},
214
 
215
+     title        = {HDM-2-3B: Hallucination Detection Model for Enterprise LLMs}, [Bibek Paudel](mailto:bibek@aimon.ai) 
216
 
217
+     year         = 2025,
218
 
219
+     url          = {<https://huggingface.co/aimonlabs/> ??????? [Preetam Joshi](mailto:preetam@aimon.ai)},
220
 
221
+     publisher    = {AIMon Labs, Inc.},
222
 
223
+     eprint       = {2504.07069},
224
 
225
+     archivePrefix= {arXiv},
226
 
227
+     primaryClass = {cs.CL},
228
 
229
+     url          = {https\://arxiv.org/abs/2504.07069}
230
 
231
+ }
232
 
 
233
 
234
+ ## Model Card Authors
235
 
236
+ @bibekp, @alexlyzhov-aimon, @pjoshi30, @aimonp
237
 
 
238
 
239
  ## Model Card Contact
240
 
241
+ <info@aimon.ai>, @aimonp, @pjoshi30