lytang commited on
Commit
8a4f0c2
·
verified ·
1 Parent(s): c453092

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +102 -0
README.md ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ pipeline_tag: text-classification
5
+ ---
6
+ # Model Summary
7
+
8
+ This is a fact-checking model from our work:
9
+
10
+ 📃 [**MiniCheck: Efficient Fact-Checking of LLMs on Grounding Documents**](https://arxiv.org/pdf/2404.10774.pdf) ([GitHub Repo](https://github.com/Liyan06/MiniCheck))
11
+
12
+ The model is based on DeBERTa-v3-Large that predicts a binary label - 1 for supported and 0 for unsupported.
13
+ The model is doing predictions on the *sentence-level*. It takes as input a document and a sentence and determine
14
+ whether the sentence is supported by the document: **MiniCheck-Model(document, claim) -> {0, 1}**
15
+
16
+
17
+ MiniCheck-DeBERTa-v3-Large is fine tuned from `microsoft/deberta-v3-large` ([He et al., 2023](https://arxiv.org/pdf/2111.09543.pdf))
18
+ on the combination of 35K data:
19
+ - 21K ANLI data ([Nie et al., 2020](https://aclanthology.org/2020.acl-main.441.pdf))
20
+ - 14K synthetic data generated from scratch in a structed way (more details in the paper).
21
+
22
+
23
+ ### Model Variants
24
+ We also have other two MiniCheck model variants:
25
+ - [lytang/MiniCheck-Flan-T5-Large](https://huggingface.co/lytang/MiniCheck-Flan-T5-Large)
26
+ - [lytang/MiniCheck-RoBERTa-Large](https://huggingface.co/lytang/MiniCheck-RoBERTa-Large)
27
+
28
+
29
+ ### Model Performance
30
+ The performance of these models is evaluated on our new collected benchmark (unseen by our models during training), [LLM-AggreFact](https://huggingface.co/datasets/lytang/LLM-AggreFact),
31
+ from 10 recent human annotated datasets on fact-checking and grounding LLM generations. MiniCheck-DeBERTa-v3-Large outperform all
32
+ exisiting specialized fact-checkers with a similar scale by a large margin but is 2% worse than our best model MiniCheck-Flan-T5-Large, which
33
+ is on par with GPT-4 but 400x cheaper. See full results in our work.
34
+
35
+ Note: We only evaluated the performance of our models on real claims -- without any human intervention in
36
+ any format, such as injecting certain error types into model-generated claims. Those edited claims do not reflect
37
+ LLMs' actual behaviors.
38
+
39
+
40
+ # Model Usage Demo
41
+
42
+ Please first clone our [GitHub Repo](https://github.com/Liyan06/MiniCheck) and install necessary packages from `requirements.txt`.
43
+
44
+
45
+ ### Below is a simple use case
46
+
47
+ ```python
48
+ from minicheck.minicheck import MiniCheck
49
+ doc = "A group of students gather in the school library to study for their upcoming final exams."
50
+ claim_1 = "The students are preparing for an examination."
51
+ claim_2 = "The students are on vacation."
52
+
53
+ # model_name can be one of ['roberta-large', 'deberta-v3-large', 'flan-t5-large']
54
+ scorer = MiniCheck(model_name='deberta-v3-large', device=f'cuda:0', cache_dir='./ckpts')
55
+ pred_label, raw_prob, _, _ = scorer.score(docs=[doc, doc], claims=[claim_1, claim_2])
56
+
57
+ print(pred_label) # [1, 0]
58
+ print(raw_prob) # [0.9786180257797241, 0.01138285268098116]
59
+ ```
60
+
61
+ ### Test on our [LLM-AggreFact](https://huggingface.co/datasets/lytang/LLM-AggreFact) Benchmark
62
+
63
+ ```python
64
+ import pandas as pd
65
+ from datasets import load_dataset
66
+ from minicheck.minicheck import MiniCheck
67
+
68
+ # load 13K test data
69
+ df = pd.DataFrame(load_dataset("lytang/LLM-AggreFact")['test'])
70
+ docs = df.doc.values
71
+ claims = df.claim.values
72
+
73
+ scorer = MiniCheck(model_name='deberta-v3-large', device=f'cuda:0', cache_dir='./ckpts')
74
+ pred_label, raw_prob, _, _ = scorer.score(docs=docs, claims=claims) # ~ 15 mins, depending on hardware
75
+ ```
76
+
77
+ To evalaute the result on the benchmark
78
+ ```python
79
+ from sklearn.metrics import balanced_accuracy_score
80
+
81
+ df['preds'] = pred_label
82
+ result_df = pd.DataFrame(columns=['Dataset', 'BAcc'])
83
+ for dataset in df.dataset.unique():
84
+ sub_df = df[df.dataset == dataset]
85
+ bacc = balanced_accuracy_score(sub_df.label, sub_df.preds) * 100
86
+ result_df.loc[len(result_df)] = [dataset, bacc]
87
+ result_df.loc[len(result_df)] = ['Average', result_df.BAcc.mean()]
88
+ result_df.round(1)
89
+ ```
90
+
91
+ # Citation
92
+
93
+ ```
94
+ @misc{tang2024minicheck,
95
+ title={MiniCheck: Efficient Fact-Checking of LLMs on Grounding Documents},
96
+ author={Liyan Tang and Philippe Laban and Greg Durrett},
97
+ year={2024},
98
+ eprint={2404.10774},
99
+ archivePrefix={arXiv},
100
+ primaryClass={cs.CL}
101
+ }
102
+ ```