﻿# ProtT5 preprocessing: amino-acid normalization can erase distinctions

Preserve original protein sequences when applying ProtT5 uppercase, ambiguous-residue replacement, and spaced-token preprocessing for encoder feature extraction.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-prott5-amino-acid-normalization-loss-ledger/
Language: en

## Compatible input is not a lossless source record

A protein embedding job may normalize every incoming sequence before calling ProtT5. That is useful for matching the documented model input, but it can collapse distinctions present in the original scientific record. Keeping only the normalized string makes those distinctions impossible to recover later.

The [ProtT5 checkpoint card](https://huggingface.co/Rostlab/prot_t5_xl_uniref50) describes uppercase amino-acid input and a preprocessing example. Treat that example as preparation of a model view, not permission to overwrite the source collection.

## Replacement has an explicit information cost

The documented preprocessing replaces U, Z, O, and B with X before inserting spaces between residues. Different original strings can therefore become the same model input. An embedding cache keyed by that processed string may legitimately reuse computation while still needing to retain the distinct original records.

Store both strings and the transformation revision. If downstream analysis asks about a specific original residue, report that its model representation was normalized rather than pretending the model observed the original symbol unchanged.

## FASTA cleanup and model preparation differ

The [official embedding script](https://raw.githubusercontent.com/agemagician/ProtTrans/master/Embedding/prott5_embedder.py) contains additional source-reading and preparation decisions. A production adapter should inventory those transformations rather than copying only the final tokenizer call.

Whitespace cleanup, case conversion, gap handling, and ambiguous-residue replacement have different meanings. The [normalization integrity guide](/journal/data-guide-unicode-normalization-span-integrity/) explains why each transformation needs a recoverable correspondence when annotations refer to original positions.

## Use the intended representation path

The [ProtTrans project](https://github.com/agemagician/ProtTrans) provides protein feature-extraction workflows. An encoder feature job is not the same operation as generative decoding from a complete sequence-to-sequence model.

Record the loaded artifact, representation path, and output interpretation. A framework interface that offers text generation does not establish that decoder outputs are the intended features for a residue annotation task. Follow the selected checkpoint workflow and verify residue alignment after tokenization.

## Audit collisions before interpreting similarity

A useful preparation report lists source identifiers that share a normalized model string. Such collisions can reflect the deliberate replacement rule rather than accidental duplicate records. Keep them distinguishable when evaluating retrieval or aggregating labels.

The [artifact validation guide](/journal/safetensors-artifact-validation/) motivates including preprocessing provenance with model outputs. A consistent encoder feature is a computational artifact; its similarity to another vector is not by itself proof of shared protein function or interchangeable biological behavior.
