PythiloLesson 6 of 12 · progress kept in this browser

Practice in Lab: Reject citations outside the supplied evidence set →

Reject citations outside the supplied evidence set

A citation is useful only if it points to evidence the system actually supplied and the user may access. A model can invent plausible identifiers, so validate the returned references against an authoritative evidence set before presenting an answer as grounded.

This local contract checks identifier membership and required references for claims. It does not verify that the cited passage supports the claim, a separate semantic and human-review problem. A citation validator must not turn an unsupported statement into a trusted one merely because its identifier has the correct format. Preserve document versions and source offsets for auditability.

allowed={"doc-1","doc-2"}
returned=["doc-1","invented"]
print([key for key in returned if key not in allowed])
Your task

Implement citation_errors(claims,allowed). Each claim has text and citations list. Return ordered strings "i:missing" if no citations and "i:unknown:key" for each distinct unknown id in that claim, preserving first occurrence. Empty claims return [].