From Characters to Tokens: Dynamic Grouping with Hierarchical BPE

Rares Dolga, Lucas Maystre, Tudor Berariu, David Barber · DOI

Introduction

Modern Large Language Models (LLMs) are typically built upon subword tokenization methods like Byte Pair Encoding (BPE). While effective, these methods impose a "tokenization tax": they require massive embedding matrices to represent hundreds of thousands of unique tokens, leading to parameter inefficiency and poor representations for rare subwords. Conversely, character-level models offer extreme flexibility and parameter efficiency but suffer from "sequence length explosion," where the quadratic scaling of Transformer attention makes processing long character sequences computationally prohibitive.

This paper introduces Hierarchical BPE (HBPE), a novel strategy designed to bridge this gap. By repurposing BPE as a dynamic grouping heuristic rather than a final tokenizer, the authors create a system that maintains the efficiency of subword models while retaining the flexibility and parameter compactness of character-level approaches.

Methodology: The Hierarchical Approach

The core of HBPE is a two-stage tokenization and modeling pipeline that replaces static embedding tables with dynamic neural components.

1. Dynamic Patching and Compression

Instead of training a complex boundary-detection model, HBPE uses a pre-trained BPE tokenizer to identify "patches" of characters. To ensure the system remains language-agnostic and handles incremental processing, an explicit "end-of-patch" marker (e.g., <!>) is appended to each token. To prevent individual patches from becoming excessively long—which could cause memory spikes—a second-level BPE algorithm compresses the character sequence within each patch into a shorter sequence of integers, capped at a maximum length $S$.

2. Model Architecture

The architecture consists of three primary components:

  • Local Encoder: A compact neural network that transforms the sequence of characters or integers within a patch into a single latent vector.
  • Global (Latent) Transformer: A large-scale model that processes the sequence of these patch-level vectors.
  • Local Decoder: An autoregressive model responsible for predicting the constituent characters of the next patch, one by one.
Figure 1: The HBPE architecture featuring local encoders/decoders and a global latent transformer.

This design effectively replaces the traditional 250k-row embedding table with a learnable encoder-decoder pair, allowing the model to "understand" the internal structure of rare words through their character compositions.

Experimental Results

The authors evaluated HBPE across diverse datasets, including SlimPajama (English and Chinese) and Skypile (Chinese), to test its general modeling capabilities and language agnosticism.

Performance and Efficiency

On the SlimPajama dataset, the BPE-Patch model demonstrated superior compression efficiency, achieving a Bits Per Byte (BPB) of 1.11. This outperformed both the standard BPE baseline (1.16) and alternative dynamic grouping methods like entropy-based patching (1.20).

Figure 6: Comparison of Bits Per Byte (BPB) across different training steps for various patching strategies.

Crucially, these gains were achieved with fewer parameters. The BPE-Patch model required only 99.7M parameters, compared to the 123M parameters used by the standard BPE baseline. This efficiency stems from the elimination of the massive embedding matrix.

Downstream Benchmarks and Language Agnosticism

In zero-shot evaluations (HellaSwag, PIQA, ARC, etc.), a 323M parameter BPE-Patch model outperformed a larger 359M parameter standard BPE model on tasks like ARC-Easy and WinoGrande. Furthermore, the method proved exceptionally effective for non-whitespace-delimited languages. On the Chinese Skypile dataset, HBPE achieved the lowest BPB (1.20) compared to space-based (1.24) and entropy-based (1.27) strategies, proving its robustness across different linguistic structures.

Discussion and Future Work

HBPE offers a compelling path toward more efficient and flexible LLMs by treating BPE as a statistical heuristic for grouping. While the results are promising for models up to 575M parameters, further research is required to determine if these benefits scale to the multi-billion parameter regime. Additionally, while the method reduces FLOPs at large vocabulary sizes, the autoregressive nature of the local decoder introduces decoding complexity that may require optimization for high-throughput production environments.

Summary updated

BibTeX
@misc{dolga2025from,
  author = {Rares Dolga and Lucas Maystre and Tudor Berariu and David Barber},
  title = {{From Characters to Tokens: Dynamic Grouping with Hierarchical BPE}},
  year = {2025},
  eprint = {2510.15517},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.15517},
}
Figure