Overview
Omnilingual ASR uses several configuration classes to define model architecture, beam search, and streaming behavior.Wav2Vec2LlamaConfig
Top-level configuration combining Wav2Vec2 encoder and Llama decoder settings.Structure
Wav2Vec2AsrConfig
required
Wav2Vec2 configuration for encoder frontend and encoder.
LLaMAConfig
required
Llama configuration for decoder.
Wav2Vec2LlamaBeamSearchConfig
default:"Wav2Vec2LlamaBeamSearchConfig()"
Beam search configuration for LLM-ASR decoding.
Wav2Vec2LlamaStreamingConfig
default:"Wav2Vec2LlamaStreamingConfig()"
Streaming configuration for >30s transcriptions.
int
default:"1"
Number of audio embedding frames to stack before decoder.
int
default:"1"
Encoder freeze setting:
0: Frozen1: UnfrozenN > 1: Unfrozen every N calls
float
default:"0.0"
Probability of dropping language embeddings during training.
str
default:"lang"
Column name containing language information in batch metadata.
bool
default:"False"
Adapts model input syntax for text-only context (instead of audio+text).
int
default:"0"
Number of additional special tokens to allocate in vocab-embedding mapping.
ModelType
default:"ModelType.LLM_ASR"
High-level model type:
ModelType.LLM_ASR: Standard ASRModelType.LLM_ASR_LID: ASR with language IDModelType.ZERO_SHOT: Zero-shot with context
int
default:"0"
Number of context examples for zero-shot model.
Vocabulary Parameters
int
default:"3"
Index of UNK token in vocabulary.
int
default:"0"
Index of BOS (beginning of sequence) token.
int
default:"2"
Index of EOS (end of sequence) token.
int
default:"1"
Index of PAD token. Must align with Llama’s
pad_idx.Example
Wav2Vec2LlamaBeamSearchConfig
Configuration for beam search decoding.Parameters
int
default:"5"
Size of the beam (number of hypotheses to maintain).
bool
default:"False"
Whether to apply length normalization when computing hypothesis scores.
int
default:"100"
Window size for early stopping detection. If the last N tokens compress at a ratio greater than
compression_threshold, decoding stops.float
default:"4.0"
Compression ratio threshold for early stopping (used with
compression_window).Example
Early Stopping
Early stopping prevents infinite loops on bad audio:- During decoding, track the last
compression_windowtokens - Compute compression ratio (e.g., using zlib)
- If ratio >
compression_threshold, stop decoding
Wav2Vec2LlamaStreamingConfig
Configuration for streaming mode (unlimited audio length).Parameters
bool
default:"False"
Enable streaming mode for >30s audio.
float
default:"15.0"
Duration of each audio segment in seconds.
int
default:"16000"
Audio sample rate in Hz.
int
default:"1"
Number of context segments to maintain (in addition to current segment).
str
default:""
Name of text tokenizer for streaming mode.
int
default:"25"
Minimum audio length in milliseconds. Shorter segments are dropped.
Example
Streaming Processing
- Segmentation: Audio is split into
segment_secschunks - Context: Previous
n_context_segmentsare maintained for continuity - Transcription: Each segment is transcribed with context
- Concatenation: Segment transcriptions are concatenated into final output
Wav2Vec2LlamaSpecialTokens
Special token indices allocated beyond vocabulary size.Properties
All special tokens are allocated asvocab_size + offset:
Default/LID Syntax
int
Language ID marker token:
vocab_size + 0Streaming Syntax
int
Streaming language token:
vocab_size + 0int
Last segment marker:
vocab_size + 1int
Regular segment marker:
vocab_size + 2Context Syntax (Zero-Shot)
int
Context start marker:
vocab_size + 0int
Context end marker:
vocab_size + 1int
Context example start marker:
vocab_size + 2int
Context example end marker:
vocab_size + 3int
Context BOS token:
vocab_size + 4int
Context EOS token:
vocab_size + 5Example
ModelType Enum
Defines the high-level model variant.Usage
Predefined Configurations
Omnilingual ASR provides predefined configurations:Loading Configs
Configuration Validation
Configs are validated in__post_init__:
Complete Example
Source Reference
See implementation atsrc/omnilingual_asr/models/wav2vec2_llama/config.py