Package: pairwiseLLM 1.6.0

pairwiseLLM: Pairwise Comparison Tools for Large Language Model-Based Writing Evaluation

Provides a unified framework for generating, submitting, and analyzing pairwise comparisons of writing quality using large language models (LLMs). The package supports live and/or batch evaluation workflows across multiple providers ('OpenAI', 'Anthropic', 'Google Gemini', 'Together AI', 'TypeSafe', and locally-hosted 'Ollama' models), includes bias-tested prompt templates and a flexible template registry, and offers tools for constructing forward and reversed comparison sets to analyze consistency and positional bias. The package additionally supports adaptive pairing workflows that iteratively select comparisons based on model uncertainty to improve ranking efficiency. Results can be modeled using frequentist or Bayesian Bradley–Terry–Luce models (Bradley & Terry, 1952 <doi:10.2307/2334029>; see also Caron & Doucet, 2012 <doi:10.1080/10618600.2012.638220>) or Elo rating methods (see Clark et al., 2018 <doi:10.1371/journal.pone.0190393>) to derive writing quality scores. The Bayesian writing quality scores can be converted to distribution-matched performance levels or calibrated to ordered rubric scores using linear or monotone ordinal models. For information on pairwise comparisons and comparative judgement, see Thurstone (1927) <doi:10.1037/h0070288> and Heldsinger & Humphry (2010) <doi:10.1007/BF03216919>.

Authors:Sterett H. Mercer [aut, cre, cph]

pairwiseLLM_1.6.0.tar.gz
pairwiseLLM_1.6.0.zip(r-4.7-any)pairwiseLLM_1.6.0.zip(r-4.6-any)pairwiseLLM_1.6.0.zip(r-4.5-any)
pairwiseLLM_1.6.0.tgz(r-4.6-any)pairwiseLLM_1.6.0.tgz(r-4.5-any)
pairwiseLLM_1.6.0.tar.gz(r-4.7-any)pairwiseLLM_1.6.0.tar.gz(r-4.6-any)
pairwiseLLM_1.6.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
pairwiseLLM/json (API)

