LlasaOptions

Options & Configuration · AiDotNet.TextToSpeech.CodecBased

Options for Llasa.

Inheritance: ModelOptions → TtsModelOptions → LlasaOptions

For Beginners

These settings size Llasa’s language model and its speech codec, and control how it picks each next speech token; the defaults reproduce the released 1B model.

How It Works

The defaults are Llasa-1B (Ye et al. 2025, “Llasa: Scaling Train-Time and Inference-Time Compute for Llama-based Speech Synthesis”; HKUSTAudio/Llasa-1B): Llama 3.2 1B (width 2048, 16 layers, 32 heads over 8 key-value heads of 64, SwiGLU 8192, rotary θ 500000 with Llama 3 scaling ×32, tied embeddings) over Llama 3’s tokenizer plus 8 task markers and 65,536 speech tokens (193,800 in all), speaking X-codec2 (HKUSTAudio/xcodec2: one 65,536-entry FSQ codebook at 50 Hz, 16 kHz audio). The 3B and 8B models are Llama 3.2 3B and Llama 3.1 8B with the same tokens.

Generation follows the model card: Llama 3.2’s chat template with “Convert the text to speech:” and the text between the text-understanding markers, the assistant turn opened with the speech-generation marker, then sampling at temperature 0.8 with top-p 1 up to 2048 tokens in all. Training follows the paper (§3.2.1) where it is explicit — peak learning rate 5e-5, a cosine schedule with warm-up over 3% of an epoch and a final rate of 10% of the peak, 3 epochs, sequences cropped to 2048 tokens, the loss on the speech tokens — and the official recipe (train_tts.py, config.json) otherwise: AdamW with β₂ = 0.95 and weight decay 0.01, gradients clipped to norm 1.

Constructors

Constructor Summary
LlasaOptions() Creates the Llasa-1B configuration.
LlasaOptions(LlasaOptions other) Copies another instance.

Properties

Property Summary
bool ConstrainToSpeechTokens { get; set; } Whether each sampled token is restricted to the speech tokens and the end of speech (false).
bool IncludePromptAudio { get; set; } Whether synthesis from a speech prompt returns the prompt’s own audio in front of the new speech (true, as the model card decodes the prompt’s codes with the generated ones).
double Beta1 { get; set; } AdamW’s β₁ (0.9, Hugging Face’s default).
double Beta2 { get; set; } AdamW’s β₂ (0.95, the official config).
double Epsilon { get; set; } AdamW’s ε (1e-8, Hugging Face’s default).
double FinalLearningRateFraction { get; set; } The final learning rate as a fraction of the peak (0.1).
double MaxGradNorm { get; set; } The gradient-norm clip (1.0, Hugging Face’s default; 0 for none).
double RmsEpsilon { get; set; } RMSNorm epsilon (1e-5).
double RopeHighFrequencyFactor { get; set; } Llama 3 rotary scaling’s high-frequency factor (4).
double RopeLowFrequencyFactor { get; set; } Llama 3 rotary scaling’s low-frequency factor (1).
double RopeScalingFactor { get; set; } Llama 3 rotary scaling factor (32; 0 for none).
double RopeTheta { get; set; } Rotary base θ (500000).
double Temperature { get; set; } Sampling temperature (0.8); 0 picks the most likely token.
double TopP { get; set; } Nucleus sampling’s probability mass (1: the whole distribution).
double WarmupEpochFraction { get; set; } The warm-up’s length as a fraction of one epoch (0.03).
int CodecAcousticDim { get; set; } X-codec2’s acoustic feature width (1024).
int CodecDecoderDepth { get; set; } X-codec2’s decoder Transformer blocks (12).
int CodecDecoderDim { get; set; } X-codec2’s decoder width (1024).
int CodecDecoderHeads { get; set; } X-codec2’s decoder attention heads (16).
int CodecEncoderDim { get; set; } X-codec2’s first acoustic-encoder width (48).
int CodecSemanticDim { get; set; } X-codec2’s semantic feature width (1024).
int Epochs { get; set; } The epochs TrainingSteps covers (3), which sizes the warm-up.
int HeadDim { get; set; } Width of each head (64).
int Heads { get; set; } Attention heads (32).
int Intermediate { get; set; } SwiGLU hidden width (8192).
int KeyValueHeads { get; set; } Key-value heads shared by groups of query heads (8).
int Layers { get; set; } Decoder layers (16).
int MaxLength { get; set; } The most tokens in the prompt and the output together (2048, the training length).
int NumDecoderLayers { get; set; } Gets or sets the actual Llama decoder depth.
int NumEncoderLayers { get; set; } Gets or sets X-codec2’s actual Wav2Vec2-BERT semantic encoder read depth.
int NumHeads { get; set; } Gets or sets the actual Llama query-head count.
int RopeOriginalMaxPositions { get; set; } Llama 3 rotary scaling’s original context (8192).
int SamplingSeed { get; set; } The seed of generation’s sampling (and of the native model’s initialization when the architecture has no seed) (0).
int SemanticHeads { get; set; } The w2v-BERT 2.0 encoder’s attention heads (16).
int SemanticHiddenSize { get; set; } The w2v-BERT 2.0 encoder’s width (1024).
int SemanticIntermediateSize { get; set; } The w2v-BERT 2.0 encoder’s feed-forward width (4096).
int SemanticLayer { get; set; } The w2v-BERT 2.0 hidden state X-codec2 reads (16); only that many of its 24 layers are built.
int TrainingSteps { get; set; } The total optimizer steps the schedule spans (0: a constant learning rate).
int[] CodecEncoderRates { get; set; } X-codec2’s acoustic-encoder strides (2, 2, 4, 4, 5): 320 samples a code.
string ChatDate { get; set; } The date the chat template writes into its system header (“Today Date: …”, formatted like “26 Jul 2024”), or null for the current date, as the template does when it runs (null).