﻿# PEFT Trainable Tokens: why a few changed rows can still save a full matrix

Understand selective token-row training, tokenizer resizing, the resized-embedding save precaution and the conditions required for a compact token-delta artifact.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/guide-trainable-tokens-save-contract/
Language: en

PEFT Trainable Tokens targets selected embedding rows instead of optimizing and storing an entire vocabulary matrix. This is useful for controlled updates to a small token set. However, the number of trained rows does not alone determine the saved artifact: resizing an embedding matrix can trigger a separate full-matrix saving precaution.

## Separate vocabulary changes from row training

The method does not create tokenizer entries automatically. Adding tokens and resizing the model's input embeddings are separate preparation steps. Preserve the resulting token-to-identifier mapping before selecting trainable indices. If another tokenizer assigns different identifiers, the same list of row numbers can modify unrelated tokens while remaining a valid tensor operation.

## Inspect the trained module set

Check the actual embedding module selected by configuration and any additional adapted layers. A model can share input and output weights or use separate output parameters. Record how the installed architecture handles that relationship. Training only selected input rows does not establish that every other vocabulary-related tensor remains consistent after a custom modification or export.

## Understand the full-matrix save behavior

PEFT documents that saving after token additions may retain the full embedding matrix as a precaution. A small trainable-row count can therefore coexist with a large saved file. The compact-saving option should be used only when other embedding modifications do not need preservation outside the tracked token changes. Otherwise a space-saving export can silently omit state that affected the evaluated model.

## Test reconstruction in a fresh process

Retain the base revision, resized tokenizer, selected token identifiers and saved token state. Reload without relying on the training process's already modified embedding matrix. Compare both selected tokens and ordinary vocabulary behavior on fixed inputs. This catches artifacts that work only because an unsaved resize or external embedding update remains in memory.

## Evaluate task utility beyond file size

For an illustrative structured-label task, measure held-out output validity and correctness, including adjacent ordinary text. The method supports learning existing token rows as well as newly added ones, so state which case is intended. A compact file is useful only if it reconstructs the right model and its chosen serving implementation supports the selective-token state. Treat training memory, saved bytes and task behavior as separate observations.

## Primary references

[PEFT: Trainable Tokens](https://huggingface.co/docs/peft/package_reference/trainable_tokens).

[Transformers tokenizer API](https://huggingface.co/docs/transformers/main_classes/tokenizer).

[Transformers model API](https://huggingface.co/docs/transformers/main_classes/model).

Related explanations: [vocabulary and embedding resizing](/journal/vocabulary-resize-embedding-rows/); [input-output weight tying](/journal/weight-tying-input-output-embeddings/).
