﻿# Nucleotide Transformer k-mers: a shifted window changes the grouping phase

Understand Nucleotide Transformer fixed k-mer grouping, nucleotide fallback, window-origin effects, and token-budget accounting for mixed DNA input.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-nucleotide-transformer-kmer-window-phase/
Language: en

## Equal-length windows can describe different token workloads

A genomic processing job may divide a chromosome into windows and estimate model input size by dividing base count by a fixed group length. That estimate assumes the tokenizer can use its ordinary k-mer path throughout the sequence. Special symbols and remainder handling can change the resulting token count.

The [official model card](https://huggingface.co/InstaDeepAI/nucleotide-transformer-v2-500m-multi-species) describes grouping nucleotides into k-mers where possible, with nucleotide-level fallback. Preserve that conditional behavior in capacity planning.

## The window origin sets the grouping phase

For non-overlapping grouping, moving the start of a window changes which bases share a token. The same genomic base can consequently appear in a different local token neighborhood under another crop, even before considering the changed model context.

Record each window origin and the tokenizer-produced spans. Do not treat shifted windows as identical views merely because they overlap heavily. If an ensemble aggregates their outputs, define how those differently grouped representations are aligned back to source coordinates.

## Fallback is part of tokenization

The [tokenizer implementation](https://raw.githubusercontent.com/instadeepai/nucleotide-transformer/main/nucleotide_transformer/tokenizers.py) constructs its vocabulary and grouping logic. Inspect the tokenizer bundled with the actual model rather than assuming every character stream can be compressed into complete canonical groups.

Unknown or additional nucleotide symbols and trailing fragments require explicit review. A cache or scheduler based only on raw sequence length can misdescribe the encoded workload when these input characteristics vary across records.

## Model generation belongs in the input contract

The [Nucleotide Transformer project](https://github.com/instadeepai/nucleotide-transformer) contains several related model workflows. A tokenizer from one generation should not be attached to a different checkpoint solely because both accept DNA strings.

Store tokenizer identity and special-token handling with the model artifact. The [artifact validation guide](/journal/safetensors-artifact-validation/) explains why related preprocessing resources are part of reproducible inference rather than optional packaging details.

## Inspect boundaries before aggregating predictions

A small validation set should include complete groups, trailing fragments, and the supported special-symbol cases relevant to the source collection. Check actual encoded length and span coverage instead of relying on a theoretical compression ratio.

The [tensor-axis guide](/journal/tensor-axes-batch-sequence-hidden/) helps distinguish genomic positions from token positions. A correctly reconstructed coordinate map does not make a token-level feature a validated nucleotide-level biological prediction; the downstream projection and scientific evaluation remain separate definitions.
