This package provides standard and classifier-based short form QA evaluation methods
Project description
QA-Evaluation-Metrics
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.
Installation
To install the package, run the following command:
pip install qa-metrics
Usage
The python package currently provides four QA evaluation metrics.
Exact Match
from qa_metrics.em import em_match
reference_answer = ["Charles , Prince of Wales"]
candidate_answer = "Prince Charles"
match_result = ExactMatch(reference_answer, candidate_answer)
print("Exact Match: ", match_result)
F1 Score
from qa_metrics.f1 import f1_match
f1_stats = f1_score_with_precision_recall(reference_answer[0], candidate_answer)
print("F1 stats: ", f1_stats)
match_result = f1_match(reference_answer, candidate_answer, threshold=0.5)
print("F1 Match: ", match_result)
CFMatch
from qa_metrics.cfm import CFMatcher
question = "who will take the throne after the queen dies"
cfm = CFMatcher()
scores = cfm.get_scores(reference_answer, candidate_answer, question)
match_result = cfm.cf_match(reference_answer, candidate_answer, question)
print("Score: %s; CF Match: %s" % (scores, match_result))
Transformer Match
Our fine-tuned BERT model is on 🤗 Huggingface. Our Package also supports downloading and matching directly. More Matching transformer models will be available 🔥🔥🔥
from qa_metrics.transformerMacher import TransformerMatcher
question = "who will take the throne after the queen dies"
tm = TransformerMatcher("bert")
scores = tm.get_scores(reference_answer, candidate_answer, question)
match_result = tm.transformer_match(reference_answer, candidate_answer, question)
print("Score: %s; CF Match: %s" % (scores, match_result))
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contact
For any additional questions or comments, please contact [zli12321@umd.edu].
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for qa_metrics-0.1.19-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3dd865b3f963fdc6c453c707f15ff248101d4ead8aee87831f1042ea4d896808 |
|
MD5 | 60e81c933e4688e3cf1bd70baf4a0adf |
|
BLAKE2b-256 | c2b1701dbecd604a2e816a84ddd5666918932cc35a89d409208b8703d6ad71f3 |