What is a Unit in Verdict
mainA Unit is a wrapper around an LLM inference call with well-defined inputs and outputs. Units are the fundamental building blocks of LLM-as-a-Judge systems in Verdict. They support arbitrary dependency structures using the >> operator and can be configured using chainable directives.
Key Features
- Model Selection: Use
.via()to specify the model and parameters. - Prompt Specification: Use
.prompt()to define the template. - Structured Extraction: Use
.extract()to parse LLM responses (e.g., via regex). - Transformation: Use
.propagate()for arbitrary post-inference transformations. - Execution: Units can be executed in parallel with built-in client-side rate-limiting.
Anatomy of a Unit
A Unit consists of three schema components:
- InputSchema (optional): The data required from dependency units. Verdict performs automatic name-casting from previous outputs to this schema.
- ResponseSchema (required): The raw schema representing the response produced by the LLM inference call after extraction.
- OutputSchema (optional): The final processed data passed to the next unit. If not specified, it defaults to the
ResponseSchema.
JudgeUnit(DiscreteScale((1, 5)), name="CXEmpathyJudge")
.via('gpt-4o', retries=3, temperature=1.4)
.prompt("""
Score the following customer support conversation on empathy.
<conversation>
...
</conversation>
""")
.extract(RegexExtractor(pattern=RegexExtractor.FIRST_INT))
.propagate(lambda output: Schema.of(score=output.score / 5))