Grounded citations
Fraction of cited [doc:id] markers that exist in the retrieved set. 0 if nothing is cited.
How it gets gamed
Models spray citations. Every invented id lowers the score, repeats count once, and a completion with more than max_citations distinct ids scores 0. See reward hacking.
Use it
Compile a Verifiable-outcome loop, then replace its verify_environment with this one. Put "allowed_docs" in each JSONL row’s metadata.
Compile a loop for it: Specialized Tool Agents · Inkling 2 Small
grounded_citations.pyverify_environment
def verify_environment(completion: str, metadata: dict | None = None) -> float: """metadata["allowed_docs"]: ids the retriever returned. Optional metadata["max_citations"] (default 5).""" import re allowed = set((metadata or {}).get("allowed_docs") or []) cap = int((metadata or {}).get("max_citations", 5)) cited = set(re.findall(r"\[doc:([A-Za-z0-9._-]+)\]", completion)) if not cited or len(cited) > cap: return 0.0 return len(cited & allowed) / len(cited)
Test cases (run on every build)
"Looping helps reasoning [doc:a1]." with {"allowed_docs":["a1","b2"]} → 1
"Claim [doc:a1] and [doc:zz]." with {"allowed_docs":["a1"]} → 0.5
"No citations here." with {"allowed_docs":["a1"]} → 0
"[doc:a][doc:b][doc:c]" with {"allowed_docs":["a","b","c"],"max_citations":2} → 0