LogoLogo
Continuum WebsiteContinuum ApplicationsContinuum KnowledgeAxolotl Platform
Continuum Knowledge
Continuum Knowledge
  • Continuum
  • Data
    • Datasets
      • Pre Training Data
      • Types of Fine Tuning
      • Self Instruct Paper
      • Self-Alignment with Instruction Backtranslation
      • Systematic Evaluation of Instruction-Tuned Large Language Models on Open Datasets
      • Instruction Tuning
      • Instruction Fine Tuning - Alpagasus
      • Less is More For Alignment
      • Enhanced Supervised Fine Tuning
      • Visualising Data using t-SNE
      • UMAP: Uniform Manifold Approximation and Projection for Dimension Reduction
      • Training and Evaluation Datasets
      • What is perplexity?
  • MODELS
    • Foundation Models
      • The leaderboard
      • Foundation Models
      • LLama 2 - Analysis
      • Analysis of Llama 3
      • Llama 3.1 series
      • Google Gemini 1.5
      • Platypus: Quick, Cheap, and Powerful Refinement of LLMs
      • Mixtral of Experts
      • Mixture-of-Agents (MoA)
      • Phi 1.5
        • Refining the Art of AI Training: A Deep Dive into Phi 1.5's Innovative Approach
      • Phi 2.0
      • Phi-3 Technical Report
  • Training
    • The Fine Tuning Process
      • Why fine tune?
        • Does Fine-Tuning LLMs on New Knowledge Encourage Hallucinations?
        • Explanations in Fine Tuning
      • Tokenization
        • Tokenization Is More Than Compression
        • Tokenization - SentencePiece
        • Tokenization explore
        • Tokenizer Choice For LLM Training: Negligible or Crucial?
        • Getting the most out of your tokenizer for pre-training and domain adaptation
        • TokenMonster
      • Parameter Efficient Fine Tuning
        • P-Tuning
          • The Power of Scale for Parameter-Efficient Prompt Tuning
        • Prefix-Tuning: Optimizing Continuous Prompts for Generation
        • Harnessing the Power of PEFT: A Smarter Approach to Fine-tuning Pre-trained Models
        • What is Low-Rank Adaptation (LoRA) - explained by the inventor
        • Low Rank Adaptation (Lora)
        • Practical Tips for Fine-tuning LMs Using LoRA (Low-Rank Adaptation)
        • QLORA: Efficient Finetuning of Quantized LLMs
        • Bits and Bytes
        • The Magic behind Qlora
        • Practical Guide to LoRA: Tips and Tricks for Effective Model Adaptation
        • The quantization constant
        • QLORA: Efficient Finetuning of Quantized Language Models
        • QLORA and Fine-Tuning of Quantized Language Models (LMs)
        • ReLoRA: High-Rank Training Through Low-Rank Updates
        • SLoRA: Federated Parameter Efficient Fine-Tuning of Language Models
        • GaLora: Memory-Efficient LLM Training by Gradient Low-Rank Projection
      • Hyperparameters
        • Batch Size
        • Padding Tokens
        • Mixed precision training
        • FP8 Formats for Deep Learning
        • Floating Point Numbers
        • Batch Size and Model loss
        • Batch Normalisation
        • Rethinking Learning Rate Tuning in the Era of Language Models
        • Sample Packing
        • Gradient accumulation
        • A process for choosing the learning rate
        • Learning Rate Scheduler
        • Checkpoints
        • A Survey on Efficient Training of Transformers
        • Sequence Length Warmup
        • Understanding Training vs. Evaluation Data Splits
        • Cross-entropy loss
        • Weight Decay
        • Optimiser
        • Caching
      • Training Processes
        • Extending the context window
        • PyTorch Fully Sharded Data Parallel (FSDP)
        • Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
        • YaRN: Efficient Context Window Extension of Large Language Models
        • Sliding Window Attention
        • LongRoPE
        • Reinforcement Learning
        • An introduction to reinforcement learning
        • Reinforcement Learning from Human Feedback (RLHF)
        • Direct Preference Optimization: Your Language Model is Secretly a Reward Model
  • INFERENCE
    • Why is inference important?
      • Grouped Query Attention
      • Key Value Cache
      • Flash Attention
      • Flash Attention 2
      • StreamingLLM
      • Paged Attention and vLLM
      • TensorRT-LLM
      • Torchscript
      • NVIDIA L40S GPU
      • Triton Inference Server - Introduction
      • Triton Inference Server
      • FiDO: Fusion-in-Decoder optimised for stronger performance and faster inference
      • Is PUE a useful measure of data centre performance?
      • SLORA
  • KNOWLEDGE
    • Vector Databases
      • A Comprehensive Survey on Vector Databases
      • Vector database management systems: Fundamental concepts, use-cases, and current challenges
      • Using the Output Embedding to Improve Language Models
      • Decoding Sentence-BERT
      • ColBERT: Efficient and Effective Passage Search via Contextualized Late Interaction over BERT
      • SimCSE: Simple Contrastive Learning of Sentence Embeddings
      • Questions Are All You Need to Train a Dense Passage Retriever
      • Improving Text Embeddings with Large Language Models
      • Massive Text Embedding Benchmark
      • RocketQAv2: A Joint Training Method for Dense Passage Retrieval and Passage Re-ranking
      • LLM2Vec: Large Language Models Are Secretly Powerful Text Encoders
      • Embedding and Fine-Tuning in Neural Language Models
      • Embedding Model Construction
      • Demystifying Embedding Spaces using Large Language Models
      • Fine-Tuning Llama for Multi-Stage Text Retrieval
      • Large Language Model Based Text Augmentation Enhanced Personality Detection Model
      • One Embedder, Any Task: Instruction-Finetuned Text Embeddings
      • Vector Databases are not the only solution
      • Knowledge Graphs
        • Harnessing Knowledge Graphs to Elevate AI: A Technical Exploration
        • Unifying Large Language Models and Knowledge Graphs: A Roadmap
      • Approximate Nearest Neighbor (ANN)
      • High Dimensional Data
      • Principal Component Analysis (PCA)
      • Vector Similarity Search - HNSW
      • FAISS (Facebook AI Similarity Search)
      • Unsupervised Dense Retrievers
    • Retrieval Augmented Generation
      • Retrieval-Augmented Generation for Large Language Models: A Survey
      • Fine-Tuning or Retrieval?
      • Revolutionising Information Retrieval: The Power of RAG in Language Models
      • A Survey on Retrieval-Augmented Text Generation
      • REALM: Retrieval-Augmented Language Model Pre-Training
      • Retrieve Anything To Augment Large Language Models
      • Generate Rather Than Retrieve: Large Language Models Are Strong Context Generators
      • Active Retrieval Augmented Generation
      • DSPy: LM Assertions: Enhancing Language Model Pipelines with Computational Constraints
      • DSPy: Compiling Declarative Language Model Calls
      • DSPy: In-Context Learning for Extreme Multi-Label Classification
      • Optimizing Instructions and Demonstrations for Multi-Stage Language Model Programs
      • HYDE: Revolutionising Search with Hypothetical Document Embeddings
      • Enhancing Recommender Systems with Large Language Model Reasoning Graphs
      • Retrieval Augmented Generation (RAG) versus fine tuning
      • RAFT: Adapting Language Model to Domain Specific RAG
      • Summarisation Methods and RAG
      • Lessons Learned on LLM RAG Solutions
      • Stanford: Retrieval Augmented Language Models
      • Overview of RAG Approaches with Vector Databases
      • Mastering Chunking in Retrieval-Augmented Generation (RAG) Systems
    • Semantic Routing
    • Resource Description Framework (RDF)
  • AGENTS
    • What is agency?
      • Rephrase and Respond: Let Large Language Models Ask Better Questions for Themselves
      • Types of Agents
      • The risk of AI agency
      • Understanding Personality in Large Language Models: A New Frontier in AI Psychology
      • AI Agents - Reasoning, Planning, and Tool Calling
      • Personality and Brand
      • Agent Interaction via APIs
      • Bridging Minds and Machines: The Legacy of Newell, Shaw, and Simon
      • A Survey on Language Model based Autonomous Agents
      • Large Language Models as Agents
      • AI Reasoning: A Deep Dive into Chain-of-Thought Prompting
      • Enhancing AI Reasoning with Self-Taught Reasoner (STaR)
      • Exploring the Frontier of AI: The "Tree of Thoughts" Framework
      • Toolformer: Revolutionising Language Models with API Integration - An Analysis
      • TaskMatrix.AI: Bridging Foundational AI Models with Specialised Systems for Enhanced Task Completion
      • Unleashing the Power of LLMs in API Integration: The Rise of Gorilla
      • Andrew Ng's presentation on AI agents
      • Making AI accessible with Andrej Karpathy and Stephanie Zhan
  • Regulation and Ethics
    • Regulation and Ethics
      • Privacy
      • Detecting AI Generated content
      • Navigating the IP Maze in AI: The Convergence of Blockchain, Web 3.0, and LLMs
      • Adverse Reactions to generative AI
      • Navigating the Ethical Minefield: The Challenge of Security in Large Language Models
      • Navigating the Uncharted Waters: The Risks of Autonomous AI in Military Decision-Making
  • DISRUPTION
    • Data Architecture
      • What is a data pipeline?
      • What is Reverse ETL?
      • Unstructured Data and Generatve AI
      • Resource Description Framework (RDF)
      • Integrating generative AI with the Semantic Web
    • Search
      • BM25 - Search Engine Ranking Function
      • BERT as a reranking engine
      • BERT and Google
      • Generative Engine Optimisation (GEO)
      • Billion-scale similarity search with GPUs
      • FOLLOWIR: Evaluating and Teaching Information Retrieval Models to Follow Instructions
      • Neural Collaborative Filtering
      • Federated Neural Collaborative Filtering
      • Latent Space versus Embedding Space
      • Improving Text Embeddings with Large Language Models
    • Recommendation Engines
      • On Interpretation and Measurement of Soft Attributes for Recommendation
      • A Survey on Large Language Models for Recommendation
      • Model driven recommendation systems
      • Recommender AI Agent: Integrating Large Language Models for Interactive Recommendations
      • Foundation Models for Recommender Systems
      • Exploring the Impact of Large Language Models on Recommender Systems: An Extensive Review
      • AI driven recommendations - harming autonomy?
    • Logging
      • A Taxonomy of Anomalies in Log Data
      • Deeplog
      • LogBERT: Log Anomaly Detection via BERT
      • Experience Report: Deep Learning-based System Log Analysis for Anomaly Detection
      • Log-based Anomaly Detection with Deep Learning: How Far Are We?
      • Deep Learning for Anomaly Detection in Log Data: A Survey
      • LogGPT
      • Adaptive Semantic Gate Networks (ASGNet) for log-based anomaly diagnosis
  • Infrastructure
    • The modern data centre
      • Enhancing Data Centre Efficiency: Strategies to Improve PUE
      • TCO of NVIDIA GPUs and falling barriers to entry
      • Maximising GPU Utilisation with Kubernetes and NVIDIA GPU Operator
      • Data Centres
      • Liquid Cooling
    • Servers and Chips
      • The NVIDIA H100 GPU
      • NVIDIA H100 NVL
      • Lambda Hyperplane 8-H100
      • NVIDIA DGX Servers
      • NVIDIA DGX-2
      • NVIDIA DGX H-100 System
      • NVLink Switch
      • Tensor Cores
      • NVIDIA Grace Hopper Superchip
      • NVIDIA Grace CPU Superchip
      • NVIDIA GB200 NVL72
      • Hopper versus Blackwell
      • HGX: High-Performance GPU Platforms
      • ARM Chips
      • ARM versus x86
      • RISC versus CISC
      • Introduction to RISC-V
    • Networking and Connectivity
      • Infiniband versus Ethernet
      • NVIDIA Quantum InfiniBand
      • PCIe (Peripheral Component Interconnect Express)
      • NVIDIA ConnectX InfiniBand adapters
      • NVMe (Non-Volatile Memory Express)
      • NVMe over Fabrics (NVMe-oF)
      • NVIDIA Spectrum-X
      • NVIDIA GPUDirect
      • Evaluating Modern GPU Interconnect
      • Scalable Hierarchical Aggregation and Reduction Protocol (SHARP)
      • Next-generation networking in AI environments
      • NVIDIA Collective Communications Library (NCCL)
    • Data and Memory
      • NVIDIA BlueField Data Processing Units (DPUs)
      • Remote Direct Memory Access (RDMA)
      • High Bandwidth Memory (HBM3)
      • Flash Memory
      • Model Requirements
      • Calculating GPU memory for serving LLMs
      • Transformer training costs
      • GPU Performance Optimisation
    • Libraries and Complements
      • NVIDIA Base Command
      • NVIDIA AI Enterprise
      • CUDA - NVIDIA GTC 2024 presentation
      • RAPIDs
      • RAFT
    • Vast Data Platform
      • Vast Datastore
      • Vast Database
      • Vast Data Engine
      • DASE (Disaggregated and Shared Everything)
      • Dremio and VAST Data
    • Storage
      • WEKA: A High-Performance Storage Solution for AI Workloads
      • Introduction to NVIDIA GPUDirect Storage (GDS)
        • GDS cuFile API
      • NVIDIA Magnum IO GPUDirect Storage (GDS)
      • Vectors in Memory
Powered by GitBook
LogoLogo

Continuum - Accelerated Artificial Intelligence

  • Continuum Website
  • Axolotl Platform

Copyright Continuum Labs - 2023

On this page
  • Definitions First!
  • Intrinsic Evaluation
  • Extrinsic Evaluation
  • Distinction between intrinsic and extrinsic evaluation
  • Key points and findings
  • The approach taken in the study
  • To apply these ideas in practice, researchers and practitioners can
  • Key insights that can guide your choice or development of a tokenizer
  • Conclusion

Was this helpful?

  1. Training
  2. The Fine Tuning Process
  3. Tokenization

Tokenizer Choice For LLM Training: Negligible or Crucial?

PreviousTokenization exploreNextGetting the most out of your tokenizer for pre-training and domain adaptation

Last updated 1 year ago

Was this helpful?

This March 2024 paper investigates the impact of tokenizer choice on the performance of Large Language Models (LLMs), particularly in the context of mono- and multilingual models.

The authors argue that while various factors such as dataset composition, model architecture, and pretraining objectives have been extensively studied, the influence of tokenizers remains underexplored.

The paper provides an overview of various tokenization approaches, including word, subword, and character tokenization.

It also discusses the usage of tokenizers in encoder and decoder models, highlighting the lack of extensive studies on the extrinsic tokenizer performance in a monolingual and multilingual setting with a focus on decoder-only models.

