Zongxia commited on
Commit
e7b9d79
•
1 Parent(s): 8765b38

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +101 -0
README.md ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ inference: false
3
+ license: mit
4
+ language:
5
+ - en
6
+ metrics:
7
+ - exact_match
8
+ - f1
9
+ - bertscore
10
+ pipeline_tag: text-classification
11
+ ---
12
+ # QA-Evaluation-Metrics
13
+
14
+ [![PyPI version qa-metrics](https://img.shields.io/pypi/v/qa-metrics.svg)](https://pypi.org/project/qa-metrics/)
15
+
16
+
17
+ QA-Evaluation-Metrics is a fast and lightweight Python package for evaluating question-answering models. It provides various basic metrics to assess the performance of QA models. Check out our paper [**CFMatcher**](https://arxiv.org/abs/2401.13170), a matching method going beyond token-level matching and is more efficient than LLM matchings but still retains competitive evaluation performance of transformer LLM models.
18
+
19
+
20
+ ## Installation
21
+
22
+ To install the package, run the following command:
23
+
24
+ ```bash
25
+ pip install qa-metrics
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ The python package currently provides four QA evaluation metrics.
31
+
32
+ #### Exact Match
33
+ ```python
34
+ from qa_metrics.em import em_match
35
+
36
+ reference_answer = ["Charles , Prince of Wales"]
37
+ candidate_answer = "Prince Charles"
38
+ match_result = em_match(reference_answer, candidate_answer)
39
+ print("Exact Match: ", match_result)
40
+ ```
41
+
42
+ #### Transformer Match
43
+ Our fine-tuned BERT model is this repository. Our Package also supports downloading and matching directly. distilroberta, distilbert, and roberta are also supported now! 🔥🔥🔥
44
+
45
+ ```python
46
+ from qa_metrics.transformerMatcher import TransformerMatcher
47
+
48
+ question = "who will take the throne after the queen dies"
49
+ tm = TransformerMatcher("distilbert")
50
+ scores = tm.get_scores(reference_answer, candidate_answer, question)
51
+ match_result = tm.transformer_match(reference_answer, candidate_answer, question)
52
+ print("Score: %s; CF Match: %s" % (scores, match_result))
53
+ ```
54
+
55
+ #### F1 Score
56
+ ```python
57
+ from qa_metrics.f1 import f1_match,f1_score_with_precision_recall
58
+
59
+ f1_stats = f1_score_with_precision_recall(reference_answer[0], candidate_answer)
60
+ print("F1 stats: ", f1_stats)
61
+
62
+ match_result = f1_match(reference_answer, candidate_answer, threshold=0.5)
63
+ print("F1 Match: ", match_result)
64
+ ```
65
+
66
+ #### CFMatch
67
+ ```python
68
+ from qa_metrics.cfm import CFMatcher
69
+
70
+ question = "who will take the throne after the queen dies"
71
+ cfm = CFMatcher()
72
+ scores = cfm.get_scores(reference_answer, candidate_answer, question)
73
+ match_result = cfm.cf_match(reference_answer, candidate_answer, question)
74
+ print("Score: %s; bert Match: %s" % (scores, match_result))
75
+ ```
76
+
77
+ If you find this repo avialable, please cite our paper:
78
+ ```bibtex
79
+ @misc{li2024cfmatch,
80
+ title={CFMatch: Aligning Automated Answer Equivalence Evaluation with Expert Judgments For Open-Domain Question Answering},
81
+ author={Zongxia Li and Ishani Mondal and Yijun Liang and Huy Nghiem and Jordan Boyd-Graber},
82
+ year={2024},
83
+ eprint={2401.13170},
84
+ archivePrefix={arXiv},
85
+ primaryClass={cs.CL}
86
+ }
87
+ ```
88
+
89
+
90
+ ## Updates
91
+ - [01/24/24] 🔥 The full paper is uploaded and can be accessed [here]([https://arxiv.org/abs/2310.14566](https://arxiv.org/abs/2401.13170)). The dataset is expanded and leaderboard is updated.
92
+ - Our Training Dataset is adapted and augmented from [Bulian et al](https://github.com/google-research-datasets/answer-equivalence-dataset). Our [dataset repo](https://github.com/zli12321/Answer_Equivalence_Dataset.git) includes the augmented training set and QA evaluation testing sets discussed in our paper.
93
+ - Now our model supports [distilroberta](https://huggingface.co/Zongxia/answer_equivalence_distilroberta), [distilbert](https://huggingface.co/Zongxia/answer_equivalence_distilbert), a smaller and more robust matching model than Bert!
94
+
95
+ ## License
96
+
97
+ This project is licensed under the [MIT License](LICENSE.md) - see the LICENSE file for details.
98
+
99
+ ## Contact
100
+
101
+ For any additional questions or comments, please contact [[email protected]].