# LLM-as-a-Verifier

> Fine-grained agent feedback read from the logprob distribution, not a single score token

- Category: Evaluation & Production Ops / Evaluation & Red-Teaming
- Language: Python
- Licence: MIT
- Repository: https://github.com/llm-as-a-verifier/llm-as-a-verifier
- Website: https://llm-as-a-verifier.com
- Canonical page: https://ai-tldr.dev/tools/llm-as-a-verifier/

## In short

LLM-as-a-Verifier is a general-purpose framework for getting fine-grained feedback out of a judge model. The usual LLM-as-a-judge setup asks for a score and reads back whichever token the model sampled, which throws away almost everything the model knew. It sits in the Evaluation & Red-Teaming category of the Evaluation & Production Ops tools and is open-source, written in Python and licensed MIT.

## Overview

LLM-as-a-Verifier is a general-purpose framework for getting fine-grained feedback out of a judge model. The usual LLM-as-a-judge setup asks for a score and reads back whichever token the model sampled, which throws away almost everything the model knew. This project keeps that information: it uses a fine-grained scoring granularity, takes the expectation over the full logprob distribution of the score tokens rather than the argmax, and scales quality by repeating the evaluation and decomposing the rubric into separate criteria.

What comes out is a continuous reward rather than a verdict, which makes it usable in three places at once: test-time scaling (pick the best of N candidate answers or trajectories), progress tracking (watch a long-horizon agent's trajectory score move), and reinforcement learning (use the verifier's output as the reward signal). The API is deliberately small — `select` picks the best candidate given a problem and a criteria dict, and `compare` exposes the raw pairwise rewards underneath it.

The project reports state-of-the-art results across agentic benchmarks including Terminal-Bench, SWE-Bench Verified, MedAgentBench and RoboRewardBench, and documents the method in an accompanying paper. Version 0.2.0 added a prefix-cache optimisation the project measures at roughly 3.4× fewer uncached input tokens on trajectory-heavy benchmarks, a `deepseek-v4-flash` verifier backend, a Terminal-Bench 2.1 self-verification benchmark and token accounting. It runs against a hosted API or any OpenAI-compatible server that returns logprobs, including a local vLLM.

## What it does

- Scores taken as the expectation over the full logprob distribution of score tokens, not the sampled token
- Criteria decomposition and repeated evaluation to scale feedback quality
- Best-of-N candidate selection via select(), with the underlying pairwise rewards exposed through compare()
- Works as a reward signal for reinforcement learning as well as for test-time scaling and progress tracking
- Modality-agnostic and agent-agnostic — one verification framework across benchmarks rather than a per-task harness
- Runs against hosted APIs or any OpenAI-compatible logprob-returning server, including a local vLLM

## Getting started

Install the package and point it at a model that returns logprobs — either a hosted key in .env, or a local OpenAI-compatible server.

1. Install

   Published on PyPI as llm-verifier; an editable install from a clone works for development.

```bash
pip install llm-verifier

# or, from a clone:
pip install -e .
```

2. Point it at a model

   Set DEEPSEEK_API_KEY or VERTEX_API_KEY in .env, or serve a local model that returns logprobs and set the base URL.

```bash
vllm serve Qwen/Qwen3.5-9B
export OPENAI_BASE_URL=http://localhost:8000/v1
```

3. Run a best-of-N selection

   select() takes the problem, the candidate answers and a criteria dict, and returns the winning index alongside continuous scores for every candidate.

```python
import llm_verifier

problem = "Write a function that reverses a string."
candidates = [
    "def rev(s): return s[::-1]", "def rev(s): return s", "def rev(s): return ''.join(sorted(s))",
]

result = llm_verifier.select(
    problem=problem,
    candidates=candidates,
    criteria={"Correctness": "Does the code actually reverse the string?"},
)
print(result.index)   # index of the best candidate: 0
print(result.scores)  # candidate scores: [0.73104, 0.38446, 0.38449]
```

4. Get raw pairwise rewards

   select() is built on a pairwise reward model; compare() returns the fine-grained rewards for a single comparison directly.

```python
reward_a, reward_b = llm_verifier.compare(...)
```

## When to use it

- Reach for it when a binary pass/fail judge is too coarse to rank near-identical agent trajectories
- Reach for it to add test-time scaling: sample N candidate answers and pick the one the verifier scores highest
- Reach for it as the reward model in an RL loop, where a continuous signal trains better than a thresholded one
- Reach for it to track whether a long-horizon agent is actually making progress rather than only whether it finished
