Alignment Data Quality and Rater Populations › A Deterministic Synthetic Experiment
Language AI HandbookAll chapters We now build a self-contained experiment that reproduces a composition-driven reversal and demonstrates a defensible reporting protocol. The synthetic groups are labeled G1 and G2. They are not stand-ins for any culture or demographic. They stand in for structured rater subgroups whose vote distributions differ: for example, two vendor teams, two skill bands, or two entry waves. The exercise will show what the data can and cannot tell us.
The experiment has three parts:
- Simulate two waves of rater votes with fixed per-group preference rates but different group-size mixes.
- Show that the pooled preference flips between waves while the generating probabilities stay fixed.
- Compute a target-weighted estimand with bootstrap confidence intervals and report it alongside the per-group rates and the naive pooled value.
Each synthetic person casts one Bernoulli vote with the probability assigned to that group. The simulation fixes the counts per wave and initializes the generator with seed 42. The subgroup probabilities remain the same, while observed fractions can fluctuate between draws.
PythonIn [5]Expand
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
rng = np.random.default_rng(42)
# Population preference rates ("ground truth" of our synthetic world).
# Each value is P(rater in this group prefers response Y over response X).
group_p_Y = {"G1": 0.70, "G2": 0.40}
# Two recruitment waves with different group mixes.
wave1_sizes = {"G1": 900, "G2": 100}
wave2_sizes = {"G1": 100, "G2": 900}
def simulate_wave(sizes, true_rates, rng, wave_label):
rows = []
for g, n in sizes.items():
votes = rng.binomial(1, true_rates[g], size=n)
for i, v in enumerate(votes):
rows.append(
{
"wave": wave_label,
"group": g,
"rater_id": f"{wave_label}-{g}-{i:05d}",
"vote_prefer_Y": int(v),
}
)
return pd.DataFrame(rows)
df1 = simulate_wave(wave1_sizes, group_p_Y, rng, "W1")
df2 = simulate_wave(wave2_sizes, group_p_Y, rng, "W2")
votes = pd.concat([df1, df2], ignore_index=True)ConsoleOut [6]Expand
wave group
W1 G1 900
G2 100
W2 G1 100
G2 900
Name: n_votes, dtype: int64
Total rows: 2000Wave 1 draws 900 votes from G1 and 100 from G2. Wave 2 swaps those counts and draws fresh votes from the same group probabilities. The design isolates the composition effect on the expected pooled rate. Realizations still vary with sampling.
Both the direct calculation and the bootstrap use the same cleaned table. In this example each independent rater contributes one row, with a known group label and a valid binary vote. The helper rejects missing or invalid entries instead of silently giving the two procedures different input rows.
PythonIn [7]Expand
def validate_vote_rows(df):
"""Require a nonempty table with a known group and binary vote per row."""
groups = df["group"]
has_blank_group = groups.map(
lambda value: isinstance(value, str) and not value.strip()
)
if df.empty or groups.isna().any() or has_blank_group.any():
raise ValueError(
"Every vote requires a known group in a nonempty table."
)
if not df["vote_prefer_Y"].isin([0, 1]).all():
raise ValueError("Every vote must be either 0 or 1.")
def summarize(df):
validate_vote_rows(df)
pooled = df["vote_prefer_Y"].mean()
by_group = df.groupby("group")["vote_prefer_Y"].mean()
sizes = df.groupby("group").size()
return pooled, by_group, sizes
pooled_w1, group_w1, size_w1 = summarize(df1)
pooled_w2, group_w2, size_w2 = summarize(df2)ConsoleOut [8]Expand
Wave 1:
pooled P(prefer Y) = 0.667
group rates = {'G1': np.float64(0.699), 'G2': np.float64(0.38)}
group sizes = {'G1': np.int64(900), 'G2': np.int64(100)}
Wave 2:
pooled P(prefer Y) = 0.434
group rates = {'G1': np.float64(0.71), 'G2': np.float64(0.403)}
group sizes = {'G1': np.int64(100), 'G2': np.int64(900)}The observed pooled rates are 0.667 and 0.434. In the model that generated the votes, the pooled probabilities are and . The group probabilities stay fixed while the sample weights change. The observed group fractions vary because each wave draws new votes.
VisualizationOut [9]Expand

The pooled rate estimates preference in the recruited mixture. If the deployment target uses different weights and preferences vary by group, the two estimates can differ. The pooled intervals are narrower in these two simulated waves. In Wave 1 the widths are 0.0560 for the pooled estimate and 0.0995 for equal group weights. In Wave 2 the corresponding widths are 0.0620 and 0.0950. The width depends on how you weight each group and how much uncertainty each group contributes.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!