🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Commonsense Reasoning: Understanding the Implied

Natural Language ProcessingCommonsense Reasoning: Understanding the ImpliedđŸŸĸ Free Lesson

Commonsense Reasoning: Understanding the Implied

Module: Natural Language Processing | Difficulty: Advanced

What You'll Learn

  • 1Score multiple-choice commonsense options by length-normalized likelihood
  • 2Represent commonsense triples with a TransE embedding and compute its margin loss
  • 3Compare human and model accuracy on PIQA, HellaSwag, and WinoGrande
  • 4Explain why adversarial filtering changed benchmark difficulty

Commonsense reasoning is the ability to draw the conclusions humans never state: that ice melts in a warm room, that a wet floor makes walking risky. NLP models fail here because the knowledge is never written down, and the standard measurement is a four-way multiple-choice task where a system must rank the plausible continuation above three distractors. This lesson builds the scoring equations, the knowledge-graph alternative, and the numbers that show where models still lose to people.

Benchmarks and the Human Gap

BenchmarkYearItemsTaskHumanGPT-3 175B
PIQA202027,399Physical intuition94.979.2
HellaSwag201939,905Activity continuation95.678.3
WinoGrande201944,398Pronoun resolution86.777.3
CommonsenseQA201912,247Question answering88.975.6
SWAG2018113,016Situational choice87.776.4

PIQA (Bisk et al., 2020) asks for the physically sensible procedure, HellaSwag (Zellers et al., 2019) for the plausible sentence continuation, and WinoGrande (Sakaguchi et al., 2019) for the pronoun that binds correctly. All four are four-way tasks, so chance is 25 percent while humans sit in the high eighties or low nineties.

Why the distractors are hard

HellaSwag generated its wrong options with adversarial filtering: a discriminator repeatedly removes any distractor a model can already distinguish. That raised human accuracy to 95.6 while early models stayed near 57, a 38-point spread created purely by the generation procedure.

Two Families of Method

Neural approaches treat commonsense as a distribution learned from text and rank candidates by likelihood. Symbolic approaches instead store triples in a knowledge base such as ConceptNet 5.5, about 39 million edges, or ATOMIC (Sap et al., 2019), about 877,000 if-then rules over 21 inference types, and embed those triples so a missing link can be predicted.

Measuring the two families

Likelihood models are scored by accuracy over the four choices, knowledge-base models by mean reciprocal rank of the true tail, and the two numbers are not comparable, so papers must state which protocol they used.

Worked Code

python
import math
from collections import Counter, defaultdict

CORPUS = [
    "the bartender dried the glass and set it on the shelf",
    "the bartender poured the beer and wiped the counter",
    "she set the glass on the shelf after drying it",
    "he poured a drink and wiped the counter clean",
    "the glass fell off the shelf and shattered",
]


def ngram_lm(corpus, n=2):
    ctx, uni = defaultdict(Counter), Counter()
    for sent in corpus:
        toks = sent.split()
        uni.update(toks)
        for i in range(len(toks) - n + 1):
            ctx[" ".join(toks[i:i + n - 1])][toks[i]] += 1
    return ctx, uni, sum(uni.values())


CTX, UNI, TOTAL = ngram_lm(CORPUS)


def score(text, alpha=0.4):
    toks = text.split()
    lp, prev = 0.0, "<s>"
    for w in toks:
        c = CTX.get(prev, Counter())
        p = (c[w] + alpha) / (sum(c.values()) + alpha * len(UNI))
        lp += math.log(p)
        prev = w
    return lp / len(toks)


OPTIONS = {
    "A": "the glass and set it on the shelf",
    "B": "the glass",
    "C": "it on the shelf after drying it",
    "D": "the shelf and shattered",
}
ranked = sorted(((score(v), k) for k, v in OPTIONS.items()), reverse=True)
for s, k in ranked:
    print(k, round(s, 4), OPTIONS[k])
print("chosen:", ranked[0][1])
python
import math, random
random.seed(7)

KG = [("cup", "UsedFor", "drink"), ("knife", "UsedFor", "cut"),
      ("glass", "UsedFor", "drink"), ("hammer", "UsedFor", "nail"),
      ("cup", "AtLocation", "kitchen"), ("knife", "AtLocation", "kitchen")]

VOCAB = sorted({e for h, _, t in KG for e in (h, t)})
D, GAMMA, LR, EPOCHS = 8, 1.0, 0.05, 300
emb = {e: [random.uniform(-0.1, 0.1) for _ in range(D)] for e in VOCAB}
rel = {"UsedFor": [random.uniform(-0.1, 0.1) for _ in range(D)],
       "AtLocation": [random.uniform(-0.1, 0.1) for _ in range(D)]}


