Accessibility and Inclusive Language AI › Worked Example: Modeling Coverage Across Interaction Modes and Languages

Michael BrenndoerferDecember 2, 20267 min read
Language AI HandbookAll chapters
Part 62 of 67Human-AI Interaction and Governance
Chapter 475Accessibility and Inclusive Language AI › Worked Example: Modeling Coverage Across Interaction Modes and Languages
Reading section 7 of 11 · Worked Example: Modeling Coverage Across Interaction Modes and Languages · 7 minSection 7 of 11 · 7 min

Section 7 of 11 · 7 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

Let's make these ideas operational. We'll simulate a plausible evaluation of a language AI assistant across interaction modes and languages, deliberately constructing a sample that underrepresents some strata, and then quantify what that does to aggregate conclusions.

We start by setting up a reproducible environment and a plotting style.

PythonIn [7]
CollapseExpand
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from book_plot_style import PALETTE, polish_axes, theme_color, use_book_style

rng = np.random.default_rng(20240501)

We define a small, plausible set of interaction modes and languages. Each combination is a stratum. Each stratum gets an invented success probability and target share. The recruitment model assigns different probabilities of drawing each stratum. This creates a study mix that can differ from the target mix.

PythonIn [8]
CollapseExpand
strata = pd.DataFrame(
    {
        "mode": [
            "keyboard",
            "keyboard",
            "speech",
            "speech",
            "switch",
            "switch",
            "screen_reader",
            "screen_reader",
        ],
        "language": [
            "English",
            "Swahili",
            "English",
            "Swahili",
            "English",
            "Swahili",
            "English",
            "Swahili",
        ],
        "population_share": [0.40, 0.05, 0.22, 0.03, 0.10, 0.02, 0.13, 0.05],
        "true_success": [0.94, 0.55, 0.86, 0.48, 0.72, 0.35, 0.80, 0.40],
    }
)

strata["stratum"] = strata["mode"] + " / " + strata["language"]
strata[["stratum", "population_share", "true_success"]].round(2)

The assumed success probabilities range from 0.35 for Swahili switch use to 0.94 for English keyboard use in this fictional setup. The true population-weighted benefit (population_share × true_success summed) is:

PythonIn [9]
CollapseExpand
true_pop_benefit = (strata["population_share"] * strata["true_success"]).sum()
ConsoleOut [10]
CollapseExpand
True population-weighted completion: 0.810

The next study has n=120n=120 synthetic trials. The participation weights give different probabilities of drawing each interaction-language setup. They do not represent observed recruitment.

PythonIn [11]
CollapseExpand
participation_weight = np.array([1.0, 0.5, 0.8, 0.3, 0.4, 0.15, 0.6, 0.2])
p = participation_weight / participation_weight.sum()
counts = rng.multinomial(120, p)
strata["sampled_n"] = counts
Out[12]:
stratum population_share sampled_n true_success
0 keyboard / English 0.40 33 0.94
1 keyboard / Swahili 0.05 8 0.55
2 speech / English 0.22 21 0.86
3 speech / Swahili 0.03 9 0.48
4 switch / English 0.10 13 0.72
5 switch / Swahili 0.02 5 0.35
6 screen_reader / English 0.13 25 0.80
7 screen_reader / Swahili 0.05 6 0.40

Now we simulate outcomes for each sampled user and estimate success per stratum.

PythonIn [13]
CollapseExpand
def simulate_success(true_p, n):
    return rng.binomial(n, true_p)


strata["observed_success"] = [
    simulate_success(tp, n) / n if n else np.nan
    for tp, n in zip(strata["true_success"], strata["sampled_n"])
]
Out[14]:
stratum sampled_n observed_success
0 keyboard / English 33 0.94
1 keyboard / Swahili 8 0.62
2 speech / English 21 1.00
3 speech / Swahili 9 0.33
4 switch / English 13 1.00
5 switch / Swahili 5 0.60
6 screen_reader / English 25 0.84
7 screen_reader / Swahili 6 0.50

The participation weights sum to 3.95. Switch access in Swahili has weight 0.15, so the expected count under the multinomial design is 120(0.15/3.95)≈4.56120(0.15/3.95) \approx 4.56. The realized count is random. A zero count means we leave the observed rate missing. Compare the equal-weight mean of measured strata, the pooled study rate, and the population-weighted estimate.

