Study: Citing Requirements in LLM Code Enables Hallucination Detection but Reduces Determinism
Forced citations yield 86-88% hallucination detection but lower output consistency across models.
A new empirical study from arXiv investigates the trade-off between output determinism and verifiability in LLM-generated code under Spec-Driven Development (SDD). The author, Subham Panda, tested three frameworks: traceSDD (mandatory per-line REQ identifiers), Spec Kit (artifact-level user stories), and OpenSpec (post-hoc trace maps). Experiments involved two frontier models—Claude Sonnet 4.6 (240 implementations across 4 conditions) and GLM-5-turbo (600 implementations)—measuring lexical similarity and automated hallucination detection rates (TDR). The pre-registered analysis reveals a consistent cross-model trade-off: the uncited condition produces significantly higher determinism (Claude: d=-0.76, p=0.003; GLM: d=-0.72, p<0.001), while only the cited condition enables any automated hallucination detection (TDR: Claude 86.4%, GLM 88.0%, vs 0% for all alternatives, with 0% false positive rate).
Notably, traceSDD (cited) significantly outperforms Spec Kit on determinism (Claude: d=0.47, p=0.049; GLM: d=0.42, p=0.003) but not OpenSpec (Claude: d=0.18, p=0.44; GLM: d=0.14, p=0.32). This suggests that finer-grained citation annotations improve determinism over coarser artifact-level traces, but still fall short of the consistency achieved without any citations. The findings establish that citation annotations inherently trade determinism for verifiability, and this trade-off generalizes across model architectures. For practitioners, this means choosing between predictable code generation and the ability to automatically detect hallucinations—a decision that depends on whether reliability or auditability is the higher priority.
- traceSDD's per-line citations enabled 86-88% automated hallucination detection with 0% false positive rate across both models.
- Uncited condition had significantly higher determinism (Cohen's d ≈ -0.74) compared to cited condition, across Claude and GLM.
- traceSDD outperformed Spec Kit on determinism (d=0.47, 0.42) but not OpenSpec, indicating that trace granularity influences consistency.
Why It Matters
Citations in LLM code generation provide verifiability but reduce reproducibility—teams must choose based on their priority.