Vocabulary
What Is Vocabulary?
Vocabulary, in the context of natural language processing and information engineering, refers to the set of distinct tokens, words, subwords, or symbols that a system recognizes and can operate on when processing text. Every text processing pipeline operates with an explicit or implicit vocabulary: a finite collection of symbols that maps between the raw character stream and the internal representations used for computation. Defining the vocabulary is therefore one of the earliest and most consequential design decisions in building a language system, because it determines what the system can represent, how it handles novel words, and how efficiently it encodes the statistical regularities of a language.
The concept spans multiple disciplines. In linguistics, vocabulary refers to the lexical knowledge of a speaker or the attested word forms in a corpus. In electrical engineering and communications, vocabulary appears in signal dictionaries and codebook design. In machine learning, vocabulary specification governs how transformer models such as BERT and GPT tokenize input text before processing.
Vocabulary in Text Processing and Tokenization
A processing vocabulary is constructed from a training corpus by enumerating all unique tokens and, typically, selecting the most frequent ones up to a specified size. Rare words are assigned a special out-of-vocabulary (OOV) token, which allows the system to handle unseen input without crashing but at the cost of losing the specific information the rare word carried. Subword tokenization methods, including Byte Pair Encoding (BPE) and WordPiece, address this limitation by segmenting words into frequent subword units rather than treating whole words as atomic tokens. A vocabulary of 30,000 to 50,000 subword units, as used in systems like BERT and GPT-2, can represent virtually any word in any language by composing subword pieces, effectively eliminating hard OOV failures. Research published in Natural Language Processing and Computational Linguistics by MIT Press discusses the theoretical implications of different vocabulary representations for language model performance and generalization.
Statistical Properties and Ranking
Vocabulary statistics exhibit strong empirical regularities that have influenced both theoretical linguistics and practical system design. Zipf's law states that the frequency of a word in a large corpus is inversely proportional to its rank in the frequency-ordered vocabulary: the most frequent word occurs roughly twice as often as the second most frequent, three times as often as the third, and so on. Heaps' law (also called Herdan's law) describes how vocabulary size grows with corpus size: the number of distinct types scales as a power law of the total token count with an exponent typically between 0.4 and 0.6, meaning vocabulary size grows sublinearly. These regularities mean that no matter how large the training corpus, some fraction of words will appear only once (hapax legomena) and will be invisible to frequency-based ranking methods. The arxiv paper on how NLP relies on linguistics discusses how linguistic structure, including morphological decomposition, can improve vocabulary coverage in low-resource language settings where sparse token statistics make pure frequency-based selection unreliable.
The relationship between vocabulary and ranking is direct in information retrieval: term frequency-inverse document frequency (TF-IDF) scoring assigns each vocabulary item a weight that reflects how discriminative it is across the document collection. Terms appearing in nearly every document rank low in discriminative power and are sometimes removed as stop words, effectively shrinking the operational vocabulary to the items with the most retrieval value. The IBM overview of natural language processing places vocabulary design within the broader pipeline of text vectorization and embedding that underpins modern NLP systems.
Applications
Vocabulary has applications in a range of fields, including:
- Search engine indexing and document retrieval using inverted index structures
- Machine translation, where source and target vocabularies must be aligned
- Speech recognition, where acoustic models are constrained by lexical pronunciation dictionaries
- Sentiment analysis and content classification in social media monitoring
- Automated terminology extraction for standards documentation and technical dictionaries