Definitions First!

Intrinsic Evaluation

Intrinsic evaluation assesses the performance of a tokenizer based on its inherent properties and the characteristics of its output, without considering its impact on downstream tasks or models. In the context of the study, the intrinsic evaluation focused on three main metrics:

Fertility

Fertility is a measure of the average number of tokens required to represent a word or document after tokenization.

It is calculated by dividing the total number of tokens in a tokenized dataset by the total number of words in the original dataset.

A lower fertility score indicates that the tokenizer is more efficient in representing the text with fewer tokens.

High fertility can lead to increased sequence lengths, which can impact the model's ability to learn long-range dependencies and increase computational costs during training and inference.

Parity

Parity assesses how fairly a tokenizer treats equivalent sentences across different languages.

It measures the consistency of the tokenizer in representing similar semantic content across languages.

In the study, parity was calculated using the FLORES-200 parallel corpus, which contains the same sentences human-translated into 200 languages. The closer the parity scores are to 1, the more consistent the tokenizer is in handling different languages.

Vocabulary Overlap

Vocabulary overlap measures the similarity between the vocabularies of different tokenizers.

It is calculated by comparing the number of shared tokens between two tokenizers' vocabularies.

A high vocabulary overlap indicates that the tokenizers generate similar subword units and may have similar performance characteristics.