PythonIn [15]
CollapseExpand
naive_agg = strata["observed_success"].mean()
observed = strata["sampled_n"].gt(0)
pooled_rate = np.average(
    strata.loc[observed, "observed_success"],
    weights=strata.loc[observed, "sampled_n"],
)
pop_weighted_est = (
    strata["population_share"] * strata["observed_success"]
).sum(skipna=False)
ConsoleOut [16]
CollapseExpand
Equal-weight mean of measured strata: 0.730
Pooled study completion:             0.833
Population-weighted estimate:            0.883
True population-weighted completion:     0.810

The equal-stratum mean gives every measured group the same weight. The pooled rate uses study shares, and the population-weighted estimate uses target shares. The latter accounts for differences in the mix of groups when estimates within each sampled group transfer to the target group. Weighting cannot recover a group with no observations or correct selection bias within groups.

Let's visualize the coverage gap: population share versus sampled share, and the observed success interval for each stratum.

PythonIn [17]
CollapseExpand
from math import sqrt


def wilson_interval(p_hat, n, z=1.96):
    if n == 0:
        return (np.nan, np.nan)
    denom = 1 + z**2 / n
    center = (p_hat + z**2 / (2 * n)) / denom
    half = z * sqrt(p_hat * (1 - p_hat) / n + z**2 / (4 * n**2)) / denom
    return (max(0.0, center - half), min(1.0, center + half))


strata = strata.sort_values("stratum").reset_index(drop=True)
strata["sampled_share"] = strata["sampled_n"] / strata["sampled_n"].sum()
intervals = [
    wilson_interval(p_hat, n)
    for p_hat, n in zip(strata["observed_success"], strata["sampled_n"])
]
strata["ci_low"] = [lo for lo, hi in intervals]
strata["ci_high"] = [hi for lo, hi in intervals]
VisualizationOut [18]
CollapseExpand
Grouped bar chart comparing population share and sampled share across interaction modes and languages.
Population share versus sampled share for each interaction mode and language stratum. Both sets of shares are generated from assumptions in the fictional example.

Compare the two bars within each group. A group can have many observations and still account for a smaller share of the study than of the target population. The direction of the difference depends on the assumed recruitment weights and this particular sample.

Now let's visualize the per-stratum success estimates with their uncertainty intervals, ordered to emphasize the stratification.

VisualizationOut [19]
CollapseExpand
Observed completion dots with Wilson intervals and simulated values marked by crosses.
Observed task completion per stratum with Wilson 95% confidence intervals. Wide intervals indicate imprecise estimates; groups with no trials have no measured estimate.

The plotted intervals show uncertainty in the observed group rates under the binomial model. They are individual intervals. A decision covering all strata needs its own evidence rule, accounting for repeated users or simultaneous comparisons when those matter.

Making the Decision Explicit

A responsible deployment decision uses this evaluation to answer a specific question: does this system meet a minimum bar in every stratum in which it will be used? A defensible policy is a max-min criterion combined with a minimum evidence threshold. It requires that even the worst-served stratum clears a bar before the system ships, so a system cannot be certified on the strength of its best groups:

ng≥nmin⁡ and p^g≥τfor every intended stratum g.n_g \ge n_{\min} \text{ and } \hat{p}_g \ge \tau \qquad \text{for every intended stratum }g.

where:

  • gg: an index over population strata
  • ngn_g: the number of sampled users in stratum gg
  • nmin⁡n_{\min}: the minimum stratum sample size required for evidence to count
  • p^g\hat{p}_g: the observed completion rate in stratum gg
  • τ\tau: the minimum acceptable completion rate

Require ng≥nmin⁡n_g \ge n_{\min} for every intended stratum as a separate condition, and apply the rate threshold only after that condition holds. Under this rule, strata with too little evidence block shipping until they are studied, and a system cannot be certified on the strength of its best-served group. This is a concrete way to operationalize the accessibility principle that inclusion cannot be averaged away.

Choose both parameters before evaluating the system. The threshold τ\tau encodes the minimum acceptable completion rate for any stratum that will be served; it answers "how bad is too bad?" The evidence minimum nmin⁡n_{\min} encodes how much data is needed before a stratum's estimate counts; it sets a minimum number of observations and does not, on its own, guarantee a confidence level. Together they make the decision block on two failure modes: a stratum that is measurably too poor, and a stratum that is too thinly studied to know. A system can fail for either reason, and either failure is a defensible reason not to ship.

The policy asks each intended group to meet both an evidence threshold and a minimum observed rate. The threshold is illustrative. A release criterion could instead compare a lower confidence bound to the minimum, and set the evidence requirement before inspecting the results.

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!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy