Upload FactGuard
Browse files- README.md +67 -0
- config.json +86 -0
- model.safetensors +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +16 -0
README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
library_name: transformers
|
| 6 |
+
tags:
|
| 7 |
+
- text-classification
|
| 8 |
+
- hallucination-detection
|
| 9 |
+
- grounding
|
| 10 |
+
- factual-consistency
|
| 11 |
+
- nli
|
| 12 |
+
- rag
|
| 13 |
+
datasets:
|
| 14 |
+
- stanfordnlp/snli
|
| 15 |
+
- nyu-mll/multi_nli
|
| 16 |
+
- anli
|
| 17 |
+
pipeline_tag: text-classification
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# 🛡️ FactGuard
|
| 21 |
+
|
| 22 |
+
Lightweight hallucination and grounding detection model. Checks whether a claim is supported by the given context.
|
| 23 |
+
|
| 24 |
+
Built on [ModernBERT-base](https://huggingface.co/answerdotai/ModernBERT-base) (149M params), fine-tuned on 1M+ NLI pairs from SNLI, MultiNLI, and ANLI.
|
| 25 |
+
|
| 26 |
+
**Classes:** Supported, Not Supported
|
| 27 |
+
|
| 28 |
+
## 🚀 Usage
|
| 29 |
+
|
| 30 |
+
```python
|
| 31 |
+
from transformers import pipeline
|
| 32 |
+
|
| 33 |
+
classifier = pipeline("text-classification", model="ENTUM-AI/FactGuard")
|
| 34 |
+
|
| 35 |
+
result = classifier({
|
| 36 |
+
"text": "Apple reported revenue of $94.8 billion in Q1 2024.",
|
| 37 |
+
"text_pair": "Apple's Q1 2024 revenue was $94.8 billion."
|
| 38 |
+
})
|
| 39 |
+
# [{'label': 'Supported', 'score': 0.99}]
|
| 40 |
+
|
| 41 |
+
result = classifier({
|
| 42 |
+
"text": "Apple reported revenue of $94.8 billion in Q1 2024.",
|
| 43 |
+
"text_pair": "Apple's revenue exceeded $100 billion."
|
| 44 |
+
})
|
| 45 |
+
# [{'label': 'Not Supported', 'score': 0.97}]
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
## 📊 Training Data
|
| 49 |
+
|
| 50 |
+
| Dataset | Samples |
|
| 51 |
+
|---------|---------|
|
| 52 |
+
| [stanfordnlp/snli](https://huggingface.co/datasets/stanfordnlp/snli) | ~550K |
|
| 53 |
+
| [nyu-mll/multi_nli](https://huggingface.co/datasets/nyu-mll/multi_nli) | ~393K |
|
| 54 |
+
| [anli](https://huggingface.co/datasets/anli) | ~163K |
|
| 55 |
+
|
| 56 |
+
1M+ NLI pairs mapped to binary grounding labels.
|
| 57 |
+
|
| 58 |
+
## 🔍 Use Cases
|
| 59 |
+
|
| 60 |
+
- **RAG pipelines** — verify LLM responses against source documents
|
| 61 |
+
- **Fact-checking** — detect unsupported claims in generated text
|
| 62 |
+
- **Content moderation** — flag hallucinated content before publishing
|
| 63 |
+
|
| 64 |
+
## ⚠️ Limitations
|
| 65 |
+
|
| 66 |
+
- English only
|
| 67 |
+
- Designed for single claim verification against a given context
|
config.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"ModernBertForSequenceClassification"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"bos_token_id": 50281,
|
| 8 |
+
"classifier_activation": "gelu",
|
| 9 |
+
"classifier_bias": false,
|
| 10 |
+
"classifier_dropout": 0.0,
|
| 11 |
+
"classifier_pooling": "mean",
|
| 12 |
+
"cls_token_id": 50281,
|
| 13 |
+
"decoder_bias": true,
|
| 14 |
+
"deterministic_flash_attn": false,
|
| 15 |
+
"dtype": "float32",
|
| 16 |
+
"embedding_dropout": 0.0,
|
| 17 |
+
"eos_token_id": 50282,
|
| 18 |
+
"global_attn_every_n_layers": 3,
|
| 19 |
+
"gradient_checkpointing": false,
|
| 20 |
+
"hidden_activation": "gelu",
|
| 21 |
+
"hidden_size": 768,
|
| 22 |
+
"id2label": {
|
| 23 |
+
"0": "Not Supported",
|
| 24 |
+
"1": "Supported"
|
| 25 |
+
},
|
| 26 |
+
"initializer_cutoff_factor": 2.0,
|
| 27 |
+
"initializer_range": 0.02,
|
| 28 |
+
"intermediate_size": 1152,
|
| 29 |
+
"label2id": {
|
| 30 |
+
"Not Supported": 0,
|
| 31 |
+
"Supported": 1
|
| 32 |
+
},
|
| 33 |
+
"layer_norm_eps": 1e-05,
|
| 34 |
+
"layer_types": [
|
| 35 |
+
"full_attention",
|
| 36 |
+
"sliding_attention",
|
| 37 |
+
"sliding_attention",
|
| 38 |
+
"full_attention",
|
| 39 |
+
"sliding_attention",
|
| 40 |
+
"sliding_attention",
|
| 41 |
+
"full_attention",
|
| 42 |
+
"sliding_attention",
|
| 43 |
+
"sliding_attention",
|
| 44 |
+
"full_attention",
|
| 45 |
+
"sliding_attention",
|
| 46 |
+
"sliding_attention",
|
| 47 |
+
"full_attention",
|
| 48 |
+
"sliding_attention",
|
| 49 |
+
"sliding_attention",
|
| 50 |
+
"full_attention",
|
| 51 |
+
"sliding_attention",
|
| 52 |
+
"sliding_attention",
|
| 53 |
+
"full_attention",
|
| 54 |
+
"sliding_attention",
|
| 55 |
+
"sliding_attention",
|
| 56 |
+
"full_attention"
|
| 57 |
+
],
|
| 58 |
+
"local_attention": 128,
|
| 59 |
+
"max_position_embeddings": 8192,
|
| 60 |
+
"mlp_bias": false,
|
| 61 |
+
"mlp_dropout": 0.0,
|
| 62 |
+
"model_type": "modernbert",
|
| 63 |
+
"norm_bias": false,
|
| 64 |
+
"norm_eps": 1e-05,
|
| 65 |
+
"num_attention_heads": 12,
|
| 66 |
+
"num_hidden_layers": 22,
|
| 67 |
+
"pad_token_id": 50283,
|
| 68 |
+
"position_embedding_type": "absolute",
|
| 69 |
+
"rope_parameters": {
|
| 70 |
+
"full_attention": {
|
| 71 |
+
"rope_theta": 160000.0,
|
| 72 |
+
"rope_type": "default"
|
| 73 |
+
},
|
| 74 |
+
"sliding_attention": {
|
| 75 |
+
"rope_theta": 10000.0,
|
| 76 |
+
"rope_type": "default"
|
| 77 |
+
}
|
| 78 |
+
},
|
| 79 |
+
"sep_token_id": 50282,
|
| 80 |
+
"sparse_pred_ignore_index": -100,
|
| 81 |
+
"sparse_prediction": false,
|
| 82 |
+
"tie_word_embeddings": true,
|
| 83 |
+
"transformers_version": "5.1.0",
|
| 84 |
+
"use_cache": false,
|
| 85 |
+
"vocab_size": 50368
|
| 86 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ca692bc1e264ae0d6febb14e04ea93452616592a2c1eb461c0e67fbdc75d4ee3
|
| 3 |
+
size 598439784
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"clean_up_tokenization_spaces": true,
|
| 4 |
+
"cls_token": "[CLS]",
|
| 5 |
+
"is_local": false,
|
| 6 |
+
"mask_token": "[MASK]",
|
| 7 |
+
"model_input_names": [
|
| 8 |
+
"input_ids",
|
| 9 |
+
"attention_mask"
|
| 10 |
+
],
|
| 11 |
+
"model_max_length": 8192,
|
| 12 |
+
"pad_token": "[PAD]",
|
| 13 |
+
"sep_token": "[SEP]",
|
| 14 |
+
"tokenizer_class": "TokenizersBackend",
|
| 15 |
+
"unk_token": "[UNK]"
|
| 16 |
+
}
|