Repeated labels for the same board do not automatically cancel each other out. Under cross-entropy, they tell the model to imitate their frequency. The more useful question is whether that frequency is the target you intended.
Erik Schluntz’s new chess-transformer write-up describes positions repeated with different suggested moves. He groups alternatives into score-derived soft labels, but also reports a later ablation in which keeping only the best alternative learned just as well. [1] I want to unpack the target-design choice without turning that observation into a universal rule about distillation.
Write down what the rows ask for
Take one invented board with four rows: moves A, A, B and C. Let the model’s predicted probabilities be qA, qB and qC. The average loss for those rows is:
L = -(2 log(qA) + log(qB) + log(qC)) / 4
That is exactly cross-entropy against the target (1/2, 1/4, 1/4). The gradients are compatible with a distribution over moves. They do not require the network to assign probability one to every alternative at once.
For positive probabilities summing to one, this loss is minimized at that empirical target. One way to see it is to minimize -sum(p_i log(q_i)) with a normalization multiplier: differentiating gives q_i = p_i / lambda, and summing gives lambda = 1.
Original computed probability illustration. Moves and scores are invented; these are not model predictions. Image by Shivam Dwivedi.
The catch is in the denominator. If another board has only one row, ordinary row sampling gives the four-row board four times its weight. Combining each board into one equally weighted example changes that weighting even if its within-board target stays the same.
Scores answer a different question
Suppose the alternatives instead carry scores 100, 50 and 0, all measured on the same scale from the same player’s perspective. A chosen softmax temperature of 50 gives probabilities about 0.665, 0.245, 0.090. Those probabilities reflect score gaps, not how often a row happened to appear.
Schluntz uses a centipawn-temperature transformation in his pipeline. [1] My scores below are deliberately invented. They illustrate the transformation without claiming that a search score is a calibrated probability of playing a move.
Save this as targets.py and run python3 targets.py. It needs only Python’s standard library.
import math
from fractions import Fraction as F
rows = ('A', 'A', 'B', 'C')
empirical = [F(rows.count(move), len(rows)) for move in 'ABC']
q = [0.6, 0.3, 0.1]
row_loss = -sum(math.log(q['ABC'.index(m)]) for m in rows) / len(rows)
group_loss = -sum(float(p) * math.log(v) for p, v in zip(empirical, q))
assert math.isclose(row_loss, group_loss, abs_tol=1e-12)
def target(scores, temperature):
if temperature <= 0:
raise ValueError('temperature must be positive')
peak = max(scores)
weights = [math.exp((s - peak) / temperature) for s in scores]
total = math.fsum(weights)
return [w / total for w in weights]
scores = [100, 50, 0]
p = target(scores, 50)
assert math.isclose(math.fsum(p), 1.0, abs_tol=1e-12)
assert all(math.isclose(a, b) for a, b in zip(p, target([s+900 for s in scores], 50)))
assert target(scores, 10)[0] > p[0] > target(scores, 100)[0]
try:
target(scores, 0)
except ValueError:
pass
else:
raise AssertionError('zero temperature accepted')
print('row target:', ' '.join(str(x) for x in empirical))
print('same loss:', f'{row_loss:.6f}', f'{group_loss:.6f}')
print('score target:', ' '.join(f'{x:.3f}' for x in p))
row target: 1/2 1/4 1/4
same loss: 1.132052 1.132052
score target: 0.665 0.245 0.090
Subtracting the largest score keeps the exponentials at most one while preserving their ratios. Adding the same constant to every score therefore leaves the target unchanged. A smaller positive temperature concentrates this example more strongly on its top score; zero is rejected instead of silently dividing by it.
The loss check uses a separate predicted distribution, 0.6, 0.3, 0.1. It verifies the algebraic equivalence between averaging these rows and using their empirical target. It does not compare training methods.
Keep the simple target in the comparison
Before merging labels, I would define the board key, whose perspective the score uses, how repeated moves are combined, and how different search depths are treated. A softmax cannot repair incompatible meanings in its inputs. A move vocabulary also does not tell you which moves are legal in a particular position.
There are then separate choices: preserve row frequencies, give each board equal weight, retain only the strongest candidate, or train on a score-derived distribution. Name the choice in the data pipeline. “Deduplicated” is too vague to describe all of them.
The source’s best-only ablation is a useful reminder to keep that baseline. Its result belongs to that project; this calculation cannot establish which target will train your model better. I ran the arithmetic shown here, without downloading chess data, training a network or reproducing an Elo result.
References
Erik Schluntz, Training a Chess Transformer, especially data preparation, soft labels and the later ablation.
Python documentation, mathematical functions, for exponentials, logarithms and accurate summation.
Asset credits
Original figure and illustrative example, CC BY 4.0. Credit: Shivam Dwivedi. No third-party images reproduced.
AI disclosure
AI was used to draft the article.

Top comments (0)