Home

Awesome

AlignScore

This is the repository for AlignScore, a metric for automatic factual consistency evaluation of text pairs introduced in
AlignScore: Evaluating Factual Consistency with a Unified Alignment Function
Yuheng Zha, Yichi Yang, Ruichen Li and Zhiting Hu
ACL 2023

Factual consistency evaluation is to evaluate whether all the information in b is contained in a (b does not contradict a). For example, this is a factual inconsistent case:

And this is a factual consistent case:

Factual consistency evaluation can be applied to many tasks like Summarization, Paraphrase and Dialog. For example, large language models often generate hallucinations when summarizing documents. We wonder if the generated text is factual consistent to its original context.

Leaderboards

We introduce two leaderboards that compare AlignScore with similar-sized metrics and LLM-based metrics, respectively.

Leaderboard --- compare with similar-sized metrics

We list the performance of AlignScore as well as other metrics on the SummaC (includes 6 datasets) and TRUE (includes 11 datasets) benchmarks, as well as other popular factual consistency datasets (include 6 datasets).

RankMetricsSummaC*TRUE**Other Datasets***Average****PaperCode
1AlignScore-large88.683.849.373.9:page_facing_up:(Zha et al. 2023):octocat:
2AlignScore-base87.482.544.971.6:page_facing_up:(Zha et al. 2023):octocat:
3QAFactEval83.879.442.468.5:page_facing_up:(Fabbri et al. 2022):octocat:
4UniEval84.678.041.568.0:page_facing_up:(Zhong et al. 2022):octocat:
5SummaC-CONV81.078.734.264.6:page_facing_up:(Laban et al. 2022):octocat:
6BARTScore80.973.434.863.0:page_facing_up:(Yuan et al. 2022):octocat:
7CTC81.272.435.363.0:page_facing_up:(Deng et al. 2022):octocat:
8SummaC-ZS79.078.230.462.5:page_facing_up:(Laban et al. 2022):octocat:
9ROUGE-278.172.427.959.5:page_facing_up:(Lin 2004):octocat:
10ROUGE-177.472.028.659.3:page_facing_up:(Lin 2004):octocat:
11ROUGE-L77.371.828.359.1:page_facing_up:(Lin 2004):octocat:
12QuestEval72.571.425.056.3:page_facing_up:(Scialom et al. 2021):octocat:
13BLEU76.367.324.656.1:page_facing_up:(Papineni et al. 2002):octocat:
14DAE66.865.735.155.8:page_facing_up:(Goyal and Durrett 2020):octocat:
15BLEURT69.271.924.955.4:page_facing_up:(Sellam et al. 2020):octocat:
16BERTScore72.168.621.954.2:page_facing_up:(Zhang et al. 2020):octocat:
17SimCSE67.470.323.853.8:page_facing_up:(Gao et al. 2021):octocat:
18FactCC68.862.721.250.9:page_facing_up:(Kryscinski et al. 2020):octocat:
19BLANC65.164.014.447.8:page_facing_up:(Vasilyev et al. 2020):octocat:
20NER-Overlap60.459.318.946.2:page_facing_up:(Laban et al. 2022):octocat:
21MNLI47.960.43.137.2:page_facing_up:(Williams et al. 2018):octocat:
22FEQA48.352.2-1.932.9:page_facing_up:(Durmus et al. 2020):octocat:

* SummaC Benchmark: [Paper] | [Github]. We report AUC ROC on the SummaC benchmark.

** TRUE Benchmark: [Paper] | [Github]. We report AUC ROC on the TRUE benchmark.

*** Besides the SummaC and TRUE benchmarks, we also include other popular factual consistency evaluation datasets: XSumFaith, SummEval, QAGS-XSum, QAGS-CNNDM, FRANK-XSum, FRANK-CNNDM and SamSum. We compute the Spearman Correlation coefficients between the human annotated score and the metric predicted score, following common practice.

**** To rank these metrics, we simply compute the average performance of SummaC, TRUE and Other Datasets.

Leaderboard --- compare with LLM-based metrics

We also show the performance comparison with large-language-model based metrics below. The rank is based on the average Spearman Correlation coefficients on SummEval, QAGS-XSum and QAGS-CNNDM datasets.*

RankMetricsBase ModelSummEvalQAGS-XSUMQAGS-CNNDMAveragePaperCode
1AlignScore-largeRoBERTa-l (355M)46.657.273.959.3:page_facing_up:(Zha et al. 2023):octocat:
2G-EVAL-4GPT450.753.768.557.6:page_facing_up:(Liu et al. 2023):octocat:
3AlignScore-baseRoBERTa-b (125M)43.451.969.054.8:page_facing_up:(Zha et al. 2023):octocat:
4FActScore (modified)**GPT3.5-d03 + GPT3.5-turbo52.651.257.653.8:page_facing_up:(Min et al. 2023):octocat:*
5ChatGPT (Chen et al. 2023)GPT3.5-turbo42.753.352.749.6:page_facing_up:(Yi Chen et al. 2023):octocat:
6GPTScoreGPT3.5-d0345.922.764.444.3:page_facing_up:(Fu et al. 2023):octocat:
7GPTScoreGPT3-d0146.122.363.944.1:page_facing_up:(Fu et al. 2023):octocat:
8G-EVAL-3.5GPT3.5-d0338.640.651.643.6:page_facing_up:(Liu et al. 2023):octocat:
9ChatGPT (Gao et al. 2023)GPT3.5-turbo41.630.448.940.3:page_facing_up:(Gao et al. 2023)-

* We notice that evaluating factual consistency using GPT-based models is expensive and slow. And we need human labor to interpret the response (generally text) to numerical scores. Therefore, we only benchmark on 3 popular factual consistency evaluation datasets: SummEval, QAGS-XSum and QAGS-CNNDM.

** We use a modified version of FActScore retrieval+ChatGPT where we skip the retrieval stage and use the context documents in SummEval, QAGS-XSUM, and QAGS-CNNDM directly. As samples in theses datasets do not have "topics", we make a small modification to the original FActScore prompt and do not mention topic when not available. See our fork of FActScore for more details.

Introduction

The AlignScore metric is an automatic factual consistency evaluation metric built with the following parts:

We assume there are two inputs to the metric, namely context and claim. And the metric evaluates whether the claim is factual consistent with the context. The output of AlignScore is a single numerical value, which shows the degree of the factual consistency.

Installation

Our models are trained and evaluated using PyTorch 1.12.1. We recommend using this version to reproduce the results.

  1. Please first install the right version of PyTorch before installing alignscore.
  2. You can install alignscore by cloning this repository and pip install ..
  3. After installing alignscore, please use python -m spacy download en_core_web_sm to install the required spaCy model (we use spaCy for sentenization).

Evaluating Factual Consistency

To evaluate the factual consistency of the claim w.r.t. the context, simply use the score method of AlignScore.

from alignscore import AlignScore

scorer = AlignScore(model='roberta-base', batch_size=32, device='cuda:0', ckpt_path='/path/to/checkpoint', evaluation_mode='nli_sp')
score = scorer.score(contexts=['hello world.'], claims=['hello world.'])

model: the backbone model of the metric. Now, we only provide the metric trained on RoBERTa

batch_size: the batch size of the inference

device: which device to run the metric

ckpt_path: the path to the checkpoint

evaluation_mode: choose from 'nli_sp', 'nli', 'bin_sp', 'bin'. nli and bin refer to the 3-way and binary classficiation head, respectively. sp indicates if the chunk-sentence splitting method is used. nli_sp is the default setting of AlignScore

Checkpoints

We provide two versions of the AlignScore checkpoints: AlignScore-base and AlignScore-large. The -base model is based on RoBERTa-base and has 125M parameters. The -large model is based on RoBERTa-large and has 355M parameters.

AlignScore-base: https://huggingface.co/yzha/AlignScore/resolve/main/AlignScore-base.ckpt

AlignScore-large: https://huggingface.co/yzha/AlignScore/resolve/main/AlignScore-large.ckpt

Training

You can use the above checkpoints directly for factual consistency evaluation. However, if you wish to train an alignment model from scratch / on your own data, use train.py.

python train.py --seed 2022 --batch-size 32 \
--num-epoch 3 --devices 0 1 2 3 \
--model-name roberta-large -- ckpt-save-path ./ckpt/ \
--data-path ./data/training_sets/ \
--max-samples-per-dataset 500000

--seed: the random seed for initialization

--batch-size: the batch size for training

--num-epoch: training epochs

--devices: which devices to train the metric, a list of GPU ids

--model-name: the backbone model name of the metric, default RoBERTa-large

--ckpt-save-path: the path to save the checkpoint

--training-datasets: the names of the training datasets

--data-path: the path to the training datasets

--max-samples-per-dataset: the maximum number of samples from a dataset

Benchmarking

Our benchmark includes the TRUE and SummaC benchmark as well as several popular factual consistency evaluation datasets.

To run the benchmark, a few additional dependencies are required and can be installed with pip install -r requirements.txt. Additionally, some depedencies are not available as packages and need to be downloaded manually (please see python benchmark.py --help for instructions).

Note installing summac may cause dependency conflicts with alignscore. Please reinstall alignscore to force the correct dependency versions.

The relevant arguments for evaluating AlignScore are:

--alignscore: evaluation the AlignScore metric

--alignscore-model: the name of the backbone model (either 'roberta-base' or 'roberta-large')

--alignscore-ckpt: the path to the saved checkpoint

--alignscore-eval-mode: the evaluation mode, defaults to nli_sp

--device: which device to run the metric, defaults to cuda:0

--tasks: which tasks to benchmark, e.g., SummEval, QAGS-CNNDM, ...

For the baselines, please see python benchmark.py --help for details.

Training datasets download

Most datasets are downloadable from Huggingface (refer to generate_training_data.py). Some datasets that needed to be imported manually are now also avaialable on Huggingface (See Issue).

Evaluation datasets download

The following table shows the links to the evaluation datasets mentioned in the paper

Benchmark/DatasetLink
SummaChttps://github.com/tingofurro/summac
TRUEhttps://github.com/google-research/true
XSumFaithhttps://github.com/google-research-datasets/xsum_hallucination_annotations
SummEvalhttps://github.com/tanyuqian/ctc-gen-eval/blob/master/train/data/summeval.json
QAGS-Xsumhttps://github.com/tanyuqian/ctc-gen-eval/blob/master/train/data/qags_xsum.json
QAGS-CNNDMhttps://github.com/tanyuqian/ctc-gen-eval/blob/master/train/data/qags_cnndm.json
FRANK-XSumhttps://github.com/artidoro/frank
FRANK-CNNDMhttps://github.com/artidoro/frank
SamSumhttps://github.com/skgabriel/GoFigure/blob/main/human_eval/samsum.jsonl

Citation

If you find the metric and this repo helpful, please consider cite:

@inproceedings{zha-etal-2023-alignscore,
    title = "{A}lign{S}core: Evaluating Factual Consistency with A Unified Alignment Function",
    author = "Zha, Yuheng  and
      Yang, Yichi  and
      Li, Ruichen  and
      Hu, Zhiting",
    booktitle = "Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)",
    month = jul,
    year = "2023",
    address = "Toronto, Canada",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2023.acl-long.634",
    pages = "11328--11348",
    abstract = "Many text generation applications require the generated text to be factually consistent with input information. Automatic evaluation of factual consistency is challenging. Previous work has developed various metrics that often depend on specific functions, such as natural language inference (NLI) or question answering (QA), trained on limited data. Those metrics thus can hardly assess diverse factual inconsistencies (e.g., contradictions, hallucinations) that occur in varying inputs/outputs (e.g., sentences, documents) from different tasks. In this paper, we propose AlignScore, a new holistic metric that applies to a variety of factual inconsistency scenarios as above. AlignScore is based on a general function of information alignment between two arbitrary text pieces. Crucially, we develop a unified training framework of the alignment function by integrating a large diversity of data sources, resulting in 4.7M training examples from 7 well-established tasks (NLI, QA, paraphrasing, fact verification, information retrieval, semantic similarity, and summarization). We conduct extensive experiments on large-scale benchmarks including 22 evaluation datasets, where 19 of the datasets were never seen in the alignment training. AlignScore achieves substantial improvement over a wide range of previous metrics. Moreover, AlignScore (355M parameters) matches or even outperforms metrics based on ChatGPT and GPT-4 that are orders of magnitude larger.",
}