Extrinsic Evaluation

Extrinsic evaluation assesses the performance of a tokenizer based on its impact on downstream tasks or models.

In the study, the extrinsic evaluation focused on two main aspects:

Downstream Performance

The authors trained language models using different tokenizers and evaluated their performance on a wide range of downstream tasks, such as natural language inference, question answering, reading comprehension, and text classification.

The models' performance on these tasks was used to assess the effectiveness of the tokenizers in enabling the models to learn meaningful representations and solve real-world problems.

Computational Costs

The study evaluated the computational costs associated with each tokenizer when used in a specific language model.

The computational costs were measured in terms of the average number of floating-point operations (FLOPs) required to process a single word during training.

This metric takes into account the tokenizer's fertility and the model's architecture, such as the number of layers, hidden size, and vocabulary size.

Lower computational costs indicate that the tokenizer is more efficient in terms of resource utilization during training.

Distinction between intrinsic and extrinsic evaluation

The distinction between intrinsic and extrinsic evaluation is important because a tokenizer's intrinsic performance metrics, such as fertility and parity, may not always directly correlate with its impact on downstream tasks.

A tokenizer with good intrinsic performance may not necessarily lead to better downstream performance, and vice versa.

Therefore, considering both intrinsic and extrinsic evaluation metrics provides a more comprehensive understanding of a tokenizer's effectiveness and its suitability for specific applications.

By conducting both intrinsic and extrinsic evaluations, the study aimed to provide insights into the relationship between tokenizer characteristics and their impact on language model performance, helping researchers and practitioners make informed decisions when selecting or designing tokenizers for their specific use cases.

Key points and findings

Comprehensive study: The authors trained 24 mono- and multilingual LLMs at a 2.6B parameter scale, ablating different tokenizer algorithms and parameterizations to assess their impact on downstream performance.

Significant impact: The study reveals that tokenizer choice can significantly affect the model's downstream performance and training costs.

Questionable evaluation metrics: Common tokenizer evaluation metrics like fertility and parity are not always predictive of the model's downstream performance, making them unreliable proxies.

Multilingual tokenizers: Multilingual tokenizers trained on the five most frequent European languages require vocabulary size increases of factor three compared to English tokenizers.

