Sub topic 12
Measuring quality: acceptance rate, latency and retention
This chapter assumes you know how a completion request is built and cancelled, and that you can read short Python. It covers the three measures most teams use to judge a completion or next edit suggestion feature, and the mistakes that make those numbers misleading.
The funnel behind the numbers
Every suggestion passes through stages. Each metric measures one stage, so the denominators matter.
Many requests never reach the screen. Debouncing and cancellation drop some, post-processing filters others, and the user may type past the suggestion before it renders.
Acceptance rate
Acceptance rate is accepted suggestions divided by suggestions shown. Use "shown" as the denominator, not "requested". Dividing by requests punishes you for cancelled or filtered requests that the user never saw.
Acceptance rate is easy to game. A feature that shows only obvious suggestions, such as a closing bracket, scores high and helps little. Track accepted characters per session as well, so long accepted suggestions count for more than trivial ones. Partial acceptance (for example, word by word) needs a rule. Most teams count any acceptance as one, and also record the share of characters accepted.
Latency
Latency is the time from the keystroke that triggered a request to the moment ghost text appears. It includes your debounce delay, so report it alongside the debounce setting.
Report percentiles, not the mean. A few very slow requests barely move an average but ruin the experience. Watch p50 for the typical case and p95 for the worst regular case. Suggestions that arrive after the user has typed more are discarded, so slow responses lower acceptance rate indirectly.
Retention
Retention asks whether accepted text survives. Measure the share of accepted characters still in the file after a fixed delay, such as 30 seconds or 5 minutes. A suggestion accepted and then deleted was probably wrong, or accepted by reflex. Retention is the check on acceptance rate: high acceptance with low retention means users are accepting and then fixing.
Computing the metrics
This script turns logged events into the three measures. Each event records one request.
from dataclasses import dataclass
from statistics import quantiles
@dataclass
class Event:
shown: bool
accepted: bool
latency_ms: float
chars_accepted: int = 0
chars_kept: int = 0 # accepted characters still present at the check time
def summarize(events: list[Event]) -> dict:
shown = [e for e in events if e.shown]
accepted = [e for e in shown if e.accepted]
cuts = quantiles([e.latency_ms for e in shown], n=20) # 19 cut points
total_chars = sum(e.chars_accepted for e in accepted)
kept_chars = sum(e.chars_kept for e in accepted)
return {
"acceptance_rate": len(accepted) / len(shown),
"latency_p50_ms": cuts[9],
"latency_p95_ms": cuts[18],
"retention": kept_chars / total_chars if total_chars else 0.0,
}
events = [
Event(True, True, 180, 20, 18),
Event(True, False, 240),
Event(True, True, 310, 40, 10),
Event(True, False, 900),
Event(False, False, 120), # cancelled before display, excluded
]
print(summarize(events))The cancelled event is excluded from every metric. Including it would lower acceptance rate and hide the real latency.
Common errors
| Mistake | Effect | Fix |
|---|---|---|
| Dividing by requests, not shown | Acceptance rate looks low | Count only displayed suggestions |
| Averaging latency | Slow outliers hidden | Report p50 and p95 |
| Optimizing acceptance alone | Short, trivial suggestions win | Pair with retention and characters accepted |
| Comparing completions to next edit suggestions directly | Misleading verdict | Compare each against its own baseline |
Completions and next edit suggestions differ in size, trigger and interface. A next edit suggestion is often rarer and larger, so its acceptance rate and latency budget differ. Compare each feature with its own earlier versions.
Exercise
Users accept 60% of shown suggestions, but only 25% of accepted characters remain after five minutes. What does this suggest, and which metric would you not trust alone?
Show answer
Users accept many suggestions and then delete or rewrite them, so the suggestions are often wrong or only superficially useful. Acceptance rate alone should not be trusted. Retention shows the real value, and both should be tracked together.