Skip to main content

Aa library to evaluate faithfulness (factual correctness) of abstractive summaries.

Project description

Faithfulness

An easy-to-use library to evaluate faithfulness (factual correctness) of abstractive summaries. Faithfulness is computed by comparing the summary with the original source document.

This library includes multiple faithfulness metrics based on:

  • BERTScore
  • Entailment
  • Question Generation & Question Answering framework (QGQA)
  • Named Entity Recognition (NER)
  • Open Information Extraction (OpenIE)
  • Semantic Role Labeling (SRL)
  • Sentence Similarity (SentSim)

Installation

  1. $ conda create -n my_project python=3.8 This creates a new virtual environment for your project with conda. You can activate it with $ conda activate my_project.
  2. $ conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=10.1 -c pytorch Please install PyTorch by following the instructions here. Make sure to install the CUDA variant that matches the CUDA version of your GPU.
  3. $ pip install faithfulness This installs the faithfulness library and it's dependencies. Read more about the dependencies below.

All faithfulness metrics are model-based. Some models have to be installed manually:

  • Download the SRL model here and save it in your project. e.g. /models/srl_model.tar.gz
  • Download a spacy model: $ python -m spacy download en_core_web_sm
  • Download CoreNLP: import stanza && stanza.install_corenlp()

Usage

from faithfulness import QGQA

qgqa = QGQA()
summary = "Lorem ipsum dolor sit amet"
source = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam ..."
faithfulness, info = qgqa.score(summary, source)

More examples can be found here.

Metric evaluation

We evaluated all faithfulness metrics by correlating them with human judgements on the XSUM dataset (link). You will soon be able to read more about the evaluation in our paper. (Master's thesis)

Method Pearson (r) Spearman (p)
BERTScore 0.501 0.486
Entailment 0.366 0.422
SentSim 0.392 0.389
SRL 0.393 0.377
NER 0.252 0.259
QGQA 0.252 0.258
OpenIE 0.169 0.185

Dependencies

By running $ pip install faithfulness you will install this library as well as the following dependencies:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

faithfulness-0.0.2.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

faithfulness-0.0.2-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file faithfulness-0.0.2.tar.gz.

File metadata

  • Download URL: faithfulness-0.0.2.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.8.11

File hashes

Hashes for faithfulness-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c215fb1d680eb2d1d7f298999278674b0ffcbfa3d2597621df0c70e51f54fe5f
MD5 8ba5c59c71f10f367b331bcf00e1be9c
BLAKE2b-256 2681645b95721d1473cd335079b0ccb57f22b61ef9f7388689d04ead69944273

See more details on using hashes here.

File details

Details for the file faithfulness-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: faithfulness-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.8.11

File hashes

Hashes for faithfulness-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 381c2dab58c6af2352c99daec493bcdd5c1b1819a2de4be7be30803e49937540
MD5 9aaa95a08fc956e92fcaa96008b1d41d
BLAKE2b-256 00c7d97d54bea94970dc321b6610a2a0f2db28e9216902fd18222f8b1fa0e65a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page