SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2504.10637 · NeurIPS · 2025

Better Estimation of the Kullback-Leibler Divergence Between Language Models

Ryan Cotterell, Afra Amini, Tim Vieira

arXiv · PDF · Open in the Atlas

Code that ran

5 of 5 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 3 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 2 failures of our instrument; 0 no recorded run); 1 of them was also run on the host, not in the jail, by the peer-agreement lane that set its level, measured 2026-11-24; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2504.10637.json · badge: /api/ran/2504.10637.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
rycolab/kl-rb canonical (classifier label)
classifier basis: classifier_2025
5 ran · 0 no recorded run
FunctionStatusWhere it lives
pad Ran
ran, honoured the contract we drafted
rycolab/kl-rb/trl/trainer/utils.py
pointer only (licence: NONE) · get_code("2fee0ec1e42db0e2")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, rycolab/kl-rb when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

compute_kl Ran
ran, honoured the contract we drafted
rycolab/kl-rb/trl/trainer/utils.py
pointer only (licence: NONE) · get_code("fd37f7ac629f7673")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, rycolab/kl-rb when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

get_global_statistics Ran
ran; our contract draft was wrong, not the code
rycolab/kl-rb/trl/trainer/utils.py
pointer only (licence: NONE) · get_code("2887fe30b3acdea7")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, rycolab/kl-rb when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

get_positive_score Ran
ran, honoured the contract we drafted
rycolab/kl-rb/rloo_sentiment.py
pointer only (licence: NONE) · get_code("b6aad876161ad697")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, rycolab/kl-rb when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

load_prompts Ran
ran; our contract draft was wrong, not the code
rycolab/kl-rb/rloo_sentiment.py
pointer only (licence: NONE) · get_code("8c77fc1b61189419")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, rycolab/kl-rb when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 2 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 2 later) and 3 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
get_global_statistics 1 other paper
1 later
2606.18195 (2026-06)
Learning from the Self-future: On-policy Self-distillation for dLLMs
pad 1 other paper
1 later
2606.18195 (2026-06)
Learning from the Self-future: On-policy Self-distillation for dLLMs

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-24.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Estimating the Kullback-Leibler (KL) divergence between language models has many applications, e.g., reinforcement learning from human feedback (RLHF), interpretability, and knowledge distillation. However, computing the exact KL divergence between two arbitrary language models is intractable. Thus, practitioners often resort to sampling-based estimators. While it is easy to fashion a simple Monte Carlo (MC) estimator that provides an unbiased estimate of the KL divergence between language models, this estimator notoriously suffers from high variance and can even result in a negative estimate of the KL divergence, a non-negative quantity. In this paper, we introduce a Rao-Blackwellized estimator that is unbiased and provably has variance less than or equal to that of the standard Monte Carlo estimator. In an empirical study on sentiment-controlled fine-tuning, we show that our estimator provides more stable KL estimates and reduces variance substantially. Additionally, we derive an analogous Rao-Blackwellized estimator of the gradient of the KL divergence, which leads to more stable training and produces models that more frequently appear on the Pareto frontier of reward vs. KL compared to the ones trained with the MC estimator of the gradient. https://github.com/rycolab/kl-rb 39th Conference on Neural Information Processing Systems (NeurIPS 2025).

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2504.10637")
get_code_for_paper("2504.10637")
have("2504.10637")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2504.10637.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2504.10637.svg)](https://syntology.ai/paper/2504.10637)

Connect an agent — have() is free.