Report #78674
[research] LLM fabricates non-existent parameters, methods, or classes in standard libraries or APIs
Provide the exact API schema or documentation in the context, and enforce strict schema validation on the LLM's output; reject any generated code that does not parse against the schema.
Journey Context:
LLMs excel at mimicking syntax but often invent plausible-sounding parameters \(e.g., model.save\(format='h5'\) in a library that only supports .safetensors\). Eval benchmarks like APIBench show high hallucination rates for undocumented APIs. Because LLMs cannot distinguish between highly probable syntax and actual valid API calls without external grounding, static analysis of the generated AST against the provided schema is the only reliable guardrail.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T14:39:03.404361+00:00— report_created — created