Skip to content

v0.8.0 - Real BPE tokenizer (cl100k) + honesty fixes

Choose a tag to compare

@lukreitor lukreitor released this 27 Apr 13:09
· 1 commit to master since this release

✨ Features

Real LLM tokenizer (opt-in)

WTK now ships an optional cl100k_base BPE tokenizer (OpenAI GPT-3.5/4, ~95% Claude proxy). Default stays the fast bytes / 4 heuristic — turn on real counts when you need precision:

# Per-call
WTK_TOKENIZER=cl100k wtk find . -name "*.rs"

# Persistent
export WTK_TOKENIZER=cl100k

# Or in ~/.config/wtk/config.toml
[tracking]
tokenizer = "cl100k"

Adds ~5-30ms per filter call. The cl100k BPE table loads lazily on first use.

Reports show both chars and tokens

wtk gain now displays Chars saved and (when DB has tokenized rows) Tokens saved side by side, with a N/M rows, cl100k coverage indicator. The Active tokenizer: line at the bottom of the summary confirms the live mode.

🗄️ Database migration

Forward-only on next open: adds tokens_input, tokens_output, tokenizer_kind columns. Existing rows keep NULL for these — no data loss, queries handle the mixed state via COALESCE / IS NOT NULL.

🐛 Honesty fixes

  • Removed misleading "tokens" labels where the underlying number was bytes
  • ≈ X tokens line now reads ~X (heuristic: chars÷4, ASCII English) with explicit caveat
  • Internal format_tokens renamed to format_count to match its actual job

📦 Filter coverage

Heavy hitters migrated to retain raw text for accurate cl100k counting: find / fd, grep / rg, git, env, windows/* (tasklist, ipconfig, ...), all PowerShell cmdlets. Other filters keep the legacy path and contribute char counts only when cl100k is active.

⚠️ Why this matters

Live test on wtk ls /tmp (large file dump):

  • Chars saved: 173.5K
  • Heuristic estimate: ~43K tokens
  • Real cl100k count: 89.4K tokens — heuristic was off by 2x

File paths and structured output don't fit the chars/4 rule. cl100k mode reveals the truth.

📦 Install

```powershell
irm https://raw.githubusercontent.com/Lukreitor/wtk/master/install.ps1 | iex
```

Binary size: 5MB → 7.1MB (+2MB for cl100k BPE table).

Full Changelog: v0.7.0...v0.8.0