Upload ClaimLens Stage B RAG Verifier Model
Browse files- .gitattributes +1 -0
- README.md +119 -0
- config.json +41 -0
- model.safetensors +3 -0
- tokenizer.json +3 -0
- tokenizer_config.json +19 -0
- training_args.bin +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
- hi
|
| 5 |
+
- kn
|
| 6 |
+
license: apache-2.0
|
| 7 |
+
tags:
|
| 8 |
+
- rag
|
| 9 |
+
- hallucination-detection
|
| 10 |
+
- xlm-roberta
|
| 11 |
+
- nli
|
| 12 |
+
- multilingual
|
| 13 |
+
- fact-checking
|
| 14 |
+
- text-classification
|
| 15 |
+
pipeline_tag: text-classification
|
| 16 |
+
widget:
|
| 17 |
+
- text: "Antigravity is an AI development platform."
|
| 18 |
+
text_pair: "Antigravity is an AI development platform created by Deepmind engineers."
|
| 19 |
+
- text: "The deadline is 30 June 2026."
|
| 20 |
+
text_pair: "Antigravity is an AI development platform created by Deepmind engineers."
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
# ClaimLens: Multilingual RAG Hallucination Verifier
|
| 24 |
+
|
| 25 |
+
**ClaimLens** is a fine-tuned multilingual (`English`, `Hindi`, `Kannada`) claim-level hallucination verifier for Retrieval-Augmented Generation (RAG) pipelines based on `xlm-roberta-base`.
|
| 26 |
+
|
| 27 |
+
It evaluates generated answers claim-by-claim against retrieved context passages and classifies each into one of three factual grounding states:
|
| 28 |
+
- **`Correct` (Label 0):** Retrieved evidence entails the claim.
|
| 29 |
+
- **`Incorrect` (Label 1):** Retrieved evidence contradicts the claim.
|
| 30 |
+
- **`Unverified` (Label 2):** Evidence neither confirms nor denies the claim (unsupported / baseless).
|
| 31 |
+
|
| 32 |
+
---
|
| 33 |
+
|
| 34 |
+
## Model Architecture & Training Protocol
|
| 35 |
+
|
| 36 |
+
* **Base Model:** `xlm-roberta-base`
|
| 37 |
+
* **Task:** Sentence-Pair Classification (`<s> claim </s></s> evidence </s>`)
|
| 38 |
+
* **Two-Stage Supervised Fine-Tuning:**
|
| 39 |
+
1. **Stage A (NLI Warm-up):** Trained on 60,000 NLI pairs (20k each for English, Hindi, and Kannada from `facebook/xnli` and `Divyanshu/indicxnli`).
|
| 40 |
+
2. **Stage B (RAG Fine-Tuning):** Fine-tuned on RAGTruth claim-level data (English) + machine-translated Hindi and Kannada subsets, using **Class-Weighted Cross-Entropy** to mitigate the ~90% majority class skew.
|
| 41 |
+
|
| 42 |
+
---
|
| 43 |
+
|
| 44 |
+
## Evaluation Results
|
| 45 |
+
|
| 46 |
+
Evaluated against the RAG test sets across languages:
|
| 47 |
+
|
| 48 |
+
| Metric | English (`en`) | Hindi (`hi`) | Kannada (`kn`) |
|
| 49 |
+
| :--- | :---: | :---: | :---: |
|
| 50 |
+
| **Macro-F1** | **0.4888** | **0.6086** | **0.5662** |
|
| 51 |
+
| **Hallucination F1** | **0.3676** | **0.8162** | **0.8057** |
|
| 52 |
+
| **Accuracy** | **76.61%** | **61.00%** | **56.67%** |
|
| 53 |
+
| **IndicGLUE WNLI (Hindi)** | — | **94.37%** | — |
|
| 54 |
+
|
| 55 |
+
*Significant performance improvement over Majority Class (0.1667) and TF-IDF baselines (0.4059 - 0.4270).*
|
| 56 |
+
|
| 57 |
+
---
|
| 58 |
+
|
| 59 |
+
## Quickstart & Usage
|
| 60 |
+
|
| 61 |
+
### Using Hugging Face Transformers
|
| 62 |
+
|
| 63 |
+
```python
|
| 64 |
+
import torch
|
| 65 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 66 |
+
|
| 67 |
+
model_id = "FaustDerLegende/RAGVERIFIER"
|
| 68 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 69 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_id)
|
| 70 |
+
model.eval()
|
| 71 |
+
|
| 72 |
+
claim = "Antigravity is an AI development platform."
|
| 73 |
+
evidence = "Antigravity is an AI development platform created by Deepmind engineers."
|
| 74 |
+
|
| 75 |
+
# Tokenize sentence-pair (claim, evidence)
|
| 76 |
+
inputs = tokenizer(
|
| 77 |
+
claim,
|
| 78 |
+
evidence,
|
| 79 |
+
truncation="only_second",
|
| 80 |
+
max_length=384,
|
| 81 |
+
return_tensors="pt"
|
| 82 |
+
)
|
| 83 |
+
|
| 84 |
+
with torch.no_grad():
|
| 85 |
+
logits = model(**inputs).logits
|
| 86 |
+
probs = torch.softmax(logits, dim=-1)[0]
|
| 87 |
+
|
| 88 |
+
id2label = model.config.id2label
|
| 89 |
+
for i, prob in enumerate(probs):
|
| 90 |
+
print(f"{id2label[i]}: {prob.item():.4f}")
|
| 91 |
+
|
| 92 |
+
predicted_class = id2label[torch.argmax(probs).item()]
|
| 93 |
+
print(f"
|
| 94 |
+
Final Verdict: {predicted_class}")
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
### Using Hugging Face Pipeline
|
| 98 |
+
|
| 99 |
+
```python
|
| 100 |
+
from transformers import pipeline
|
| 101 |
+
|
| 102 |
+
classifier = pipeline(
|
| 103 |
+
"text-classification",
|
| 104 |
+
model="FaustDerLegende/RAGVERIFIER",
|
| 105 |
+
tokenizer="FaustDerLegende/RAGVERIFIER"
|
| 106 |
+
)
|
| 107 |
+
|
| 108 |
+
result = classifier({
|
| 109 |
+
"text": "Antigravity is an AI development platform.",
|
| 110 |
+
"text_pair": "Antigravity is an AI development platform created by Deepmind engineers."
|
| 111 |
+
})
|
| 112 |
+
print(result)
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
---
|
| 116 |
+
|
| 117 |
+
## Citation & Acknowledgment
|
| 118 |
+
|
| 119 |
+
Developed as part of the **ClaimLens** Multilingual Hallucination Detection project, adapting datasets from [RAGTruth (Niu et al.)](https://github.com/ParticleMedia/RAGTruth), [IndicXNLI (Aggarwal et al.)](https://huggingface.co/datasets/Divyanshu/indicxnli), and [IndicGLUE](https://huggingface.co/datasets/ai4bharat/indic_glue).
|
config.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_cross_attention": false,
|
| 3 |
+
"architectures": [
|
| 4 |
+
"XLMRobertaForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"bos_token_id": 0,
|
| 8 |
+
"classifier_dropout": null,
|
| 9 |
+
"dtype": "float32",
|
| 10 |
+
"eos_token_id": 2,
|
| 11 |
+
"hidden_act": "gelu",
|
| 12 |
+
"hidden_dropout_prob": 0.1,
|
| 13 |
+
"hidden_size": 768,
|
| 14 |
+
"id2label": {
|
| 15 |
+
"0": "Correct",
|
| 16 |
+
"1": "Incorrect",
|
| 17 |
+
"2": "Unverified"
|
| 18 |
+
},
|
| 19 |
+
"initializer_range": 0.02,
|
| 20 |
+
"intermediate_size": 3072,
|
| 21 |
+
"is_decoder": false,
|
| 22 |
+
"label2id": {
|
| 23 |
+
"Correct": 0,
|
| 24 |
+
"Incorrect": 1,
|
| 25 |
+
"Unverified": 2
|
| 26 |
+
},
|
| 27 |
+
"layer_norm_eps": 1e-05,
|
| 28 |
+
"max_position_embeddings": 514,
|
| 29 |
+
"model_type": "xlm-roberta",
|
| 30 |
+
"num_attention_heads": 12,
|
| 31 |
+
"num_hidden_layers": 12,
|
| 32 |
+
"output_past": true,
|
| 33 |
+
"pad_token_id": 1,
|
| 34 |
+
"position_embedding_type": "absolute",
|
| 35 |
+
"problem_type": "single_label_classification",
|
| 36 |
+
"tie_word_embeddings": true,
|
| 37 |
+
"transformers_version": "5.20.2",
|
| 38 |
+
"type_vocab_size": 1,
|
| 39 |
+
"use_cache": false,
|
| 40 |
+
"vocab_size": 250002
|
| 41 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c5074cbdd38a89ed0d834f8c9c0305a5e621dd66f85d8fec3e7837dbae3e5965
|
| 3 |
+
size 1112208084
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c554c8acbec4ce21df5b0a2adfc7c5214224315810a8e4307c895b1e683b1127
|
| 3 |
+
size 17098182
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": true,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "<s>",
|
| 5 |
+
"cls_token": "<s>",
|
| 6 |
+
"eos_token": "</s>",
|
| 7 |
+
"is_local": true,
|
| 8 |
+
"local_files_only": false,
|
| 9 |
+
"mask_token": "<mask>",
|
| 10 |
+
"max_length": 128,
|
| 11 |
+
"model_max_length": 512,
|
| 12 |
+
"pad_token": "<pad>",
|
| 13 |
+
"sep_token": "</s>",
|
| 14 |
+
"stride": 0,
|
| 15 |
+
"tokenizer_class": "XLMRobertaTokenizer",
|
| 16 |
+
"truncation_side": "right",
|
| 17 |
+
"truncation_strategy": "only_second",
|
| 18 |
+
"unk_token": "<unk>"
|
| 19 |
+
}
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ae0bda57a3f4afc6cb9894eb3b387e608582b42eafeee7c3c677f8ffe52cd7cb
|
| 3 |
+
size 5265
|