pairsort 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .venv/
5
+ .pytest_cache/
6
+ dist/
7
+ build/
8
+ .env
9
+ .env.*
10
+ *.key
11
+ secrets*
12
+ .pairsort_cache/
13
+ examples/data/.cache/
pairsort-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Eric Florenzano
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,140 @@
1
+ Metadata-Version: 2.5
2
+ Name: pairsort
3
+ Version: 0.1.0
4
+ Summary: Rank anything with AI judges: many small pairwise questions, coupled into one calibrated ranking (PKPD / Bradley-Terry)
5
+ Project-URL: Homepage, https://ericflo.github.io/pairsort/
6
+ Project-URL: Documentation, https://ericflo.github.io/pairsort/quickstart.html
7
+ Project-URL: Source, https://github.com/ericflo/pairsort
8
+ Project-URL: Issues, https://github.com/ericflo/pairsort/issues
9
+ Author-email: Eric Florenzano <floguy@gmail.com>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: bradley-terry,calibration,evaluation,jev,llm-as-judge,openrouter,pairwise-comparison,pkpd,ranking,sorting,typesafe
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
25
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
26
+ Classifier: Typing :: Typed
27
+ Requires-Python: >=3.10
28
+ Requires-Dist: httpx>=0.25
29
+ Requires-Dist: numpy>=1.24
30
+ Provides-Extra: dev
31
+ Requires-Dist: matplotlib>=3.7; extra == 'dev'
32
+ Requires-Dist: pytest>=7; extra == 'dev'
33
+ Provides-Extra: hf
34
+ Requires-Dist: huggingface-hub; extra == 'hf'
35
+ Requires-Dist: torch; extra == 'hf'
36
+ Requires-Dist: transformers>=4.45; extra == 'hf'
37
+ Provides-Extra: plots
38
+ Requires-Dist: matplotlib>=3.7; extra == 'plots'
39
+ Description-Content-Type: text/markdown
40
+
41
+ # pairsort
42
+
43
+ **Rank anything with AI judges: reliably, cheaply, and with honest confidence.**
44
+
45
+ [![tests](https://github.com/ericflo/pairsort/actions/workflows/ci.yml/badge.svg)](https://github.com/ericflo/pairsort/actions/workflows/ci.yml)
46
+ [![Summary Showdown](https://img.shields.io/badge/play-Summary%20Showdown-2a78d6)](https://ericflo.github.io/pairsort/)
47
+ [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ericflo/pairsort/blob/main/LICENSE)
48
+
49
+ Ask a model to *score* 100 things from 1 to 10 and you get noise on a drifting scale. Ask it *"which of these two is
50
+ better?"* and you get its best judgment. pairsort asks many of those small questions, cancels the model's biases,
51
+ and couples the answers into **one ranking with probabilities**, using the pairwise-coupling rule of
52
+ Price, Knerr, Personnaz & Dreyfus ([NeurIPS 1994](https://proceedings.neurips.cc/paper_files/paper/1994/file/210f760a89db30aa72ca258a3483cc7f-Paper.pdf)).
53
+
54
+ * **More reliable than any single judgment.** Coupling many pairwise answers fixes the contradictions a judge makes
55
+ (A > B > C > A) and averages out its noise and position bias. Measured against explicit ground truth in
56
+ [eight evals](#does-it-work).
57
+ * **Cheap: not all-vs-all.** An active schedule asks only the informative pairs and stops when the ranking settles;
58
+ 100 items were ranked from 8% of the possible pairs. With [Jev](https://ericflo.github.io/pairsort/judges.html) as the judge, 4,800 comparisons cost $0.11.
59
+ * **Probabilities, not vibes.** Every item gets a posterior, every pair a calibrated P(A beats B), and pairsort
60
+ abstains when the top two are too close to call.
61
+ * **Any judge.** TypeSafe's Jev via OpenRouter (default), any OpenRouter LLM via token logprobs, open Jev models,
62
+ or your own: [judges](https://ericflo.github.io/pairsort/judges.html).
63
+ * **Auditable.** Every judgment, in both orders, lands in a JSON audit log.
64
+
65
+ ## Try it in 60 seconds
66
+
67
+ ```bash
68
+ pip install pairsort # PyPI name; you `import pairsort` and run `pairsort` (or `pairsort`)
69
+ uvx pairsort demo # or run the CLI without installing anything
70
+ export OPENROUTER_API_KEY=sk-or-... # or skip it and bring your own judge function
71
+ ```
72
+
73
+ ```python
74
+ import pairsort
75
+
76
+ ideas = ["A CLI that turns any CSV into a chart", "A to-do app on a blockchain", "A tool that ranks PRs by urgency"]
77
+
78
+ result = pairsort.sort(ideas, "Which side project would developers find most useful?")
79
+ result.best # 'A tool that ranks PRs by urgency' (your own objects back, best first)
80
+ result.top(2) # the two best
81
+ result.scores # {id: probability of being the best}
82
+
83
+ pairsort.sort(ideas, {"useful": "Which is more useful?", "easy": "Which is easier to build?"}) # blend questions
84
+ pairsort.compare("draft A", "draft B", "Which is clearer?") # -> P(A is better)
85
+ pairsort.sort(ideas, "Which is shorter?", judge=lambda q, a, b: len(a) < len(b)) # any function is a judge
86
+ ```
87
+
88
+ ```bash
89
+ pairsort sort ideas.txt "Which idea has more impact?" # from a file (`uvx pairsort sort ...` works too)
90
+ cat ideas.txt | pairsort sort - "Which is funnier?" --top 3 # from stdin
91
+ pairsort compare "draft A" "draft B" "Which is clearer?"
92
+ ```
93
+
94
+ Nothing is hidden behind the easy path: budgets, active/referee schedules, meta-judges, calibration profiles and
95
+ any backend are all keywords on `pairsort.sort` or steps on the builder (`pairsort.sorter().by(...).budget(60).meta()`).
96
+ [Quickstart](https://ericflo.github.io/pairsort/quickstart.html) (runs in ~5 s: `python examples/quickstart.py`) ·
97
+ [Usage & CLI](https://ericflo.github.io/pairsort/usage.html)
98
+
99
+ ## Summary Showdown
100
+
101
+ <!-- showdown:start -->
102
+
103
+ **100 of OpenRouter's most-used models each summarized the 1994 paper this library implements.** pairsort ranked them on six questions from 400 of 4,950 possible pairs (8%) with a jury of 4 AI judges. Current top 3: GPT-6 Astra, Claude Opus 5, Nemotron 3 Ultra.
104
+
105
+ [![Summary Showdown](https://raw.githubusercontent.com/ericflo/pairsort/main/examples/figures/showdown_top.png)](https://ericflo.github.io/pairsort/)
106
+
107
+ *Ground truth: none — nobody can say which summary is truly best. The ranking is the AI jury's opinion; we check it against a separate LLM grader (Claude Sonnet 5 + a key-fact rubric), which the [verifiable eval](https://ericflo.github.io/pairsort/verifiable.html) shows is itself accurate on exact counts. Humans can vote on the site.*
108
+
109
+ [**Judge the summaries yourself →**](https://ericflo.github.io/pairsort/) · [full results + method](https://ericflo.github.io/pairsort/showdown.html) · [leaderboard](https://github.com/ericflo/pairsort/blob/main/examples/SHOWDOWN.md)
110
+
111
+ <!-- showdown:end -->
112
+
113
+ ## Does it work?
114
+
115
+ Eight evals, each with its ground truth stated up front:
116
+
117
+ | eval | what gets ranked | ground truth | result | details |
118
+ |---|---|---|---|---|
119
+ | **Verifiable** | 72 summaries of 6 *fictional* documents | **exact counts** of injected false statements and of facts mentioned, fixed by construction and recountable by a script | <!-- ev:verifiable -->Jev: 96% of pairs right on accuracy, 94% on completeness (τ 0.82 / 0.89) for $0.02; weakest judge τ 0.42<!-- /ev --> | [verifiable](https://ericflo.github.io/pairsort/verifiable.html) |
120
+ | **Market** | 80 + 101 stocks over 2 sessions, judged only on their pre-open SEC filings | **realized next-day returns** (Mon 09-21 and Tue 09-22), which didn't exist before those days | <!-- ev:market -->Monday: Jev τ +0.14 (p = 0.035). Tuesday: no judge beat guessing (best p = 0.12). Weak evidence so far<!-- /ev --> | [market](https://ericflo.github.io/pairsort/market.html) |
121
+ | **Degradation ladder** | 60 copies of 6 real summaries, damaged one logged step at a time | **rung number** (each rung = previous + one planted error / deleted / swapped sentence) | Jev: 94% of pairs right, ECE 0.033 | [ladder](https://ericflo.github.io/pairsort/ladder.html) |
122
+ | **Code runtime** | 25 correct implementations of a new function | **measured wall-clock time** in a sandbox | Jev picks the faster one 97% of the time | [runtime](https://ericflo.github.io/pairsort/runtime.html) |
123
+ | **Cross-lingual** | the same summaries in EN/ES/DE/JA | **exact counts, identical in every language** by construction | Jev gives the same answer in all 4 languages 96% of the time | [cross-lingual](https://ericflo.github.io/pairsort/crosslingual.html) |
124
+ | **Weather** | 35 cities, ranked the day before | **airport observations** of the next day's high and rain; predictions committed first | first round resolves 2026-09-25 | [weather](https://ericflo.github.io/pairsort/weather.html) |
125
+ | **Paper sorting** | 16 *fictional* abstracts on 3 questions | **1–5 levels assigned by construction** by the dataset author (not expert ratings) | Jev: fused AUC 0.994, Kendall τ 0.86 | [evaluation](https://ericflo.github.io/pairsort/evaluation.html) |
126
+ | **Synthetic** | simulated items, flawed simulated judge | **known latent order**; calibration labels sampled from it | coupling + both orders + temperature: ECE 0.158 → 0.013 | [evaluation](https://ericflo.github.io/pairsort/evaluation.html) |
127
+
128
+ ![Verifiable eval](https://raw.githubusercontent.com/ericflo/pairsort/main/examples/figures/verifiable_eval.png)
129
+
130
+ *Ground truth in this figure: exact counts built into fictional documents; recount them with
131
+ `python examples/verifiable_eval.py verify`.*
132
+
133
+ ## Learn more
134
+
135
+ * [How it works](https://ericflo.github.io/pairsort/how-it-works.html): pairwise questions, PKPD Eq. 7, Bradley–Terry, bias guards, blending, Jev as meta-judge and referee
136
+ * [Judges & backends](https://ericflo.github.io/pairsort/judges.html): Jev via OpenRouter, the LLM fallback, open Jev models, the `/v1/systemone` shim
137
+ * [Usage](https://ericflo.github.io/pairsort/usage.html): CLI, input formats, Python API, calibration, a worked example
138
+ * Evals: [verifiable](https://ericflo.github.io/pairsort/verifiable.html) · [market](https://ericflo.github.io/pairsort/market.html) · [ladder](https://ericflo.github.io/pairsort/ladder.html) · [runtime](https://ericflo.github.io/pairsort/runtime.html) · [cross-lingual](https://ericflo.github.io/pairsort/crosslingual.html) · [weather](https://ericflo.github.io/pairsort/weather.html) · [synthetic + papers](https://ericflo.github.io/pairsort/evaluation.html) · [Summary Showdown](https://ericflo.github.io/pairsort/showdown.html) · [Humans vs judges](https://ericflo.github.io/pairsort/humans-vs-judges.html)
139
+
140
+ MIT licensed. Contributions welcome.
@@ -0,0 +1,100 @@
1
+ # pairsort
2
+
3
+ **Rank anything with AI judges: reliably, cheaply, and with honest confidence.**
4
+
5
+ [![tests](https://github.com/ericflo/pairsort/actions/workflows/ci.yml/badge.svg)](https://github.com/ericflo/pairsort/actions/workflows/ci.yml)
6
+ [![Summary Showdown](https://img.shields.io/badge/play-Summary%20Showdown-2a78d6)](https://ericflo.github.io/pairsort/)
7
+ [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ericflo/pairsort/blob/main/LICENSE)
8
+
9
+ Ask a model to *score* 100 things from 1 to 10 and you get noise on a drifting scale. Ask it *"which of these two is
10
+ better?"* and you get its best judgment. pairsort asks many of those small questions, cancels the model's biases,
11
+ and couples the answers into **one ranking with probabilities**, using the pairwise-coupling rule of
12
+ Price, Knerr, Personnaz & Dreyfus ([NeurIPS 1994](https://proceedings.neurips.cc/paper_files/paper/1994/file/210f760a89db30aa72ca258a3483cc7f-Paper.pdf)).
13
+
14
+ * **More reliable than any single judgment.** Coupling many pairwise answers fixes the contradictions a judge makes
15
+ (A > B > C > A) and averages out its noise and position bias. Measured against explicit ground truth in
16
+ [eight evals](#does-it-work).
17
+ * **Cheap: not all-vs-all.** An active schedule asks only the informative pairs and stops when the ranking settles;
18
+ 100 items were ranked from 8% of the possible pairs. With [Jev](https://ericflo.github.io/pairsort/judges.html) as the judge, 4,800 comparisons cost $0.11.
19
+ * **Probabilities, not vibes.** Every item gets a posterior, every pair a calibrated P(A beats B), and pairsort
20
+ abstains when the top two are too close to call.
21
+ * **Any judge.** TypeSafe's Jev via OpenRouter (default), any OpenRouter LLM via token logprobs, open Jev models,
22
+ or your own: [judges](https://ericflo.github.io/pairsort/judges.html).
23
+ * **Auditable.** Every judgment, in both orders, lands in a JSON audit log.
24
+
25
+ ## Try it in 60 seconds
26
+
27
+ ```bash
28
+ pip install pairsort # PyPI name; you `import pairsort` and run `pairsort` (or `pairsort`)
29
+ uvx pairsort demo # or run the CLI without installing anything
30
+ export OPENROUTER_API_KEY=sk-or-... # or skip it and bring your own judge function
31
+ ```
32
+
33
+ ```python
34
+ import pairsort
35
+
36
+ ideas = ["A CLI that turns any CSV into a chart", "A to-do app on a blockchain", "A tool that ranks PRs by urgency"]
37
+
38
+ result = pairsort.sort(ideas, "Which side project would developers find most useful?")
39
+ result.best # 'A tool that ranks PRs by urgency' (your own objects back, best first)
40
+ result.top(2) # the two best
41
+ result.scores # {id: probability of being the best}
42
+
43
+ pairsort.sort(ideas, {"useful": "Which is more useful?", "easy": "Which is easier to build?"}) # blend questions
44
+ pairsort.compare("draft A", "draft B", "Which is clearer?") # -> P(A is better)
45
+ pairsort.sort(ideas, "Which is shorter?", judge=lambda q, a, b: len(a) < len(b)) # any function is a judge
46
+ ```
47
+
48
+ ```bash
49
+ pairsort sort ideas.txt "Which idea has more impact?" # from a file (`uvx pairsort sort ...` works too)
50
+ cat ideas.txt | pairsort sort - "Which is funnier?" --top 3 # from stdin
51
+ pairsort compare "draft A" "draft B" "Which is clearer?"
52
+ ```
53
+
54
+ Nothing is hidden behind the easy path: budgets, active/referee schedules, meta-judges, calibration profiles and
55
+ any backend are all keywords on `pairsort.sort` or steps on the builder (`pairsort.sorter().by(...).budget(60).meta()`).
56
+ [Quickstart](https://ericflo.github.io/pairsort/quickstart.html) (runs in ~5 s: `python examples/quickstart.py`) ·
57
+ [Usage & CLI](https://ericflo.github.io/pairsort/usage.html)
58
+
59
+ ## Summary Showdown
60
+
61
+ <!-- showdown:start -->
62
+
63
+ **100 of OpenRouter's most-used models each summarized the 1994 paper this library implements.** pairsort ranked them on six questions from 400 of 4,950 possible pairs (8%) with a jury of 4 AI judges. Current top 3: GPT-6 Astra, Claude Opus 5, Nemotron 3 Ultra.
64
+
65
+ [![Summary Showdown](https://raw.githubusercontent.com/ericflo/pairsort/main/examples/figures/showdown_top.png)](https://ericflo.github.io/pairsort/)
66
+
67
+ *Ground truth: none — nobody can say which summary is truly best. The ranking is the AI jury's opinion; we check it against a separate LLM grader (Claude Sonnet 5 + a key-fact rubric), which the [verifiable eval](https://ericflo.github.io/pairsort/verifiable.html) shows is itself accurate on exact counts. Humans can vote on the site.*
68
+
69
+ [**Judge the summaries yourself →**](https://ericflo.github.io/pairsort/) · [full results + method](https://ericflo.github.io/pairsort/showdown.html) · [leaderboard](https://github.com/ericflo/pairsort/blob/main/examples/SHOWDOWN.md)
70
+
71
+ <!-- showdown:end -->
72
+
73
+ ## Does it work?
74
+
75
+ Eight evals, each with its ground truth stated up front:
76
+
77
+ | eval | what gets ranked | ground truth | result | details |
78
+ |---|---|---|---|---|
79
+ | **Verifiable** | 72 summaries of 6 *fictional* documents | **exact counts** of injected false statements and of facts mentioned, fixed by construction and recountable by a script | <!-- ev:verifiable -->Jev: 96% of pairs right on accuracy, 94% on completeness (τ 0.82 / 0.89) for $0.02; weakest judge τ 0.42<!-- /ev --> | [verifiable](https://ericflo.github.io/pairsort/verifiable.html) |
80
+ | **Market** | 80 + 101 stocks over 2 sessions, judged only on their pre-open SEC filings | **realized next-day returns** (Mon 09-21 and Tue 09-22), which didn't exist before those days | <!-- ev:market -->Monday: Jev τ +0.14 (p = 0.035). Tuesday: no judge beat guessing (best p = 0.12). Weak evidence so far<!-- /ev --> | [market](https://ericflo.github.io/pairsort/market.html) |
81
+ | **Degradation ladder** | 60 copies of 6 real summaries, damaged one logged step at a time | **rung number** (each rung = previous + one planted error / deleted / swapped sentence) | Jev: 94% of pairs right, ECE 0.033 | [ladder](https://ericflo.github.io/pairsort/ladder.html) |
82
+ | **Code runtime** | 25 correct implementations of a new function | **measured wall-clock time** in a sandbox | Jev picks the faster one 97% of the time | [runtime](https://ericflo.github.io/pairsort/runtime.html) |
83
+ | **Cross-lingual** | the same summaries in EN/ES/DE/JA | **exact counts, identical in every language** by construction | Jev gives the same answer in all 4 languages 96% of the time | [cross-lingual](https://ericflo.github.io/pairsort/crosslingual.html) |
84
+ | **Weather** | 35 cities, ranked the day before | **airport observations** of the next day's high and rain; predictions committed first | first round resolves 2026-09-25 | [weather](https://ericflo.github.io/pairsort/weather.html) |
85
+ | **Paper sorting** | 16 *fictional* abstracts on 3 questions | **1–5 levels assigned by construction** by the dataset author (not expert ratings) | Jev: fused AUC 0.994, Kendall τ 0.86 | [evaluation](https://ericflo.github.io/pairsort/evaluation.html) |
86
+ | **Synthetic** | simulated items, flawed simulated judge | **known latent order**; calibration labels sampled from it | coupling + both orders + temperature: ECE 0.158 → 0.013 | [evaluation](https://ericflo.github.io/pairsort/evaluation.html) |
87
+
88
+ ![Verifiable eval](https://raw.githubusercontent.com/ericflo/pairsort/main/examples/figures/verifiable_eval.png)
89
+
90
+ *Ground truth in this figure: exact counts built into fictional documents; recount them with
91
+ `python examples/verifiable_eval.py verify`.*
92
+
93
+ ## Learn more
94
+
95
+ * [How it works](https://ericflo.github.io/pairsort/how-it-works.html): pairwise questions, PKPD Eq. 7, Bradley–Terry, bias guards, blending, Jev as meta-judge and referee
96
+ * [Judges & backends](https://ericflo.github.io/pairsort/judges.html): Jev via OpenRouter, the LLM fallback, open Jev models, the `/v1/systemone` shim
97
+ * [Usage](https://ericflo.github.io/pairsort/usage.html): CLI, input formats, Python API, calibration, a worked example
98
+ * Evals: [verifiable](https://ericflo.github.io/pairsort/verifiable.html) · [market](https://ericflo.github.io/pairsort/market.html) · [ladder](https://ericflo.github.io/pairsort/ladder.html) · [runtime](https://ericflo.github.io/pairsort/runtime.html) · [cross-lingual](https://ericflo.github.io/pairsort/crosslingual.html) · [weather](https://ericflo.github.io/pairsort/weather.html) · [synthetic + papers](https://ericflo.github.io/pairsort/evaluation.html) · [Summary Showdown](https://ericflo.github.io/pairsort/showdown.html) · [Humans vs judges](https://ericflo.github.io/pairsort/humans-vs-judges.html)
99
+
100
+ MIT licensed. Contributions welcome.
@@ -0,0 +1,168 @@
1
+ {
2
+ "name": "clinical-hallucination-papers",
3
+ "description": "16 FICTIONAL paper abstracts written for the pairsort demo. Each has ground-truth levels (1-5) per dimension assigned by construction by the dataset author, so judge accuracy (ROC/AUC, Kendall tau) can be measured. Overall = mean of the three levels. None of these papers exist.",
4
+ "objective": "Find methods that reliably reduce hallucinated (unsupported) statements in LLM-generated hospital discharge summaries without reducing clinical completeness.",
5
+ "preset": "papers",
6
+ "items": [
7
+ {
8
+ "id": "P01",
9
+ "title": "Retrieval-grounded decoding for discharge summaries: a 12-hospital randomized trial",
10
+ "abstract": "We randomized 4,812 discharge summaries across 12 hospitals to standard LLM drafting or retrieval-grounded decoding that restricts each generated sentence to spans retrieved from the patient's chart. Blinded attending physicians rated every summary. Unsupported statements fell from 7.9 to 2.1 per 100 sentences (difference 5.8, 95% CI 5.1-6.5, p<0.001) with no loss in a pre-specified completeness score. Effects were consistent across all sites and five note types. We release code, the rating protocol and anonymized ratings.",
11
+ "labels": {
12
+ "evidence": 5,
13
+ "relevance": 5,
14
+ "contribution": 4
15
+ }
16
+ },
17
+ {
18
+ "id": "P02",
19
+ "title": "Citation-constrained generation cuts unsupported claims in clinical summaries",
20
+ "abstract": "We force the model to attach a chart citation to every clinical claim and reject uncited sentences at decode time. On 400 discharge summaries from one academic center, two blinded clinicians found 61% fewer unsupported statements than a strong prompting baseline (Cohen's kappa 0.78). Ablations show the verifier and the citation format each contribute. Completeness dropped by 2%, within the non-inferiority margin we pre-registered.",
21
+ "labels": {
22
+ "evidence": 4,
23
+ "relevance": 5,
24
+ "contribution": 4
25
+ }
26
+ },
27
+ {
28
+ "id": "P03",
29
+ "title": "HalluGuard: a revolutionary framework that eliminates hallucination in medical AI",
30
+ "abstract": "HalluGuard is a paradigm-shifting framework that completely eliminates hallucinations in clinical text generation. In our experiments on 20 carefully selected discharge summaries, HalluGuard produced zero hallucinations, demonstrating its transformative potential. HalluGuard combines state-of-the-art prompting with a proprietary knowledge layer. We believe HalluGuard will revolutionize healthcare documentation.",
31
+ "labels": {
32
+ "evidence": 1,
33
+ "relevance": 4,
34
+ "contribution": 1
35
+ }
36
+ },
37
+ {
38
+ "id": "P04",
39
+ "title": "Scaling laws for factual consistency in news summarization",
40
+ "abstract": "Across 38 models from 70M to 400B parameters and 1.2M CNN/DailyMail and XSum articles, we measure factual consistency with three independent human-validated metrics. Unsupported content decreases as a power law in compute (R^2=0.97), and the fitted law predicts held-out model families within 4%. We release all generations and annotations. We do not study clinical or other specialist domains.",
41
+ "labels": {
42
+ "evidence": 5,
43
+ "relevance": 2,
44
+ "contribution": 4
45
+ }
46
+ },
47
+ {
48
+ "id": "P05",
49
+ "title": "A taxonomy of hallucination types in clinical text generation",
50
+ "abstract": "Three clinicians annotated 150 LLM-generated discharge summaries and inductively derived a taxonomy of nine hallucination types, from fabricated medications to wrong laterality (Fleiss' kappa 0.71). Medication and follow-up fabrications were most frequent and most clinically dangerous. The taxonomy is descriptive; we do not test mitigation methods.",
51
+ "labels": {
52
+ "evidence": 3,
53
+ "relevance": 4,
54
+ "contribution": 3
55
+ }
56
+ },
57
+ {
58
+ "id": "P06",
59
+ "title": "Entailment-based verification filter for LLM discharge summaries",
60
+ "abstract": "We add an NLI verifier that deletes generated sentences not entailed by the source notes. On 1,000 discharge summaries the filter improves automatic faithfulness metrics (SummaC +0.14, FactCC +0.11). We did not conduct clinician evaluation, and we did not measure whether deleted sentences removed clinically necessary content.",
61
+ "labels": {
62
+ "evidence": 3,
63
+ "relevance": 5,
64
+ "contribution": 3
65
+ }
66
+ },
67
+ {
68
+ "id": "P07",
69
+ "title": "Ten prompt engineering tips for medical chatbots",
70
+ "abstract": "Drawing on our experience deploying chatbots, we share ten tips for writing better prompts in healthcare, such as asking the model to be careful and to double-check its answers. Anecdotally these tips reduced mistakes in the conversations we looked at. We hope practitioners find them useful.",
71
+ "labels": {
72
+ "evidence": 1,
73
+ "relevance": 2,
74
+ "contribution": 1
75
+ }
76
+ },
77
+ {
78
+ "id": "P08",
79
+ "title": "Self-consistency sampling reduces hallucination in radiology report summarization",
80
+ "abstract": "We sample eight impressions per radiology report and keep only findings stated in a majority. Across 2,300 reports from two hospitals, blinded radiologists found 44% fewer unsupported findings than greedy decoding (p<0.001), with a 3% drop in recall of critical findings. Results held for CT and MRI. Discharge summaries were not studied, but the method is domain-agnostic.",
81
+ "labels": {
82
+ "evidence": 4,
83
+ "relevance": 4,
84
+ "contribution": 3
85
+ }
86
+ },
87
+ {
88
+ "id": "P09",
89
+ "title": "Diffusion models for retinal vessel segmentation",
90
+ "abstract": "We train a conditional diffusion model for retinal vessel segmentation and evaluate on DRIVE, STARE and CHASE with five-fold cross-validation and three seeds. It improves Dice by 1.8 points over the best U-Net baseline (p<0.01) and is robust to acquisition noise. Code and weights are released.",
91
+ "labels": {
92
+ "evidence": 4,
93
+ "relevance": 1,
94
+ "contribution": 3
95
+ }
96
+ },
97
+ {
98
+ "id": "P10",
99
+ "title": "Contrastive fine-tuning on clinician edits: a multi-center study with pre-registered endpoints",
100
+ "abstract": "We fine-tune a summarizer contrastively on 210,000 pairs of LLM drafts and the clinician-corrected versions, teaching it to rank supported over unsupported statements. In a pre-registered evaluation on 6,000 discharge summaries from 9 health systems, blinded physicians found 72% fewer unsupported statements than the base model and 38% fewer than retrieval-grounded decoding, with completeness non-inferior. Gains replicated in an independent external cohort and in three languages. The method needs no retrieval at inference time.",
101
+ "labels": {
102
+ "evidence": 5,
103
+ "relevance": 5,
104
+ "contribution": 5
105
+ }
106
+ },
107
+ {
108
+ "id": "P11",
109
+ "title": "Does RLHF increase fabrication? Evidence from clinical question answering",
110
+ "abstract": "We compare one base model with its RLHF-tuned version on 300 clinical questions. Two physicians judged answers; the RLHF model fabricated citations more often (18% vs 11%, p=0.03). We did not study summarization, and results may not generalize to other models.",
111
+ "labels": {
112
+ "evidence": 3,
113
+ "relevance": 3,
114
+ "contribution": 3
115
+ }
116
+ },
117
+ {
118
+ "id": "P12",
119
+ "title": "Knowledge-graph grounded summarization of EHR notes: a pilot",
120
+ "abstract": "We link EHR notes to a medical knowledge graph and condition the summarizer on linked entities. In a pilot on 25 notes, the authors judged the summaries to contain fewer errors than a baseline. No statistical testing was performed. A larger study is planned.",
121
+ "labels": {
122
+ "evidence": 2,
123
+ "relevance": 5,
124
+ "contribution": 2
125
+ }
126
+ },
127
+ {
128
+ "id": "P13",
129
+ "title": "ClinFaith: a benchmark for faithfulness in clinical summarization",
130
+ "abstract": "We release ClinFaith, 5,000 discharge summaries generated by nine LLMs with sentence-level support labels from 14 clinicians (inter-annotator agreement 0.81). Existing automatic faithfulness metrics correlate weakly with clinician labels (best Spearman 0.42); we train a verifier reaching 0.71. ClinFaith enables comparable evaluation of hallucination mitigation methods.",
131
+ "labels": {
132
+ "evidence": 4,
133
+ "relevance": 5,
134
+ "contribution": 4
135
+ }
136
+ },
137
+ {
138
+ "id": "P14",
139
+ "title": "Hallucination detection in legal contract drafting",
140
+ "abstract": "We fine-tune a classifier to flag fabricated clauses in LLM-drafted contracts. On 600 contracts labeled by two lawyers it reaches F1 0.83, versus 0.71 for prompting. We do not evaluate generalization beyond commercial leases.",
141
+ "labels": {
142
+ "evidence": 3,
143
+ "relevance": 2,
144
+ "contribution": 2
145
+ }
146
+ },
147
+ {
148
+ "id": "P15",
149
+ "title": "On the impossibility of hallucination-free language models",
150
+ "abstract": "We prove that any computable language model trained on finite data must hallucinate on some inputs, and derive a lower bound on the hallucination rate as a function of the model's calibration. The result implies that mitigation must target detection and grounding rather than elimination. We present no experiments.",
151
+ "labels": {
152
+ "evidence": 1,
153
+ "relevance": 3,
154
+ "contribution": 4
155
+ }
156
+ },
157
+ {
158
+ "id": "P16",
159
+ "title": "Bigger is not safer: a failed replication of scale-reduces-hallucination in clinical summaries",
160
+ "abstract": "A widely cited claim holds that larger models hallucinate less in clinical summarization. We re-ran the original protocol on 1,500 discharge summaries with 6 model sizes and blinded clinician rating. We find no significant relationship between size and unsupported statement rate (slope -0.02, 95% CI -0.09 to 0.05), and show the original effect was driven by a data leak.",
161
+ "labels": {
162
+ "evidence": 4,
163
+ "relevance": 4,
164
+ "contribution": 3
165
+ }
166
+ }
167
+ ]
168
+ }
@@ -0,0 +1,46 @@
1
+ """The 60-second quickstart, as a script. Every snippet in docs/quickstart.md is here, verbatim.
2
+
3
+ export OPENROUTER_API_KEY=sk-or-...
4
+ python examples/quickstart.py
5
+ """
6
+
7
+ import pairsort
8
+
9
+ ideas = [
10
+ "A browser extension that summarizes long email threads",
11
+ "A CLI that turns any CSV into a chart in one command",
12
+ "A to-do app with a blockchain backend",
13
+ "A tool that ranks pull requests by review urgency",
14
+ "A smart fridge magnet that tweets your grocery list",
15
+ ]
16
+
17
+ # 1. One question, one line.
18
+ result = pairsort.sort(ideas, "Which side project would developers find most useful?")
19
+ print(result.best) # the winner (your own string back)
20
+ print(result.top(3)) # the three best
21
+ print(result.scores) # {id: probability of being the best}
22
+
23
+ # 2. Several questions, blended. Plain strings, or name="question".
24
+ result = pairsort.sort(ideas, {"useful": "Which would developers find more useful?",
25
+ "easy": "Which is easier to build in a weekend?"})
26
+ print(result) # a table: overall + each question
27
+
28
+ # 3. One comparison.
29
+ p = pairsort.compare("Short, clear sentences.",
30
+ "Sentences that, owing to a proliferation of subordinate clauses, meander.",
31
+ "Which is easier to read?")
32
+ print(f"P(first is easier to read) = {p:.2f}")
33
+
34
+ # 4. Your own judge: any function (question, a, b) -> P(a is better). No API key needed.
35
+ by_length = pairsort.sort(ideas, "Which is shorter?", judge=lambda q, a, b: len(a) < len(b))
36
+ print(by_length.best)
37
+
38
+ # 5. Everything else is still there: builder, budgets, meta-judge, calibration, any backend.
39
+ result = (pairsort.sorter()
40
+ .by("Which would developers find more useful?")
41
+ .objective("We are picking one weekend hackathon project.")
42
+ .judge("llm:deepseek/deepseek-v4.1-flash") # any OpenRouter model, Jev, or a local model
43
+ .budget(8) # at most 8 comparisons
44
+ .meta() # let the judge re-rank the top items overall
45
+ .sort(ideas))
46
+ print(result.ids, result.usage["pairs"], "pairs")
@@ -0,0 +1,57 @@
1
+ """pairsort — rank anything with AI judges.
2
+
3
+ import pairsort
4
+ result = pairsort.sort(["idea one", "idea two", "idea three"], "Which idea has more impact?")
5
+ result.sorted # best first
6
+ pairsort.compare("draft A", "draft B", "Which is clearer?") # -> P(A is better)
7
+ pairsort.sorter().by("Which is clearer?").judge("llm").budget(60).meta().sort(items) # builder
8
+
9
+ PKPD pairwise sorting on Jev-style judges.
10
+
11
+ Sort anything by asking a calibrated judge many small pairwise questions
12
+ ("which of A or B has stronger evidence?"), coupling the pairwise posteriors
13
+ into global posteriors (Price–Knerr–Personnaz–Dreyfus 1994, Eq. 7, or
14
+ Bradley–Terry), and blending several dimensions — optionally with the judge
15
+ itself as meta-judge and referee.
16
+ """
17
+
18
+ from .api import FunctionJudge, Sorter, as_dimensions, as_items, as_judge, compare, sort, sorter
19
+ from .backends import Choice, JudgeBackend, make_backend
20
+ from .blend import LinearBlend
21
+ from .calibrate import Profile, apply_temperature, ece, fit_temperature
22
+ from .couple import Coupled, bradley_terry, couple, pkpd
23
+ from .pairwise import PairwiseMatrix, clip, symmetrize
24
+ from .sorter import PAPER_DIMENSIONS, Dimension, Item, PairSorter, SortResult
25
+
26
+ __version__ = "0.1.0"
27
+
28
+ __all__ = [
29
+ "sort",
30
+ "compare",
31
+ "sorter",
32
+ "Sorter",
33
+ "FunctionJudge",
34
+ "as_dimensions",
35
+ "as_items",
36
+ "as_judge",
37
+ "Choice",
38
+ "JudgeBackend",
39
+ "make_backend",
40
+ "LinearBlend",
41
+ "Profile",
42
+ "apply_temperature",
43
+ "ece",
44
+ "fit_temperature",
45
+ "Coupled",
46
+ "bradley_terry",
47
+ "couple",
48
+ "pkpd",
49
+ "PairwiseMatrix",
50
+ "clip",
51
+ "symmetrize",
52
+ "PAPER_DIMENSIONS",
53
+ "Dimension",
54
+ "Item",
55
+ "PairSorter",
56
+ "SortResult",
57
+ ]
@@ -0,0 +1,3 @@
1
+ from .cli import main
2
+
3
+ raise SystemExit(main())