How do I count distinct LLM users without storing user IDs?
Count distinct users from locally keyed IDs, then merge compatible measurements across workers.
Security
See the security reference.
Try the sample
Requires Python 3.11+. Count users in four synthetic records.
python3 -m venv .venv
.venv/bin/python -m pip install --no-cache-dir llm-sketchkit==0.3.0
.venv/bin/python - <<'PY'
import secrets
from llm_sketchkit import USER_V1, canonicalize_text_v1, hash64, hllpp
from llm_sketchkit.hash import Secret
secret = Secret(secrets.token_bytes(32))
users = hllpp.new("small", USER_V1)
for user_id in ("sample-user-a", "sample-user-b", "sample-user-a", "sample-user-c"):
users.add_hash(hash64(secret, USER_V1, canonicalize_text_v1(user_id)))
print(f"Estimated distinct users: {users.estimate():.0f}")
PY
What you'll see
Example output from this synthetic sample; your values will reflect your input.
Four input records contain three distinct user IDs. Adding the repeated ID does not add another distinct user.
Estimated distinct users: 3
Source: llm-sketchkit v0.3.0. The checked command above defines the complete synthetic input. Verification record.
What the numbers mean
Distinct counts are statistical estimates. Your application hashes raw IDs before they reach the sketch.
Measurement notes
evijay+fleetdiff@gmail.com ·
Questions ·
Ran it on your data? Tell us what it found ·
Security issues (private)