Training, adaptation, compression, and systems techniques · Training, fine-tuning, adaptation, compression, and systems techniques · TRN031 · Training method
Textual inversion
Learns a token embedding that represents a new concept while freezing the text-to-image model.
In CodeSplash
Documented in the Academy only. There's no Set up button.
- Availability
- Explained here
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Learns a token embedding that represents a new concept while freezing the text-to-image model.
Question / hypotheses
Does this intervention improve the intended quality, adaptation, resource, or reliability objective under a controlled comparison? It defines a method, not an intrinsic null-hypothesis test.
Architecture / computational structure
One or more learned embedding vectors are inserted into the text-conditioning stream; the denoiser and most text-encoder weights remain fixed.
Assumptions
The frozen generator must already have capacity to express the concept. Tokenizer insertion and embedding serialization must be consistent.
Formula / computational definition
Parameters and notation
Learned: new embedding v. Hyperparameters: number of vectors, initialization token, learning rate, prompt templates, image augmentations, training steps.
Fitting, fine-tuning, and adaptation
Optimize only the new embedding and verify that frozen weights do not change. Test composition with new prompts and compare with broader DreamBooth/adapter adaptation when capacity is insufficient.
How to use and calibrate
Inspect concept fidelity versus editability. Example: add a reusable visual style token to a compatible local model.
Example application
add a reusable visual style token to a compatible local model.
Interpretation / pitfalls
Watch out
Textual inversion is not ordinary text prompting or full-model fine-tuning. Embeddings are generally checkpoint/text-encoder specific.
Python and R code examples
Scope: numerical mechanism demonstration. Validation: Python executed successfully on the supplied synthetic inputs; R reviewed but not executed (Rscript unavailable).
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — numerical mechanism demonstration. · needs numpy
import numpy as np
v=np.array([.2,-.1,.3]); grad=np.array([.05,.02,-.03]); lr=.1
print(v-lr*grad)
Component demo, not a trained model — numerical mechanism demonstration.
v <- c(.2,-.1,.3); grad <- c(.05,.02,-.03); lr <- .1
print(v-lr*grad)
Sources
- Primary/official source 1arxiv.org
From the CodeSplash reference, entry TRN031.