TextConditioningBase<T>
Base Classes · AiDotNet.Diffusion.Conditioning
Base class for text conditioning modules used in diffusion models.
Inheritance: NeuralNetworkBase<T> → TextConditioningBase<T>
Implements: IConditioningModule<T>, IShapeContract
Known derived types: CLIPTextConditioner<T>, ChatGLM3TextConditioner<T>, DistilledT5TextConditioner<T>, GemmaTextConditioner<T>, Qwen2TextConditioner<T>, SigLIP2TextConditioner<T>, SigLIPTextConditioner<T>, T5TextConditioner<T>
How It Works
Inherits NeuralNetworkBase so concrete subclasses use the
codebase’s golden “Architecture.Layers ? : LayerHelper.CreateDefaultXxxTextLayers”
pattern — the same shape that the recent CLAP / AST / PANNs rewrites established.
The forward path walks the inherited Layers
list via Predict, so engine fast-paths,
gradient tape, and weight-streaming auto-detect (#1222, merged) all apply
automatically.
Tokenisation is delegated to an injected ITokenizer from
src/Tokenization. Each concrete subclass constructs its paper-
canonical tokenizer (CLIP byte-level BPE, T5 SentencePiece-Unigram,
Gemma SentencePiece, etc.) in its constructor; this base class never
fabricates token IDs from characters.
Properties
| Property | Summary |
|---|---|
ConditioningType ConditioningType { get; } |
|
bool ProducesPooledOutput { get; } |
|
int EmbeddingDimension { get; } |
|
int MaxSequenceLength { get; } |
|
int VocabSize { get; } |
Vocabulary size of the configured tokenizer. |
Methods
| Method | Summary |
|---|---|
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank) |
|
ModelMetadata<T> GetModelMetadata() |
|
Tensor<T> Encode(Tensor<T> input) |
|
Tensor<T> EncodeText(Tensor<T> tokenIds, Tensor<T> attentionMask) |
|
Tensor<T> GetPooledEmbedding(Tensor<T> sequenceEmbeddings) |
Default pooling: mean over the sequence axis. |
Tensor<T> GetUnconditionalEmbedding(int batchSize) |
|
Tensor<T> Tokenize(string text) |
|
Tensor<T> TokenizeBatch(string[] texts) |