LLM MeasurementGitHub
Guides

Who is tokenmaxxing? Find your heaviest AI token users

No spike needed: rank who uses the most tokens in a period, and see how concentrated usage is.

Collect user rankings

Configure user-key rankings on GenAI spans, then retain summary windows. Use a user identity attribute and one hashing key.

Already have a usage file?

Requires Python 3.11+ and usage.csv with user_id,tokens columns. Get the user count, total tokens and heaviest users.

Run the Python ranking recipe
python3 -m venv .venv
.venv/bin/python -m pip install --no-cache-dir llm-sketchkit==0.3.0
.venv/bin/python - <<'PY'
import csv
import secrets
from llm_sketchkit import USER_V1, canonicalize_text_v1, hash64, hllpp, frequentitems
from llm_sketchkit.hash import Secret

secret = Secret(secrets.token_bytes(32))  # use your protected key for repeatable reports
users = hllpp.new("small", USER_V1)
ranking = frequentitems.Sketch("small", USER_V1)
total = 0
with open("usage.csv", newline="") as source:
    for row in csv.DictReader(source):
        if not row.get("user_id") or not row.get("tokens", "").isascii() or not row["tokens"].isdigit():
            raise SystemExit("Each row needs user_id and nonnegative integer tokens.")
        tokens = int(row["tokens"])
        if tokens > 2**63 - 1 or total + tokens > 2**63 - 1:
            raise SystemExit("Token total exceeds this example's supported range.")
        digest = hash64(secret, USER_V1, canonicalize_text_v1(row["user_id"]))
        users.add_hash(digest)
        if tokens:
            ranking.add_hash(digest, tokens)
        total += tokens
print(f"Estimated distinct users: {users.estimate():.0f}")
print(f"Recorded tokens: {total:,}")
items = sorted(ranking.frequent_items(frequentitems.NO_FALSE_NEGATIVES),
               key=lambda item: item.lower_bound, reverse=True)[:5]
for rank, item in enumerate(items, 1):
    print(f"user-{rank}: [{item.lower_bound:,}, {item.upper_bound:,}] tokens")
if total:
    low = sum(item.lower_bound for item in items) / total
    high = min(1, sum(item.upper_bound for item in items) / total)
    print(f"Displayed users account for {low:.1%} to {high:.1%} of tokens.")
PY
Security

See the security reference.

Try the sample

Requires Python 3.11+. Rank a synthetic week of usage.

python3 -m venv .venv
.venv/bin/python -m pip install --no-cache-dir llm-sketchkit==0.3.0
.venv/bin/python - <<'PY'
import random
import secrets
from llm_sketchkit import USER_V1, canonicalize_text_v1, frequentitems, hash64
from llm_sketchkit.hash import Secret

secret = Secret(secrets.token_bytes(32))  # use your protected key in practice
ranking = frequentitems.Sketch("small", USER_V1)
total = 0

# One synthetic week: 60 people with heavy-tailed session sizes.
rng = random.Random(2026)
for n in range(60):
    digest = hash64(secret, USER_V1, canonicalize_text_v1(f"person-{n:02d}@example.com"))
    for _ in range(rng.randint(3, 25)):
        tokens = int(20_000 * rng.paretovariate(1.2))
        ranking.add_hash(digest, tokens)
        total += tokens

items = ranking.frequent_items(frequentitems.NO_FALSE_NEGATIVES)
assert ranking.max_error() == 0  # This 60-user example fits in the 512-entry ranking.
people = len(items)
top = sorted(items, key=lambda i: i.lower_bound, reverse=True)[:5]
print(f"People using AI this week: {people}")
print(f"Total reported tokens: {total:,}")
print("Heaviest users (keyed; only the key holder can look them up):")
for rank, item in enumerate(top, 1):
    exact = item.lower_bound == item.upper_bound
    amount = f"{item.lower_bound:,}" if exact else f"{item.lower_bound:,} to {item.upper_bound:,}"
    print(f"  #{rank}: {amount} tokens")
low = sum(i.lower_bound for i in top) / total
high = min(1.0, sum(i.upper_bound for i in top) / total)
share = f"{low:.0%}" if f"{low:.0%}" == f"{high:.0%}" else f"{low:.0%} to {high:.0%}"
print(f"The top 5 of {people} people account for {share} of all tokens.")
PY

What you'll see

Example output from this synthetic sample; your values will reflect your input.

In this synthetic week, 5 of 60 people account for 43% of reported tokens. The ranking holds keyed values, not names; whoever holds the key can look up a person by hashing a known ID.

People using AI this week: 60
Total reported tokens: 78,126,732
Heaviest users (keyed; only the key holder can look them up):
  #1: 17,034,328 tokens
  #2: 8,652,754 tokens
  #3: 3,136,006 tokens
  #4: 2,615,589 tokens
  #5: 2,273,034 tokens
The top 5 of 60 people account for 43% of all tokens.

To see who caused a jump between two periods, see Which user is driving my token spike?

Source: llm-sketchkit v0.3.0. The checked command above defines the complete synthetic input. Verification record.

What the numbers mean

Reported tokens measure usage, not productivity or useful work. Rankings from keyed IDs are pseudonymous: whoever holds the key can identify people.
Measurement notes

evijay+fleetdiff@gmail.com · Questions · Ran it on your data? Tell us what it found · Security issues (private)