Fig. 1 in words
The swap test · 7 675 real claim–sentence pairs · same data as code 05
1 One claim, right and wrong sentence
- “Arctic sea ice is also falling at an accelerated rate.”
- right sentence · 4 of 4 readers: SUPPORTS
- “Accelerated decline in the Arctic sea ice.”
- words: SUPPORTS ✓ · +overlap: SUPPORTS ✓
- wrong sentence · from another claim
- “In the U.S., Lyme is most common in the New England and Mid-Atlantic states and parts of Wisconsin…”
- words: SUPPORTS ✕ · +overlap: NOT ENOUGH INFO ✓
- pair 7011 · same folds and models as Code 05
2 Balanced accuracy
- - - chance 0.333
- claim only 0.461 · evid. only 0.438 · claim+ evid. 0.489 · +overlap 0.500
- 5 folds grouped by claim
3 The swap test
- % answered SUPPORTS or REFUTES · - - gold labels 35.8%
- words: right sentence 40.3 · swapped 39.8
- + overlap: right sentence 40.4 · swapped 27.6
4 Claim words → REFUTES
- claim-only model, top weights
- #1 no · #2 isn · #3 kills · #4 not · #5 life · #6 insignificant
- red: a negation (isn = isn’t)
- fitted on all 7 675 pairs
01 Verification Definition
- Input: a claim and a sentence; output SUPPORTS, REFUTES or NOT ENOUGH INFO
- FEVER: 185 445 claims written from Wikipedia sentences (Thorne et al. 2018)
- CLIMATE-FEVER: 7 675 real claim–sentence pairs; each claim stays in one fold
Grouping by claim keeps a claim’s five sentences out of its own training data (Sprint 20).
02 A Score Is a Check Claim fails
- Claim: “a verifier that scores well is checking the evidence”
- Never shown the evidence: 0.461 balanced accuracy (chance 0.333)
- Claim + evidence model, wrong sentence: SUPPORTS or REFUTES 39.8% vs 40.3%
Word models on one data set; Schuster et al. found the same with BERT on FEVER.
03 Shortcuts Evidence
- FEVER: a claim-only BERT reached 61.7%, majority baseline 33.3% (Schuster et al. 2019)
- NLI: the hypothesis alone gets about 67% of SNLI (Gururangan et al. 2018)
- Real claims show the same kind of cue: no · isn’t · not
Geirhos et al. (2020): shortcuts do well on the usual tests and fail to transfer.
04 The Swap Test Method
- Give each claim another claim’s sentence
- Only 5.1% share a Wikipedia article with the claim’s own evidence
- Schuster et al.’s symmetric set: a leading verifier fell from 81.8% to 58.7%
Strict, not perfect: a few may still touch the topic.
05 Try It Yourself PY 3.13.18 · SKLEARN 1.9.1
sprint47_checking_a_claim_against_evidence.py
import json, re
import numpy as np
from scipy.sparse import csr_matrix, hstack
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import balanced_accuracy_score
from sklearn.model_selection import GroupKFold
with open("climate-fever.jsonl", encoding="utf-8") as f:
rows = [json.loads(line) for line in f]
P = [(i, r["claim"], e["evidence"], e["evidence_label"])
for i, r in enumerate(rows) for e in r["evidences"]]
g, C, E, y = (np.array(x) for x in zip(*P))
NEI = "NOT_ENOUGH_INFO"
def overlap(c, e): # share of words the two have in common
a, b = (set(re.findall(r"[a-z]{3,}", s.lower())) for s in (c, e))
return len(a & b) / max(1, len(a | b))
def run(parts, swap=False): # c claim, e evidence, o overlap
pred = np.empty(len(y), dtype=object)
for tr, te in GroupKFold(5).split(y, y, g): # by claim
vc = TfidfVectorizer(min_df=2, sublinear_tf=True).fit(C[tr])
ve = TfidfVectorizer(min_df=2, sublinear_tf=True).fit(E[tr])
def X(rc, rev):
cols = []
if "c" in parts: cols.append(vc.transform(C[rc]))
if "e" in parts: cols.append(ve.transform(E[rev]))
if "o" in parts: cols.append(csr_matrix(
[[overlap(C[i], E[j])] for i, j in zip(rc, rev)]))
return hstack(cols).tocsr()
ev = np.roll(te, 5 * (len(te) // 10)) if swap else te
m = LogisticRegression(max_iter=5000, class_weight="balanced")
pred[te] = m.fit(X(tr, tr), y[tr]).predict(X(te, ev))
return pred
print(len(y), "claim-evidence pairs | gold SUPPORTS or REFUTES:",
f"{np.mean(y != NEI):.1%}")
print("balanced accuracy, 5 folds grouped by claim (chance 0.333)")
for name, parts in [("claim only", "c"), ("evidence only", "e"),
("claim + evidence", "ce"), ("+ overlap", "ceo")]:
print(f" {name:<17} {balanced_accuracy_score(y, run(parts)):.3f}")
print("says SUPPORTS/REFUTES: true pairs | evidence of another claim")
for name, parts in [("claim + evidence", "ce"), ("+ overlap", "ceo")]:
t, s = (np.mean(run(parts, sw) != NEI) for sw in (False, True))
print(f" {name:<17} {t:.1%} | {s:.1%}")
Output, as printed on the image
7675 claim-evidence pairs | gold SUPPORTS or REFUTES: 35.8%
balanced accuracy, 5 folds grouped by claim (chance 0.333)
claim only 0.461
evidence only 0.438
claim + evidence 0.489
+ overlap 0.500
says SUPPORTS/REFUTES: true pairs | evidence of another claim
claim + evidence 40.3% | 39.8%
+ overlap 40.4% | 27.6%
Run it. sprint47_checking_a_claim_against_evidence.py · versions, data and steps
Check: 40.3 − 39.8 = 0.5 points · 40.4 − 27.6 = 12.8 points · 0.461 − 0.333 = 0.128
06 General Notes Practice
- Report claim-only and evidence-only scores beside the full one
- A FEVER-trained model scored 38.78% on CLIMATE-FEVER claims, DISPUTED left out (Diggelmann et al. 2020)
Bridge: run a swap test before trusting a verifier; one overlap feature cut swapped answers from 39.8% to 27.6%.
07 Mini Project Hands-on
- Swap only within the same Wikipedia article and rerun
- Add word pairs (bigrams) to the claim-only model: does it climb?
- Print the ten claim words with the largest SUPPORTS weights
Then try the overlap feature with a list of stop words removed.
R Trusted Sources
- Thorne et al. (2018) FEVER, NAACL, 809–819
- Schuster et al. (2019) Towards Debiasing Fact Verification Models, EMNLP-IJCNLP, 3419–3425
- Gururangan et al. (2018) Annotation Artifacts in Natural Language Inference Data, NAACL, 107–112
- Geirhos et al. (2020) Shortcut learning in deep neural networks, Nat. Mach. Intell. 2, 665–673
- Diggelmann et al. (2020) CLIMATE-FEVER, arXiv 2012.00614