def sub(a, b):
    return [x - y for x, y in zip(a, b)]


def norm2(v):
    return sum(x * x for x in v)


def dist(h, r, t):
    """Squared TransE distance for entity names h and t under relation r."""
    return norm2(sub(sub(emb[h], rel[r]), emb[t]))


def sgd(h, r, t, hp, sign):
    # Gradient of -sign * || h + r - t ||^2 with respect to h, r, t.
    diff = sub(sub(emb[h], rel[r]), emb[t])
    hp_diff = sub(sub(emb[hp], rel[r]), emb[t])
    step_h, step_r, step_t = [], [], []
    for k in range(D):
        step_h.append(-sign * 2 * (diff[k] - hp_diff[k]))
        step_r.append(-sign * 2 * (diff[k] - hp_diff[k]))
        step_t.append(sign * 2 * (diff[k] - hp_diff[k]))
    for k in range(D):
        emb[h][k] -= LR * step_h[k]
        rel[r][k] -= LR * step_r[k]
        emb[t][k] -= LR * step_t[k]


for _ in range(EPOCHS):
    for h, r, t in KG:
        hp = random.choice([e for e in VOCAB if e != t])
        loss = max(0.0, GAMMA + dist(hp, r, t) - dist(h, r, t))
        if loss > 0:
            sgd(h, r, t, hp, 1.0)

ranks = []
for h, r, t in KG:
    scores = sorted(((dist(h, r, e), e) for e in VOCAB))
    ranks.append([e for _, e in scores].index(t) + 1)
mrr = sum(1.0 / r for r in ranks) / len(ranks)
print("ranks", ranks, "MRR", round(mrr, 3))

Real-World Applications

  • ConceptNet 5.5 carries about 39 million relations over millions of concepts, the largest general commonsense graph in open use.
  • ATOMIC stores roughly 877,000 if-then rules across 21 inference types such as xIntent and xEffect.
  • HellaSwag's adversarial filtering produced 39,905 items whose distractors a 2019 model could not separate, holding human accuracy at 95.6 percent.
  • PIQA's 27,399 physical-intuition questions still cap GPT-3 at 79.2 against a 94.9 human score.

💡Chance is 25 percent, not zero

Every benchmark here is four-choice, so a model at 78 percent is 3.1 times random guessing while humans at 95.6 are 3.8 times better; report lift over chance, not just accuracy.

Common Mistakes

Comparing accuracy across choice counts

Fix: Normalize by chance level: 25 percent for four-way tasks, 50 percent for binary, so scores are comparable

Scoring options by raw log probability

Fix: Divide by token count, otherwise a 6-token option loses to a 3-token option purely on length

Evaluating a knowledge base with accuracy

Fix: Use mean reciprocal rank, because link prediction is a retrieval problem over the whole entity set

Best Practices

  • Report accuracy together with lift over the 25 percent chance baseline
  • Use length-normalized log likelihood for every multiple-choice comparison
  • Separate in-distribution test sets from adversarially filtered ones when you claim progress

Key Takeaways

  • Four-way choice means chance is 25 percent, so 78.3 percent is 3.1 times random
  • Length normalization divides by |y|; without it the shortest option tends to win
  • TransE scores triples as the squared distance h + r - t with a margin loss of gamma = 1
  • On HellaSwag the model error rate of 21.7 percent is 4.93 times the human rate of 4.4 percent

Frequently Asked Questions

How big are the standard commonsense datasets?

PIQA has 27,399 items, HellaSwag 39,905, WinoGrande 44,398, and CommonsenseQA 12,247, all four-choice. On the knowledge side ConceptNet 5.5 holds about 39 million edges and ATOMIC about 877,000 rules.

Why do models look close to humans on accuracy but not on error?

Because accuracy compresses near the ceiling. GPT-3 at 78.3 percent and humans at 95.6 percent differ by 17.3 accuracy points, but their error rates are 21.7 and 4.4 percent, a ratio of 4.93 that raw accuracy hides.

Do knowledge bases or language models win today?

Likelihood models generally win on the four-way benchmarks, while knowledge bases remain useful for retrieval and for exposing which fact was missing. Hybrid systems that attach retrieved triples to the prompt recover part of the human gap.

Interview Questions

Q1: What is adversarial filtering?

A generation loop that removes any distractor a discriminator can already separate; on HellaSwag it lifted human accuracy to 95.6 while holding early models near 57

Q2: Why use mean reciprocal rank for ConceptNet link prediction?

Because the model must rank the true tail among thousands of entities; MRR averages 1/rank and reaches about 0.4 on strong TransE setups

CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-07

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Continue Learning

Suggested next tutorials based on this topic

Need Expert NLP Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement