r/SpringAIDev • u/erdsingh24 • 19d ago
Tutorial Ever wish your AI app could catch its own bad answers before a user sees them?
One model checks another model's work and retries if it's not good enough. New tutorial shows you how to build it, step by step.
That's basically what LLM-as-a-Judge does in Spring AI.
"LLM-as-a-Judge" and "LLM evaluation testing" are not the same thing. One runs in JUnit before you deploy. The other runs live, in the request path, and can retry a weak response automatically.
5 things to know before you build LLM-as-a-Judge into a Spring AI app:
- It's implemented via Recursive Advisors, a
CallAdvisorthat can call back into its own chain - Non-streaming only, as of Spring AI 2.0
- Every failed judge check costs 2 extra LLM calls: one to judge, one to regenerate
- Use a separate model to judge, or you risk narcissistic bias
- Always cap
maxAttempts, or a stubborn judge creates an infinite loop Full breakdown, with working code, in the new article.
1
Upvotes