Tokenisation is a fundamental preprocessing step in natural language processing (NLP) that involves breaking down text into smaller units called tokens. These tokens can be words, subwords, or characters, and they serve as the basic input units for language models like GPT, BERT, and other transformer architectures.
In the context of large language models (LLMs), tokenisation is crucial because it converts raw text into a format that the model can understand. The process typically involves:
- Splitting text: The input text is segmented based on whitespace, punctuation, or learned rules.
- Mapping to IDs: Each unique token in the vocabulary is assigned a numerical ID, which the model processes.
- Handling out-of-vocabulary words: Common tokenisation algorithms like Byte-Pair Encoding (BPE) or WordPiece can break unknown words into known subword units.
Efficient tokenisation enables models to handle diverse languages, reduce vocabulary size, and improve computational efficiency. It also directly impacts model performance—poor tokenisation can lead to loss of meaning or increased inference time.
Tokenisation is the bridge between human language and machine understanding. Without it, even the most advanced AI would struggle to parse a simple sentence.
In practice, tokenisation is implemented using libraries such as Hugging Face's tokenizers, spaCy, or custom pipelines. For LLMs, subword tokenisation is the standard, balancing character-level flexibility with word-level efficiency.
As AI models continue to scale, the role of tokenisation remains a key area of research, with newer methods like Unigram or SentencePiece emerging for multilingual and code-switching scenarios.