Fishing for Magikarp: Automatically Detecting Under-trained Tokens in Large Language Models

Sander Land, Max Bartolo
5/8/2024
cs.CL

No official code found. Best implementation: cohere-ai/magikarp (191 stars, Apache-2.0, last commit 2026-04-14).

Abstract

The disconnect between tokenizer creation and model training in language models allows for specific inputs, such as the infamous SolidGoldMagikarp token, to induce unwanted model behaviour. Although such `glitch tokens', tokens present in the tokenizer vocabulary but that are nearly or entirely absent during model training, have been observed across various models, a reliable method to identify and address them has been missing. We present a comprehensive analysis of Large Language Model tokenizers, specifically targeting this issue of detecting under-trained tokens. Through a combination of tokenizer analysis, model weight-based indicators, and prompting techniques, we develop novel and effective methods for automatically detecting these problematic tokens. Our findings demonstrate the prevalence of such tokens across a diverse set of models and provide insights into improving the efficiency and safety of language models.

View on arXivView PDF

Code Implementations(1)

cohere-ai/magikarpCommunity100%
Apache-2.0

Code for the paper "Fishing for Magikarp"

19118Shell, PythonApr 29, 20246 months agoApache-2.0
large-language-modelstokenization

Similar Papers

Cite this paper

@article{land2024fishing,
  title  = {Fishing for Magikarp: Automatically Detecting Under-trained Tokens in Large Language Models},
  author = {Sander Land and Max Bartolo},
  year   = {2024},
  eprint = {2405.05417},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2405.05417v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2405.05417.svg)](https://codeofpaper.com/paper/2405.05417)

Discussion