Skip to contents

pairwiseLLM supports (1) constructing paired-comparison designs over items, (2) collecting binary judgments from LLMs (live or via provider batch APIs), and (3) fitting ranking models (Elo, Bradley–Terry) including an adaptive, Bayesian BTL (MCMC) workflow.

Details

Start here

Compare writing samples two at a time, then estimate relative quality from the winners. The Getting Started guide begins with an offline example and explains scores before collecting new data.

Typical fixed-pair workflow

  1. Load items using read_samples_df() or read_samples_dir().

  2. Create a pairing design with make_pairs() or sample_pairs(), optionally adding reversals via sample_reverse_pairs().

  3. (Optional) Control ordering / bias with randomize_pair_order(), alternate_pair_order(), and diagnostics like check_positional_bias() or reversal agreement via compute_reverse_consistency().

  4. Build prompts with build_prompt() + trait_description(), using templates managed by list_prompt_templates(), get_prompt_template(), set_prompt_template(), register_prompt_template(), and remove_prompt_template().

  5. Collect judgments:

  6. Assemble modeling data with build_bt_data() or build_elo_data() (and for some pipelines, build_btl_results_data()).

  7. Fit / summarize:

Provider matrix

  • Live backends: "openai", "anthropic", "gemini" (Gemini Developer API), "vertex" (Vertex AI Gemini API), "together", and "ollama".

  • Batch backends: "openai", "anthropic", and "gemini". backend = "vertex" is rejected explicitly on generic batch surfaces.

  • Gemini Developer API and Vertex use separate API-key surfaces: GEMINI_API_KEY and VERTEX_API_KEY.

  • service_tier is provider-specific. Gemini Developer API and Vertex share the public values "standard", "flex", and "priority", but they use different request transports.

Adaptive Bayesian pairing + ranking (end-to-end loop)

If you want the package to both choose pairs and fit Bayesian BTL in an auditable loop, use the adaptive workflow:

Choose an example dataset

Exported functions by task

1) Read / define items to rank

2) Create pair designs and manage ordering

Design notes (adaptive Bayesian BTL)

The adaptive design targets stable, auditable rankings using Bayesian Bradley–Terry–Luce inference with MCMC, supports position bias and lapse-rate variants, and is intended to be robust for noisy LLM judges.

The adaptive loop enforces connectivity, duplicate control with order reversal for repeated unordered pairs, and approximate 50/50 position balance across items. Stopping and refits are logged so stop decisions are reproducible from the round_log fields (an explicit stop audit trail).

See also

Author

Maintainer: Sterett H. Mercer sterett.mercer@ubc.ca (ORCID) [copyright holder]

Authors: