Prefix-Free Parsing Tokenizer Enables Efficient Long-Context Modeling of
A research team led by Conrad Testagrose, Rahul Varki, and Christina Boucher has developed PFPTok, an algorithm that uses prefix-free parsing to compress raw DNA sequences into compact dictionary-based tokens for transformer models. Published in Genome Biology
Illustrative imageA research team led by Conrad Testagrose, Rahul Varki, and Christina Boucher has developed PFPTok, an algorithm that uses prefix-free parsing to compress raw DNA sequences into compact dictionary-based tokens for transformer models. Published in Genome Biology, the methodology addresses a primary computational obstacle in genomic deep learning: transformer architectures scale quadratically in memory and runtime with sequence length, severely restricting the genomic context accessible within practical hardware constraints. While natural language processing systems routinely process text divided by whitespace and punctuation, biological sequences are continuous, lack explicit word delimiters, and extend across millions or billions of nucleotides. By leveraging intrinsic sequence repetitiveness through deterministic string parsing, PFPTok compresses full bacterial assemblies and long human regulatory regions into small token sequences. This design allows standard bidirectional transformers to process whole genomes and distant chromosomal loci without truncating inputs, modifying attention mechanisms, or partitioning sequences into fragmented windows.
Modern genomic language models face fundamental limitations when processing biological sequences at single-nucleotide resolution. Genomic sequences frequently contain structural motifs, regulatory elements, and evolutionary relationships that span hundreds of kilobases or depend on genome-wide variation. Standard transformer self-attention mechanisms require quadratic time and memory relative to sequence length, causing single-base representations of long sequences to exceed graphic processing unit memory capacity. Prior computational efforts have largely pursued two paths to mitigate these length constraints. The first redesigns neural architectures or develops specialized attention approximations, such as implicit long convolutions or state-space models, to process extended nucleotide sequences directly. Although these architectures expand context windows, modeling entire genomes at single-nucleotide resolution remains computationally expensive. The second path operates within standard transformer architectures by tokenizing inputs into compressed multi-base subunits. However, standard tokenizers borrowed from natural language processing introduce distinct algorithmic bottlenecks when applied to long genomic data.
Widely adopted subword tokenizers, including Byte-Pair Encoding and Unigram models, struggle to process long biological sequences efficiently. Byte-Pair Encoding iteratively merges frequent adjacent character pairs to build a vocabulary, whereas Unigram adopts a top-down probabilistic framework that iteratively prunes an oversized vocabulary to maximize sequence likelihood. Both methods are fundamentally offline algorithms that require entire sequences to be held in system memory during vocabulary construction and tokenization. When applied to long DNA sequences, these tokenizers cause severe memory consumption and slow processing speeds. Researchers commonly mitigate these issues by pre-tokenizing data into arbitrary non-overlapping sequence windows. This partitioning introduces substantial computational overhead and disrupts biological patterns that cross artificial split boundaries. Furthermore, statistical subword tokenizers frequently generate redundant intermediate subwords that fail to capture repetitive genomic structures succinctly, diluting model embedding spaces and inflating parameter overhead.
PFPTok avoids these limitations by adapting Prefix-Free Parsing, an algorithmic compression technique originally designed to construct Burrows-Wheeler transforms for massive bioinformatic datasets. The algorithm operates in a single streaming pass across input sequences without requiring prior sequence partitioning. PFPTok uses two user-defined integer parameters, window size w and modulus p. As a sliding window of length w moves across the text, the algorithm computes a rolling Karp-Rabin hash value for each window position. Whenever the hash modulo p equals zero, the corresponding w-base window is designated as a trigger string, which simultaneously terminates the current word and initiates the next. Consequently, consecutive parsed words overlap by exactly w bases, and every word begins and ends with a trigger string. To preserve boundary integrity, sentinel symbols are internally prepended and appended to the sequence. The resulting unique words form a lexicographically sorted dictionary that serves as the tokenizer vocabulary, while the sequence of dictionary ranks forms the tokenized input.
The researchers evaluated PFPTok on antimicrobial resistance classification across 12,209 Mycobacterium tuberculosis clinical isolates obtained from the CRyPTIC database, comparing its performance directly against Byte-Pair Encoding and Unigram. In the curated gene-level experiment, models were tasked with predicting resistance phenotypes for nine first- and second-line antibiotics: rifampicin, isoniazid, ethambutol, amikacin, kanamycin, rifabutin, levofloxacin, moxifloxacin, and ethionamide. Input sequences were derived from resistance-associated genes and flanking intergenic regions, yielding short segments averaging 714.37 base pairs that fit within a standard 5,000-token BERT input window. Across independent models trained under identical hyperparameters, PFPTok achieved the highest positive-class F1 score on five antibiotics, whereas Unigram led on four, and Byte-Pair Encoding attained no top scores. Average F1 scores across all nine antibiotics were nearly identical between PFPTok at 0.8355 and Unigram at 0.8359, differing by only 0.0004 points, while Byte-Pair Encoding trailed at 0.8262. These results demonstrated that PFPTok retains predictive fidelity on short gene sequences while matching standard baseline tokenizers.
When evaluated on full-length bacterial assemblies, PFPTok scaled effectively where conventional tokenizers failed. In an ablation study using five training and five testing Mycobacterium tuberculosis genomes averaging approximately 4.5 million base pairs, Byte-Pair Encoding required over four hours to process a single genome, yielding 623,092 tokens and exceeding a 64-gigabyte system memory limit when scaling to additional assemblies. SentencePiece Unigram similarly failed under whole-genome settings. Across the parameter grid, Byte-Pair Encoding and Unigram produced tokenized genome sequences that vastly exceeded 5,000 tokens. In contrast, PFPTok processed full-length genomes in a single pass without prior partitioning. Across the tested ablation grid, PFPTok achieved mean compression ratios of 887.7 base pairs per token on training assemblies and 892.0 base pairs per token on held-out test assemblies. Selecting parameters w = 2,000 and p = 4,096 compressed full assemblies to an average of 1,141.88 tokens on test genomes, enabling direct end-to-end training of whole-genome BERT classifiers within a 5,000-token budget.
To evaluate whether aggressive whole-genome compression preserved biologically relevant signal, the authors conducted token-level interpretability analyses on the whole-genome classifier for isoniazid resistance. By extracting attention-derived importance scores from the trained model across test isolates, the researchers mapped the top 100 attention tokens back to the annotated H37Rv reference genome using minimap2 and bedtools. Of the 96 unique token sequences analyzed, 93 aligned successfully to the reference genome, representing a 96.88 percent alignment rate. The mapped token sequences exhibited a mean length of 1,359.38 base pairs and a median length of 908 base pairs. Intersection with annotated coding sequences revealed that high-attention tokens repeatedly overlapped genomic loci with established mechanistic roles in isoniazid resistance, including katG, iniA, iniC, and ndh. This demonstrated that deterministic sequence compression does not prevent attention-based models from localizing verified phenotypic markers across entire bacterial genomes.
The study also assessed PFPTok on complex human genomic data using the DNALongBench benchmark, evaluating fixed 450,000-base-pair inputs on enhancer-target gene prediction and expression quantitative trait locus classification across nine tissues. The authors compared a PFPTok-trained BERT model against two single-nucleotide foundation models designed specifically for long context: HyenaDNA, which utilizes implicit long convolutions, and Caduceus, a bidirectional state-space model based on Mamba blocks. Using parameters w = 100 and p = 4,096, PFPTok compressed the 450,000-base-pair human inputs into compact token sequences that fit inside standard transformer windows. Single-nucleotide models were trained at a batch size of 1 due to high memory consumption, whereas the compact sequence length of PFPTok allowed a training batch size of 128 under identical computational hardware.
In the enhancer-target gene prediction task, PFPTok combined with BERT achieved the highest overall performance among all evaluated models. PFPTok reached an area under the receiver operating characteristic curve of 0.9496 and an area under the precision-recall curve of 0.5362, completing training in 688 seconds. By comparison, HyenaDNA achieved an AUROC of 0.9338 and an AUPRC of 0.4543 over 4,661 seconds of training, while Caduceus achieved an AUROC of 0.9044 and an AUPRC of 0.4721 across 4,023 seconds. Across nine tissue tasks in expression quantitative trait locus classification, PFPTok surpassed Caduceus in both AUROC and AUPRC across all nine tissues, achieving a mean AUROC of 0.8392 compared to 0.7859 and a mean AUPRC of 0.2354 compared to 0.1910. When compared against HyenaDNA, PFPTok achieved a slightly higher mean AUROC across tissues, leading in six of nine tissues, whereas HyenaDNA showed higher average AUPRC, leading in five of nine tissues.
The researchers further benchmarked fine-tuning costs against Nucleotide Transformer v3, a megabase-scale model operating at single-nucleotide resolution. On the 450,000-base-pair enhancer-target gene prediction input, PFPTok compressed inputs to an average of 46.3 tokens, compared to 450,048 single-base tokens required by the foundation model trunk. At a matched batch size of 1 on an NVIDIA B200 graphics processing unit, PFPTok required 39.1 seconds per epoch and 1.8 gigabytes of peak memory, compared to 495.1 seconds per epoch and 65.0 gigabytes of peak memory for Nucleotide Transformer v3, where 63 gigabytes constituted activation memory. Leveraging its compact representations, PFPTok scaled to a batch size of 128, utilizing 8.0 gigabytes of memory and completing an epoch in 0.6 seconds at a throughput of 3,406 sequences per second. Including one-time dictionary construction, a complete 20-epoch training run required 8.4 minutes for PFPTok compared to 165.7 minutes for the nucleotide-resolution model.
The authors outlined important technical constraints inherent to the prefix-free parsing tokenizer framework. Because PFPTok relies on a fixed dictionary learned during initial vocabulary construction, sequences containing variants or phrases unseen during training cannot be parsed into known dictionary ranks and are assigned to an unknown token label. In closely related Mycobacterium tuberculosis isolates and human enhancer-target gene predictions, unknown token rates remained low, measuring 2.14 percent on the enhancer test set. However, in expression quantitative trait locus classification, unknown token proportions increased to between 10.62 and 20.15 percent across tissues, reflecting sequence divergence between inference samples and the training dictionary. These elevated unknown rates degrade effective sequence resolution and may explain the lower precision-recall values observed relative to HyenaDNA on certain human tissue benchmarks. Consequently, the authors note that PFPTok is primarily suited for large, repetitive sequence cohorts with shared sequence backbones, such as bacterial pangenomes, rather than highly diverse cross-species or metagenomic datasets. Proposed extensions include soft binning over lexicographically ranked dictionary bins to improve generalization across single-nucleotide variants.
Subject of Research: Prefix-free parsing tokenization for long-context genomic transformer sequence modeling
Article Title: PFPTok enables efficient long-context genomic sequence modeling
Article References: Testagrose, C., Varki, R., & Boucher, C. (2026). PFPTok enables efficient long-context genomic sequence modeling. Genome Biology. https://doi.org/10.1186/s13059-026-04363-w
Image Credits: AI Generated
DOI: 10.1186/s13059-026-04363-w
Keywords: PFPTok, prefix-free parsing, genomic sequence modeling, transformer models, DNA tokenization, Mycobacterium tuberculosis, antimicrobial resistance, DNALongBench, enhancer-target gene prediction, eQTL classification, HyenaDNA, Caduceus, Nucleotide Transformer, computational genomics, bioinformatics algorithms, self-attention scalability, BERT architecture
News Source: Juliet Wilcox. (November 27, 2026). Prefix-Free Parsing Tokenizer Enables Efficient Long-Context Modeling of Whole Genomes. Scienmag.
