Skip to content

How to rank documents with an LLM

At the end of this page you will have ranked a folder of documents with an LLM judge and read which places are firm and which are ties.

The method in one paragraph: write what “better” means as a rubric in plain words; have a model compare the documents two at a time against it; combine the verdicts into one ranking; and give each document a range of places it could hold, so you can see where the judge has not separated two documents. Supposing does all four. Comparing pairs works better than asking the model to score each document alone: see Pairwise comparison or scoring each item.

One short paragraph: what matters most, what matters less, what to ignore.

Terminal window
cat > rubric.md <<'RUBRIC'
Which proposal makes the strongest case for funding? Weigh impact (how many people benefit, and how much)
about twice as much as feasibility. Ignore formatting and length.
RUBRIC

No folder at hand? This makes proposals, four short funding proposals:

Terminal window
mkdir -p proposals
printf '# Solar panels for rural schools\nRooftop solar on 40 rural schools. 60%% lower power bills, 4-year payback, three pilot schools already running. Budget $1.2M.\n' > proposals/solar-schools.md
printf '# An app for everything\nWe will build a super-app. Details to follow.\n' > proposals/app-for-everything.md
printf '# Extend library hours\nOpen until 10pm on weekdays for $80k a year. Surveys show 300 students a night would come.\n' > proposals/library-hours.md
printf '# Protected bike lanes\n2km on Main Street for $400k, with a traffic study attached.\n' > proposals/bike-lanes.md

From the command line, on a folder with one document per .md, .txt or .html file (a JSONL or CSV file with one item per row works too):

Terminal window
supposing rank ./proposals --rubric rubric.md --judge mock

--judge mock is a fake judge that costs nothing, for checking the flow; its order means nothing. For a real ranking, leave it out to use the default judge on OpenRouter (OPENROUTER_API_KEY), or use --judge claude_cli with a Claude Code login. Choosing a judge compares them.

From Python:

from supposing import rank
docs = {"a.md": "Solar panels for 40 rural schools, 4-year payback.",
"b.md": "An app for everything. Details to follow.",
"c.md": "Late opening hours at the town library, three evenings a week."}
ranking = rank(docs, "Which proposal makes the strongest case for funding?", judge="mock")
print(ranking.summary)
for row in ranking.leaderboard:
print(row["rank"], "could be %d-%d" % (row["rank_lo"], row["rank_hi"]), row["item_id"])

From a coding agent, connect the MCP server and ask it to rank: Set up your coding agent.

The result starts with one sentence, the verdict, then one row per document. could be 2-4 means the document belongs somewhere from 2nd to 4th with 90% confidence. Where two ranges overlap, the judge has not told those documents apart: treat them as a tie, or add rounds. The last line grades the judge’s consistency. Reading the result and Judge checks explain both.

By default each document meets 8 opponents, so a ranking makes about 4 judge calls per document: 160 calls for 40 documents. --dry-run prints the calls and the price before anything runs. What a run costs has the detail.