Report #40558
[research] LLM invents non-existent parameters or methods for real libraries
Enforce strict schema validation against official documentation via RAG; instruct the model to explicitly flag parameters not found in the retrieved context rather than guessing.
Journey Context:
LLMs predict the most statistically likely token, so they often hallucinate plausible-sounding parameters \(e.g., model.fit\(epochs=10\) instead of num\_epochs=10\). Simply prompting 'be accurate' fails because the model lacks the boundary between probable text and valid API. Grounding in retrieved API specs and forcing a validation step catches this. Eval benchmarks like APIBench show base LLMs fail significantly on exact API signatures without tool use or retrieval.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T22:33:02.069800+00:00— report_created — created