Eval Compare
Compare the same prompt's outputs from several models or prompt versions side by side, with a word diff, a scorecard, and a preference vote.
Overview
Eval Compare puts two to four answers to the same prompt next to each other: different models, prompt versions, or settings. It can show what changed word by word against a baseline, score each answer on the metrics you measured, list the checks each one passed, and collect a person's preference.
It shows the results you pass. Running the models and scoring them is your application's work.
Anatomy
- HeaderThe prompt, the expected answer, the case switcher, and the Differences toggle
- ColumnOne per candidate: its label, note, output, checks, and Prefer
- ScorecardA table with a row per metric and a column per candidate
- FooterTie, and the announcement of the vote, when you collect votes
Installing eval-compare brings Button and Toggle along as registry dependencies.
Behavior
Differences
Differences compares every column with the baseline, word by word. Added words are tinted and removed words are struck through, and each column counts both. The first candidate is the baseline until a person chooses another with its "Compare against" link. diffWords is exported if you need the same comparison elsewhere.
Very long outputs fall back to marking the whole text as changed instead of blocking the page.
Scorecard
Each metric names the direction that wins with better. The best value in a row gets a dot and medium weight. A row where every candidate ties, or with fewer than two values, has no best. A missing value shows as a dash. Pass format to show units such as seconds or dollars.
Checks and votes
Passed checks keep a neutral mark and failed ones are red. Passing onVote shows Prefer under each column and Tie in the footer. Pressing the current choice again clears it, and onVote receives null.
Cases
With caseIndex, caseCount, and onCaseChange, the header shows a switcher such as "Case 2 of 12". Pass the new case's prompt and candidates when it changes.
Layout
Columns sit side by side when the component is wide enough and stack when it is narrow. Rows line up across columns, so outputs of different lengths still start their checks at the same height.
Accessibility
The comparison is a group named Comparison, not a landmark, so several on one page stay distinct. Each candidate is an article named by its label. Added and removed words use ins and del. The scorecard is a table with row and column headers, and the best value is announced as best. Prefer and Differences are toggle buttons that report whether they are pressed, and a vote is announced.
Installation
Usage
import { EvalCompare, type EvalMetric } from "@/components/ai/eval-compare"
const metrics: EvalMetric[] = [
{ key: "correctness", label: "Correctness", better: "higher" },
{ key: "latency", label: "Latency", better: "lower", format: (ms) => `${ms} ms` },
]
<EvalCompare
prompt={run.prompt}
candidates={run.outputs.map((output) => ({
id: output.model,
label: output.model,
output: output.text,
metrics: output.scores,
}))}
metrics={metrics}
vote={vote}
onVote={setVote}
/>Examples
Two prompt versions
Differences starts on, so the change between versions is the first thing a reviewer sees.
API reference
EvalCompare
Accepts native div props beyond those listed.