CSE Roadmap

Core tier · about 4 hours · 11 parts

Part 2 of 11 · 2 min read

A claim either matches its source or it doesn't -- but "matches" needs a rule

Checking a claim against a context by eye is easy; writing code that does it reliably is not.

Think of a fact-checker who reads a news article next to its press-release source. A sentence that borrows the source's words checks out at a glance. A sentence that says almost the same thing in different words takes real judgment to verify.

In plain words: hallucination is generated content not grounded in training data or the input context, grounding is tying a claim to a source that can be checked, and faithfulness is whether an answer is actually supported by the context it was given -- and a faithfulness check tests faithfulness by comparing each claim's words against the context's words.

A worked example. The context is six policy sentences (warranty length, water damage, refunds, shipping, support hours, gift cards). The claim "The warranty lasts 24 months" shares every content word with the context sentence "The standard warranty lasts 24 months", so its support score is 1.0 -- fully supported. The claim "Premium support includes a dedicated phone line" shares almost no words with any context sentence, so its support score comes out under 0.5 -- correctly flagged as unsupported, because it's invented.

The key lines. From code/mini-faithful/faithful.py:

# from code/mini-faithful/faithful.py
def support_score(claim, context):
    ct = set(tokens(claim))
    return len(ct & set(tokens(context))) / len(ct) if ct else 1.0


def is_supported(claim, context, threshold=0.7, check_numbers=True, check_negation=True):
    if support_score(claim, context) < threshold:
        return False

Read it as: support_score divides the words the claim and context have in common by the total words in the claim. So a claim entirely covered by the context's vocabulary scores 1.0, regardless of word order. Then is_supported rejects anything below a 0.7 overlap threshold. It does this before it even looks at numbers or negation.

Hallucination, grounding, faithfulness

Hallucination is generated content that is not grounded in the model's training data or in the input context. Grounding is tying a claim to a source that can be checked. Faithfulness is whether the answer is supported by the provided context.

Example: "Premium support includes a dedicated phone line" has no grounding in the six-sentence context, so it is unfaithful even though it sounds like a plausible policy.