Skip to main content

No project description provided

Project description

SummaC: Summary Consistency Detection

This repository contains the code for TACL2021 paper: SummaC: Re-Visiting NLI-based Models for Inconsistency Detection in Summarization

We release: (1) the trained SummaC models, (2) the SummaC Benchmark and data loaders, (3) training and evaluation scripts.

Installing/Using SummaC

[Update] Thanks to @Aktsvigun for the help, we now have a pip package, making it easy to install the SummaC models:

pip install summac

The two trained models SummaC-ZS and SummaC-Conv are implemented in model_summac (link). Once the package is installed, the models can be used like this:

Example use

from summac.model_summac import SummaCZS, SummaCConv

model_zs = SummaCZS(granularity="sentence", model_name="vitc", device="cpu") # If you have a GPU: switch to: device="cuda"
model_conv = SummaCConv(models=["vitc"], bins='percentile', granularity="sentence", nli_labels="e", device="cpu", start_file="default", agg="mean")

document = """Scientists are studying Mars to learn about the Red Planet and find landing sites for future missions.
One possible site, known as Arcadia Planitia, is covered instrange sinuous features.
The shapes could be signs that the area is actually made of glaciers, which are large masses of slow-moving ice.
Arcadia Planitia is in Mars' northern lowlands."""

summary1 = "There are strange shape patterns on Arcadia Planitia. The shapes could indicate the area might be made of glaciers. This makes Arcadia Planitia ideal for future missions."
score_zs1 = model_zs.score([document], [summary1])
score_conv1 = model_conv.score([document], [summary1])
print("[Summary 1] SummaCZS Score: %.3f; SummacConv score: %.3f" % (score_zs1["scores"][0], score_conv1["scores"][0])) # [Summary 1] SummaCZS Score: 0.582; SummacConv score: 0.536

summary2 = "There are strange shape patterns on Arcadia Planitia. The shapes could indicate the area might be made of glaciers."
score_zs2 = model_zs.score([document], [summary2])
score_conv2 = model_conv.score([document], [summary2])
print("[Summary 2] SummaCZS Score: %.3f; SummacConv score: %.3f" % (score_zs2["scores"][0], score_conv2["scores"][0])) # [Summary 2] SummaCZS Score: 0.877; SummacConv score: 0.709

We recommend using the SummaCConv models, as experiments from the paper show it provides better predictions. Two notebooks provide experimental details: SummaC - Main Results.ipynb for the main results (Table 2) and SummaC - Additional Experiments.ipynb for additional experiments (Tables 1, 3, 4, 5, 6) from the paper.

SummaC Benchmark

The SummaC Benchmark consists of 6 summary consistency datasets that have been standardized to a binary classification task. The datasets included are:


% Positive is the percentage of positive (consistent) summaries. IAA is the inter-annotator agreement (Fleiss Kappa). Source is the dataset used for the source documents (CNN/DM or XSum). # Summarizers is the number of summarizers (extractive and abstractive) included in the dataset. # Sublabel is the number of labels in the typology used to label summary errors.

The data-loaders for the benchmark are included in benchmark.py (link). Each dataset in the benchmark downloads automatically on first run. To load the benchmark:

from summac.benchmark import SummaCBenchmark
benchmark_val = SummaCBenchmark(benchmark_folder="/path/to/summac_benchmark/", cut="val")
frank_dataset = benchmark_val.get_dataset("frank")
print(frank_dataset[300]) # {"document: "A Darwin woman has become a TV [...]", "claim": "natalia moon , 23 , has become a tv sensation [...]", "label": 0, "cut": "val", "model_name": "s2s", "error_type": "LinkE"}

Cite the work

If you make use of the code, models, or algorithm, please cite our paper.

@article{Laban2022SummaCRN,
  title={SummaC: Re-Visiting NLI-based Models for Inconsistency Detection in Summarization},
  author={Philippe Laban and Tobias Schnabel and Paul N. Bennett and Marti A. Hearst},
  journal={Transactions of the Association for Computational Linguistics},
  year={2022},
  volume={10},
  pages={163-177}
}

Contributing

If you'd like to contribute, or have questions or suggestions, you can contact us at phillab@berkeley.edu. All contributions welcome, for example helping make the benchmark more easily downloadable, or improving model performance on the benchmark.

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

summac-0.0.4.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

summac-0.0.4-py3-none-any.whl (31.0 kB view details)

Uploaded Python 3

File details

Details for the file summac-0.0.4.tar.gz.

File metadata

  • Download URL: summac-0.0.4.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for summac-0.0.4.tar.gz
Algorithm Hash digest
SHA256 dcb0add41f40510371a1da9915d77e4a6fc05b160385fffbdfb9340afe6fceb5
MD5 24245fef8fb6895b72ad127d236aae25
BLAKE2b-256 c7d4b863cf246df4d835e81790da3a7960cf3d5fa9efbb4c902d10190252113d

See more details on using hashes here.

File details

Details for the file summac-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: summac-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 31.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for summac-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b6da2a3597e5025ef83c83c86a62032ba6475430673aa28bdb3765202899261c
MD5 2f753dc1bd1fcda9fdbfd1cfc00b99ae
BLAKE2b-256 3a8b7383e47daa893e87c475bda5e1a91974c5e10e559c75874545f83f1ebe96

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