Skip to main content

Overview

Several Gaussia metrics (Context, Conversational, BestOf, Agentic) use an LLM-as-a-Judge pattern to evaluate AI responses. The Judge class handles prompt rendering, model invocation, and response parsing.

How it works

The Judge supports two evaluation modes:

Configuration

You configure the judge through the metric’s constructor parameters:

Parameters

Choosing how the schema is bound

Judging needs no tools, so the default strategy asks for the schema through response_format and declares none. This matters on self-hosted OpenAI-compatible servers: vLLM rejects a request that carries an empty tools array with HTTP 400. Metrics use that default. A custom metric built on Judge directly can inject the other strategy, for a provider that exposes structured output only through tool calling:
Never leave the route to the provider’s own default. Bound without naming it, a model served behind the HuggingFace router ignored the schema entirely and generated prose until it hit forty thousand completion tokens — so the request failed on length, which reads as a model failure and is a binding failure. Both strategies above worked on that same provider once named. This is why the strategy is a parameter rather than a detail, and why every model-driven component of Roast Me takes one too.
Both strategies request include_raw, so a bound runnable answers with a mapping carrying the message itself beside the parsed value. parsed(answer, Schema) from the same module is the other half of that contract: it returns the instance, or None when the provider answered off-format. None is a thing that happens, and what it costs belongs to the caller — a generator can re-ask, a reading of one passage can contribute nothing, and a gate that must return a number has neither option.

Compatible models

The Judge works with any LangChain-compatible chat model:

Reasoning extraction

When available, the Judge automatically extracts reasoning content from the model’s response. This is supported by models that provide chain-of-thought reasoning (e.g., OpenAI’s reasoning models, Anthropic’s extended thinking). The reasoning is returned as the first element of the tuple from judge.check() and is used internally for logging and debugging.
For best results with use_structured_output=True, use models that natively support structured outputs like GPT-4o or Gemini. For open-source models, use_structured_output=False with regex extraction is more reliable.