Skip to main content

Fact checking

This generative model - trained on FEVER - aims to predict whether a claim is consistent with the provided evidence.

Installation and simple usage

One quick way to install it is to type

pip install fact_checking

and then use the following code:

from transformers import (
    GPT2LMHeadModel,
    GPT2Tokenizer,
)

from fact_checking import FactChecker

_evidence = """
Justine Tanya Bateman (born February 19, 1966) is an American writer, producer, and actress . She is best known for her regular role as Mallory Keaton on the sitcom Family Ties (1982 -- 1989). Until recently, Bateman ran a production and consulting company, SECTION 5 . In the fall of 2012, she started studying computer science at UCLA.
"""

_claim = 'Justine Bateman is a poet.'

tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
fact_checking_model = GPT2LMHeadModel.from_pretrained('fractalego/fact-checking')
fact_checker = FactChecker(fact_checking_model, tokenizer)
is_claim_true = fact_checker.validate(_evidence, _claim)

print(is_claim_true)

which gives the output

False

Probabilistic output with replicas

The output can include a probabilistic component, obtained by iterating a number of times the output generation. The system generates an ensemble of answers and groups them by Yes or No.

For example, one can ask

from transformers import (
    GPT2LMHeadModel,
    GPT2Tokenizer,
)

from fact_checking import FactChecker

_evidence = """
Jane writes code for Huggingface.
"""

_claim = 'Jane is an engineer.'


tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
fact_checking_model = GPT2LMHeadModel.from_pretrained('fractalego/fact-checking')
fact_checker = FactChecker(fact_checking_model, tokenizer)
is_claim_true = fact_checker.validate_with_replicas(_evidence, _claim)

print(is_claim_true)

with output

{'Y': 0.95, 'N': 0.05}

Score on FEVER

The predictions are evaluated on a subset of the FEVER dev dataset, restricted to the SUPPORTING and REFUTING options:

precision recall F1
0.94 0.98 0.96

These results should be taken with many grains of salt. This is still a work in progress, and there might be leakage coming from the underlining GPT2 model unnaturally raising the scores.

Metadata

Release files for fact-checking 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fact-checking 0.0.3
File Size Uploaded
fact_checking-0.0.3.tar.gz 3.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fact-checking 0.0.3
File Interpreter ABI Platform
fact_checking-0.0.3-py2-none-any.whl Python 2 none any Details

Total release size: 8.6 kB

Release files / fact_checking-0.0.3.tar.gz

Download URL fact_checking-0.0.3.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
cd7a6b8f112a419df30d5fd01d5c815d4cfbe817d57303cc10043a2ed218110b
BLAKE2b-256 checksum
How to use checksums
c3edca12419db224518ab3ec6edf9c4c7c0867ea2323cf1387182aa567f33f72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.9

Release files / fact_checking-0.0.3-py2-none-any.whl

Download URL fact_checking-0.0.3-py2-none-any.whl
Size 5.0 kB
Tags Python 2
SHA-256 checksum
How to use checksums
a934b8e1021c78a02cd700ae7fb3fb8dea71d44c5a1815f97075dc710e84bf63
BLAKE2b-256 checksum
How to use checksums
6ef5cac4b1e2b877589d2e5b872cba1c873c4ff62fbaa2d9bb2f1276467d2aec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page