Understand tokenx terminology and concepts
mainTo use tokenx effectively, it is important to use its specific terminology to avoid confusion with standard NLP or LLM concepts:
- Token: The unit being estimated. Note that
tokenxprovides an estimate, not an exact count. Avoid using terms like 'word' or 'character'. - Reference tokenizer: The ground truth used for calibration, specifically OpenAI's
o200k_baseencoding (used by GPT-4o, o-series, etc.). - Segment: The atomic unit of estimation (a run of text like a word or punctuation) that is never subdivided.
- Deviation: The relative difference between the
tokenxestimate and the reference tokenizer. Positive means overestimation; negative means underestimation. Avoid 'accuracy percentage' or 'error rate'. - Register: The variety of language (e.g., technical documentation vs. everyday prose). This is a primary driver of Deviation. Avoid 'genre' or 'domain'.
- Language config: A rule pairing a script-detection pattern with its average characters per token. Custom configs take precedence over built-in heuristics.
- Chunk: A contiguous piece of text produced by splitting, sized by estimated tokens.
- Target chunk size: The estimated token count at which a chunk closes. This is a soft threshold; chunks may exceed it if a single segment crosses the boundary.
- Overlap: Trailing tokens from one chunk repeated at the start of the next to preserve context. Overlap is always smaller than the target chunk size.