English-centric tokenizers: Applying English-centric tokenizers to multilingual LLMs results in severe downstream performance degradation and additional training costs of up to 68% due to an inefficient tokenization vocabulary.

The approach taken in the study

Dataset creation

The authors created two datasets (monolingual English and multilingual) with 70B words each, ensuring that the mixture proportions of data domains were consistent between the tokenizer and model training datasets to avoid domain shift.

Tokenizer training

They trained 24 different tokenizers using BPE and Unigram algorithms, varying the language composition, vocabulary size, and tokenizer library (Huggingface and SentencePiece).

Model training

For each of the 24 trained tokenizers, they trained a 2.6B transformer-based decoder-only model on up to 52B tokens, following a specific scaling law. They also trained monolingual and multilingual baseline models using the pre-trained GPT-2 tokenizer.

Evaluation

The authors conducted both intrinsic and extrinsic evaluations of the tokenizers.

The intrinsic evaluation assessed the tokenizers' output based on fertility, parity, and vocabulary overlap, while the extrinsic evaluation measured the impact of tokenizers on the model's downstream performance and computational costs.

To apply these ideas in practice, researchers and practitioners can

  1. Evaluate and compare different tokenizer algorithms, configurations, and libraries for their specific use case, considering both intrinsic and extrinsic performance metrics.

  2. Design and train custom tokenizers tailored to the target languages and domains of their LLMs, ensuring optimal downstream performance and computational efficiency.

  3. Use the provided computational cost formula to estimate the impact of tokenizer choice and model architecture on training costs, and optimize their setups accordingly.

By applying these insights and approaches, practitioners can develop more efficient and effective LLMs, particularly in multilingual settings, ultimately leading to better performance on downstream tasks and more accessible language technology for a wider range of users.

Key insights that can guide your choice or development of a tokenizer

Monolingual vs. Multilingual

If you are working with multilingual data, it is crucial to use a multilingual tokenizer.

Using a monolingual tokenizer on multilingual data leads to significantly higher fertility and parity scores, indicating inefficient tokenization.

Multilingual tokenizers perform only slightly worse on English documents compared to monolingual English tokenizers, making them a better choice for multilingual settings.

Vocabulary Size

The optimal vocabulary size depends on the language(s) you are working with.

For monolingual English settings, smaller vocabulary sizes (around 33k-50k) tend to perform better.

However, for multilingual settings, larger vocabulary sizes (up to 100k) generally yield better downstream performance, especially for non-Germanic languages. Consider the trade-off between performance and computational costs when choosing the vocabulary size.

Tokenizer Library

The choice of tokenizer library (e.g., Huggingface vs. SentencePiece) can impact the downstream performance.

In the study, SentencePiece's BPE implementation generally outperformed Huggingface's BPE in both monolingual and multilingual settings.

Consider the differences in pre- and post-processing steps between libraries when selecting a tokenizer.

Tokenizer Algorithm

The choice between BPE and Unigram algorithms may depend on the target language(s).

In the study, Germanic languages (German and English) benefited more from BPE, while Romanic languages (French and Spanish) benefited more from Unigram.

Consider the linguistic properties of your target language(s) when choosing the tokenizer algorithm.

Computational Costs

Larger vocabulary sizes generally increase computational costs, even if they lead to lower fertility scores.

When choosing a tokenizer, consider the trade-off between downstream performance and computational costs, especially if you need to process a fixed set of documents during training.

Pre-trained Tokenizers

Using pre-trained tokenizers (e.g., GPT-2) for multilingual models may lead to suboptimal performance. It is better to train a custom tokenizer tailored to your specific language(s) and domain.

Conclusion

The study provides valuable insights into the impact of tokenizer choice on the downstream performance of language models, particularly in monolingual and multilingual settings.

The findings highlight the importance of training tokenizers with a balanced share across languages to achieve comparable low fertility and parity scores, which has significant implications for computational costs and the model's ability to learn long-range dependencies.

The study demonstrates that the tokenizer choice can significantly impact the model's downstream performance, with the BPE algorithm performing well in both mono- and multilingual settings.

For English, a vocabulary size of 33k is sufficient, while multilingual models based on the five considered languages require up to three times larger vocabulary sizes. Additionally, the SentencePiece library outperforms the Huggingface tokenizer library.

Interestingly, the study finds no clear correlation between intrinsic and extrinsic tokenizer performance, suggesting that the correlation is rather task-specific. A small fertility value might be a necessary condition for good downstream performance but not a sufficient one.

LogoTokenizer Choice For LLM Training: Negligible or Crucial?arXiv.org
Tokenizer Choice For LLM Training: Negligible or Crucial?
Page cover image