# Install 'pairwiseLLM' in R:
install.packages('pairwiseLLM', repos = c('https://shmercer.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/shmercer/pairwisellm/issues

Pkgdown/docs site:https://shmercer.github.io

Datasets:

On CRAN:

Conda:

anthropicassessment-toolautomated-scoringbradley-terryelo-ratinggeminilarge-language-modelsllmllm-as-a-judgeollamaopenaipairwise-comparisonrankingtogether-aiwriting-assessmentwriting-evaluation

7.18 score 3 stars 39 scripts 390 downloads 116 exports 21 dependencies

Last updated from:3cf49a9a25. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-develOK1247
source / vignettesOK678
linux-releaseOK938
macos-releaseOK1096
macos-oldrelOK1097
windows-develOK1464
windows-releaseOK1921
windows-oldrelOK1847
wasm-releaseOK192

Exports:adaptive_get_logsadaptive_item_logadaptive_rankadaptive_rank_resumeadaptive_rank_run_liveadaptive_rank_startadaptive_results_historyadaptive_round_logadaptive_step_logalternate_pair_orderanthropic_compare_pair_liveanthropic_create_batchanthropic_download_batch_resultsanthropic_get_batchanthropic_poll_batch_until_completebootstrap_bt_modelbuild_anthropic_batch_requestsbuild_bt_databuild_btl_results_databuild_elo_databuild_gemini_batch_requestsbuild_openai_batch_requestsbuild_promptcheck_llm_api_keyscheck_positional_biascompute_reverse_consistencyensemble_warm_start_algorithmsensemble_warm_start_modelsensure_only_ollama_model_loadedestimate_llm_pairs_costevaluate_rubric_predictionsextract_warm_start_featuresfit_bayes_btl_mcmcfit_bt_modelfit_elo_modelfit_linkfit_rubric_calibrationfit_warm_start_modelgemini_compare_pair_livegemini_create_batchgemini_download_batch_resultsgemini_get_batchgemini_poll_batch_until_completeget_prompt_templatelist_prompt_templateslist_warm_start_modelsllm_compare_pairllm_download_batch_resultsllm_resume_multi_batchesllm_submit_pairs_batchllm_submit_pairs_multi_batchload_adaptive_sessionload_link_sessionload_warm_start_modelmake_adaptive_judge_llmmake_adaptive_judge_replaymake_adaptive_replay_reservoirmake_pairsmake_warm_start_cv_planmake_warm_start_priorollama_compare_pair_liveopenai_compare_pair_liveopenai_create_batchopenai_download_batch_errorsopenai_download_batch_outputopenai_get_batchopenai_poll_batch_until_completeopenai_upload_batch_fileparse_anthropic_batch_outputparse_gemini_batch_outputparse_openai_batch_outputpredict_linkprepare_link_inputprepare_linked_rubric_referenceprepare_warm_start_modelrandomize_pair_orderread_samples_dfread_samples_dirregister_prompt_templateregister_warm_start_modelremove_prompt_templateremove_warm_start_modelresume_link_sessionrun_anthropic_batch_pipelinerun_gemini_batch_pipelinerun_openai_batch_pipelinesample_pairssample_reverse_pairssave_adaptive_sessionsave_link_sessionsave_warm_start_modelscale_separation_reliabilityset_prompt_templatestart_link_sessionsubmit_anthropic_pairs_livesubmit_gemini_pairs_livesubmit_llm_pairssubmit_ollama_pairs_livesubmit_openai_pairs_livesubmit_together_pairs_livesubmit_typesafe_pairs_livesubmit_vertex_pairs_livesummarize_adaptivesummarize_bt_fitsummarize_itemssummarize_refitstogether_compare_pair_livetrait_descriptiontypesafe_compare_pair_livevalidate_adaptive_replayvalidate_session_dirvertex_compare_pair_livewarm_start_coefficientswarm_start_feature_schemawarm_start_python_statuswrite_openai_batch_file

Dependencies:askpassclicurldplyrgenericsgluehttr2jsonlitelifecyclemagrittropensslpillarpkgconfigR6rlangsystibbletidyselectutf8vctrswithr

Advanced: Submitting and Polling Multiple Batches
Overview | Setup and API Keys | Example Data and Prompt Template | First batch: submit once, then resume | OpenAI storage, output limits, and error files | OpenAI Batch prompt caching and costs | Designing the Batch Grid | Submitting Many Batches with the Multi‑Batch Helpers | Create a run plan and output directory | Submit all runs (no polling) | Polling, Downloading, and Parsing (Resumable) | Building a single merged results table (all runs) | Resuming After Interruption | Next Steps | Citation

Last update: 2026-10-16
Started: 2025-12-05

Backends and Tested Model Configurations
Choose a backend and model | What the package supports | Dated compatibility record | Optional future checks | Decision-model live qualification | Reproduce the design without sharing private data | Citation

Last update: 2026-10-16
Started: 2026-09-06

Data Schemas and Prompt Management
Bring a spreadsheet or data frame | Samples and pairs | Traits and prompt templates | Decision instructions and probabilities | Provider and result schemas | Modeling and adaptive branches | Failure checks at schema boundaries | Related documentation | Citation

Last update: 2026-10-16
Started: 2026-09-06

Getting Started with pairwiseLLM
What you will do | Install the tools for this example | Your first result: scores from bundled comparisons | Read the scores | Read the reliability summary | An option for comparisons chosen in advance | An option for comparisons chosen adaptively | An experimental comparison with the Bayesian likelihood | Save an analysis | Prepare your own writing samples | Prepare a judging prompt | Collect a small set of new judgments | Configure one provider | Submit the pairs | Check what succeeded | Choose the next workflow | Common first-run problems | Citation

Last update: 2026-10-16
Started: 2025-12-05

Provider Controls and Recovery
Start with the symptom | Storage, sampling, and service tiers | Controls by backend | Live calls: retain successes and failures | Decision models: save, resume, and inspect | Batch recovery | Adaptive recovery | Ollama setup and resources | Privacy and retention | Estimate costs before a larger run | Deterministic calculation example | Reuse pilot results | Citation

Last update: 2026-10-16
Started: 2026-09-06

Guide: Linking Saved Comparisons
Start with the samples and their comparisons | Choose a method and fit the first comparison | Save your work and add the next comparison | Use saved uncertainty with E2 | Return to the original comparisons with E3 | Link a prepared standalone reference | Predict a comparison and check the result | Use saved Phase A results or several spokes | Dependency upgrades and saved hashes | Citation

Last update: 2026-10-14
Started: 2026-09-23

Bootstrap bias correction for BT scores
What the correction estimates | A fixed random schedule | An adaptive p50 schedule | Reading the results and managing cost | Reusing an external worker pool | Citation

Last update: 2026-10-10
Started: 2026-10-02

Guide: Adaptive Warm Start
Before you start | Choose where starting scores are used | Opt in to predictive uncertainty | Choose the initial graph independently | Count evidence consistently across arms | A complete example with three algorithms | Load example texts and inspect the features | Extract features when you have Python configured | Share the same training and validation splits | Fit the three algorithms | Inspect validation before combining models | Combine algorithms trained on this assessment | Predict new items and initialize an assessment | Save a model and resume a session | Combining models from separate assessments | Inspect calibrated standardized coefficients | Understand saved models | Citation

Last update: 2026-10-09
Started: 2026-09-09

Design: Adaptive Pairing
Reading guide | Foundational concepts | Glossary and units | Algorithm overview | Predictive initialization and connected bootstrap | Online TrueSkill update and selection utility | Post-bootstrap pairing strategies | Hybrid rounds, anchors, and rank strata | Hybrid candidate filters, coverage, and fallback | Conceptual example of one adaptive step | Coverage and exploration | Duplicate and degree controls | Fallback ladder | Global identification and hybrid long-link tapering | Bayesian BTL refits | Code-derived defaults | Diagnostics, reliability, and stopping | Audit trail and reproducibility | Citation

Last update: 2026-10-09
Started: 2026-09-06

Adaptive comparative judgment: estimation, reliability, and evaluation
Five related questions | Start with comparisons chosen in advance | Conventional fitting and estimator provenance | What the adjustments change | Internal reliability: SSR and Bayesian EAP | Scale Separation Reliability (SSR) | Bayesian BTL and EAP reliability | Collect an adaptive schedule | Hybrid recovery stays within hybrid | A small provider-free p50 run | Empirical recovery and scale dispersion | Held-out predictive evaluation | Schedule-aware parametric bootstrap | Fixed versus adaptive scheduling | What the Monte Carlo summaries mean | Experimental lapse and positional-bias model matching | Reporting the complete workflow | Citation

Last update: 2026-10-03
Started: 2026-10-03

Guide: Adaptive Pairing
What you will do | Choose a comparison workflow | Install and check CmdStan | A complete offline run with adaptive_rank() | Inspect the ranking and stopping state | Inspect comparisons and audit logs | What happens during a run? | Choose how later pairs are selected | Lower-level lifecycle and offline judges | Replay a sparse reservoir | Replay frozen directed judgments | Persistence, interruption, and resume | Invalid judgments and failed calls | A detailed live-LLM workflow | Inspect the live run | Continue the same study | Troubleshooting | Related documentation | Predictive warm-start priors | Citation

Last update: 2026-10-03
Started: 2026-02-10

Standalone Bayesian BTL with CmdStan
When to use this guide | Prerequisites | Prepare modeling input | Fit and summarize | What the output means | Chains and CPU allocation | Cumulative refits | Files, failures, and reproducibility | Predictive warm-start priors | Citation

Last update: 2026-10-03
Started: 2026-09-06

Guide: Rubric Calibration
Choose the workflow | What the research shows | Start from completed CJ results | Define the ordered rubric and labels | Same-set linear calibration | Read probabilities and hard scores | Evaluate held-out labels and inspect diagnostics | Explicit monotone alternative | Percentile levels without human labels | Reuse a historical rubric reference for a new set | Prepare a reference from a standalone ranking | Link the reference and new samples | Separate analytic traits | Uncertainty and reporting | Citation

Last update: 2026-10-01
Started: 2026-09-13

Design: Adaptive Linking
Coordinates, identification, and the judge model | E1: fixed-shape offset | E2: full-covariance Gaussian posterior bridge | E3: single-use joint-offset model | MAP/Laplace calculation | E3-MCMC audit engine | Evidence, prediction, and uncertainty contracts | Selection, probes, and stopping | Persistence, multiple spokes, and rubric transport | Frozen standalone rubric-reference identity | Why old Phase B sessions cannot resume | Citation

Last update: 2026-09-23
Started: 2026-09-06

Guide: Adaptive Linking
Choose what to retain from Phase A | Prepare your comparisons | Fit and inspect the link | Save, add comparisons, and reuse a reference | Restart a session from an older version | Citation

Last update: 2026-09-23
Started: 2026-09-06

Prompt Template Positional Bias Testing
How to read this guide | Motivation | Testing Process Summary | Trait descriptions and custom traits | Built-in traits | Setting a different built-in trait | Creating a custom trait | Why traits matter for positional bias testing | Example data used in tests | Built-in prompt templates | Forward and reverse pairs | Thinking / Reasoning Configurations Used in Testing | Anthropic (Claude 4.5 models) | thinking = "no_thinking" | thinking = "with_thinking" | Gemini 3 Pro Preview | Only thinking = "with_thinking" was used | OpenAI (gpt-4.1, gpt-4o, gpt-5.1) | thinking = "with_thinking" (gpt-5.1 only) | TogetherAI (Deepseek-R1, Deepseek-V3, Kimi-K2, Qwen3) | Summary of historical request configurations | Loading summary results | Column definitions | Interpreting the statistics | Summary results by prompt | Template test1 | Template text | Summary table | Template test2 | Template test3 | Template test4 | Template test5 | Per-backend summary | Anthropic models | Gemini models | OpenAI models | TogetherAI-hosted models | Conclusion | Citation

Last update: 2026-09-16
Started: 2025-12-11

Readme and manuals

Help Manual

Help pageTopics
Retrieve canonical adaptive logs.adaptive_get_logs
Adaptive item log accessor.adaptive_item_log
Run adaptive ranking end-to-end from data and model settingsadaptive_rank
Adaptive ranking resumeadaptive_rank_resume
Adaptive ranking live runneradaptive_rank_run_live
Adaptive rankingadaptive_rank_start
Adaptive results history ready for BT fittingadaptive_results_history
Adaptive round log accessor.adaptive_round_log
Adaptive step log accessor.adaptive_step_log
Deterministically alternate sample order in pairsalternate_pair_order
Live Anthropic (Claude) comparison for a single pair of samplesanthropic_compare_pair_live
Create an Anthropic Message Batchanthropic_create_batch
Download Anthropic Message Batch results (.jsonl)anthropic_download_batch_results
Retrieve an Anthropic Message Batch by IDanthropic_get_batch
Poll an Anthropic Message Batch until completionanthropic_poll_batch_until_complete
Schedule-aware parametric bootstrap bias correction for Bradley-Terry scoresbootstrap_bt_model
Build Anthropic Message Batch requests from a tibble of pairsbuild_anthropic_batch_requests
Build Bradley-Terry comparison data from pairwise resultsbuild_bt_data
Build canonical 'results_tbl' data for Bayesian BTL MCMCbuild_btl_results_data
Build EloChoice comparison data from pairwise resultsbuild_elo_data
Build Gemini batch requests from a tibble of pairsbuild_gemini_batch_requests
Build OpenAI batch JSONL lines for paired comparisonsbuild_openai_batch_requests
Build a concrete LLM prompt from a templatebuild_prompt
Check configured API keys for LLM backendscheck_llm_api_keys
Check positional preference and bootstrap reversal agreementcheck_positional_bias
Compute consistency between forward and reverse pair comparisonscompute_reverse_consistency
Live decision execution, persistence and recovery contractsdecision_bulk
Average algorithms trained on the same taskensemble_warm_start_algorithms
Combine independently trained warm-start modelsensemble_warm_start_models
Ensure only one Ollama model is loaded in memoryensure_only_ollama_model_loaded
Estimate LLM token usage and cost for a set of pairwise comparisonsestimate_llm_pairs_cost
Evaluate rubric predictions on observed ordered labelsevaluate_rubric_predictions
Example OpenAI Batch output (JSONL lines)example_openai_batch_output
Example dataset of paired comparisons for writing samplesexample_writing_pairs
Example canonical results table for writing comparisonsexample_writing_results
Example dataset of writing samplesexample_writing_samples
Synthetic Writing Samples with Controlled Quality Levels (N = 1000)example_writing_samples1000
Extract frozen writing features for warm-start predictionextract_warm_start_features
Full Bayesian BTL inference via CmdStanR (adaptive-compatible)fit_bayes_btl_mcmc
Fit a Bradley-Terry model with optional frequentist enginesfit_bt_model
Fit an EloChoice model to pairwise comparison datafit_elo_model
Fit a linker using prepared explicit evidencefit_link
Fit a rubric calibration to completed comparative judgmentsfit_rubric_calibration
Train a task-specific warm-start model with nested validationfit_warm_start_model
Live Google Gemini comparison for a single pair of samplesgemini_compare_pair_live
Create a Gemini Batch job from request objectsgemini_create_batch
Download Gemini Batch results to a JSONL filegemini_download_batch_results
Retrieve a Gemini Batch job by namegemini_get_batch
Poll a Gemini Batch job until completiongemini_poll_batch_until_complete
Retrieve a named prompt templateget_prompt_template
List available prompt templateslist_prompt_templates
Backend-agnostic live comparison for a single pair of samplesllm_compare_pair
Extract results from a pairwiseLLM batch objectllm_download_batch_results
Resume polling and download results for multiple batch jobsllm_resume_multi_batches
Submit pairs to an LLM backend via batch APIllm_submit_pairs_batch
Multi‑batch submission and polling wrappersllm_submit_pairs_multi_batch
Load an adaptive session from disk.load_adaptive_session
Build an LLM judge function for adaptive rankingmake_adaptive_judge_llm
Create an offline judge from frozen directed outcomesmake_adaptive_judge_replay
Create a sparse frozen adaptive replay reservoirmake_adaptive_replay_reservoir
Create all unordered pairs of writing samplesmake_pairs
Construct reusable warm-start cross-validation partitionsmake_warm_start_cv_plan
Convert warm-start predictions to Bayesian BTL priorsmake_warm_start_prior
Live Ollama comparison for a single pair of samplesollama_compare_pair_live
Live OpenAI comparison for a single pair of samplesopenai_compare_pair_live
Create an OpenAI batch from an uploaded fileopenai_create_batch
Download the error file for an OpenAI batchopenai_download_batch_errors
Download the output file for a completed batchopenai_download_batch_output
Retrieve an OpenAI batchopenai_get_batch
Poll an OpenAI batch until it completes or failsopenai_poll_batch_until_complete
Upload a JSONL batch file to OpenAIopenai_upload_batch_file
Portable task-specific warm-start modelspairwiseLLM_warm_model print.pairwiseLLM_warm_model summary.pairwiseLLM_warm_model
Parse Anthropic Message Batch output into a tibbleparse_anthropic_batch_output
Parse Gemini batch JSONL output into a tibble of pairwise resultsparse_gemini_batch_output
Parse an OpenAI Batch output JSONL fileparse_openai_batch_output
Predict oriented hub-spoke comparison probabilitiespredict_link
Predict pairwise win probabilities from an alpha-adjusted Bradley-Terry fitpredict.pairwiseLLM_bt_alpha
Predict pairwise win probabilities from a Firth Bradley-Terry fitpredict.pairwiseLLM_bt_firth
Predict ordered comparisons from an experimental lapse BTL fitpredict.pairwiseLLM_bt_lapse
Predict rubric scores from a calibrationpredict.pairwiseLLM_rubric_calibration
Predict with a same-task algorithm ensemblepredict.pairwiseLLM_warm_algorithm_ensemble
Predict with an equal-weight warm-start ensemblepredict.pairwiseLLM_warm_ensemble
Predict relative quality from a portable warm-start modelpredict.pairwiseLLM_warm_model
Prepare explicit evidence for a linking estimatorprepare_link_input
Save a standalone Bayesian ranking as a reusable rubric referenceprepare_linked_rubric_reference
Prepare metadata or a summary-only warm-start artifactprepare_warm_start_model
Print an adaptive state summary.print.adaptive_state
Print a pairwiseLLM cost estimateprint.pairwiseLLM_cost_estimate
Randomly assign samples to positions SAMPLE_1 and SAMPLE_2randomize_pair_order
Read writing samples from a data frameread_samples_df
Read writing samples from a directory of .txt filesread_samples_dir
Register a named prompt templateregister_prompt_template
Register, inspect, or remove user warm-start modelslist_warm_start_models register_warm_start_model remove_warm_start_model
Remove a registered prompt templateremove_prompt_template
Run an Anthropic batch pipeline for pairwise comparisonsrun_anthropic_batch_pipeline
Run a Gemini batch pipeline for pairwise comparisonsrun_gemini_batch_pipeline
Run a full OpenAI batch pipeline for pairwise comparisonsrun_openai_batch_pipeline
Randomly sample pairs of writing samplessample_pairs
Sample reversed versions of a subset of pairssample_reverse_pairs
Save an adaptive session to disk.save_adaptive_session
Save and load exact linking sessionsload_link_session save_link_session
Save or load a portable warm-start modelload_warm_start_model save_warm_start_model
Calculate scale-separation reliabilityscale_separation_reliability
Read or validate a prompt template for pairwise comparisonsset_prompt_template
Run and resume explicit-evidence linking sessionsresume_link_session start_link_session
Live Anthropic (Claude) comparisons for a tibble of pairssubmit_anthropic_pairs_live
Live Google Gemini comparisons for a tibble of pairssubmit_gemini_pairs_live
Backend-agnostic live comparisons for a tibble of pairssubmit_llm_pairs
Live Ollama comparisons for a tibble of pairssubmit_ollama_pairs_live
Live OpenAI comparisons for a tibble of pairssubmit_openai_pairs_live
Live Together.ai comparisons for a tibble of pairssubmit_together_pairs_live
Collect and resume live TypeSafe Jev decisionssubmit_typesafe_pairs_live
Live Vertex AI Gemini comparisons for a tibble of pairssubmit_vertex_pairs_live
Summarize an adaptive state.summarize_adaptive
Summarize a Bradley–Terry model fitsummarize_bt_fit
Summarize adaptive itemssummarize_items
Summarize adaptive refitssummarize_refits
Inspect explicit-evidence linking results and sessionsprint.pairwiseLLM_link_result print.pairwiseLLM_link_session summary.pairwiseLLM_link_result summary.pairwiseLLM_link_session
Inspect a same-task algorithm ensembleprint.pairwiseLLM_warm_algorithm_ensemble summary.pairwiseLLM_warm_algorithm_ensemble
Inspect a warm-start ensembleprint.pairwiseLLM_warm_ensemble summary.pairwiseLLM_warm_ensemble
Inspect ensemble predictionsprint.pairwiseLLM_warm_predictions summary.pairwiseLLM_warm_predictions
Live Together.ai comparison for a single pair of samplestogether_compare_pair_live
Get a trait name and description for promptstrait_description
Live TypeSafe Jev comparison for a single pair of samplestypesafe_compare_pair_live
Validate frozen directed judgments for an adaptive panelvalidate_adaptive_replay
Validate an adaptive session directory.validate_session_dir
Live Vertex AI Gemini comparison for a single pair of samplesvertex_compare_pair_live
Inspect calibrated standardized warm-start coefficientswarm_start_coefficients warm_start_coefficients.pairwiseLLM_warm_algorithm_ensemble warm_start_coefficients.pairwiseLLM_warm_ensemble warm_start_coefficients.pairwiseLLM_warm_model
Inspect the frozen warm-start writing feature schemawarm_start_feature_schema
Check the optional warm-start feature environmentwarm_start_python_status
Write an OpenAI batch table to a JSONL filewrite_openai_batch_file