Skip to main content

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: Frozen
  • 1: Unfrozen
  • N > 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 ASR
  • ModelType.LLM_ASR_LID: ASR with language ID
  • ModelType.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:
  1. During decoding, track the last compression_window tokens
  2. Compute compression ratio (e.g., using zlib)
  3. If ratio > compression_threshold, stop decoding
Example: Repetitive output like “the the the the…” compresses well and triggers early stopping.

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

  1. Segmentation: Audio is split into segment_secs chunks
  2. Context: Previous n_context_segments are maintained for continuity
  3. Transcription: Each segment is transcribed with context
  4. Concatenation: Segment transcriptions are concatenated into final output

Wav2Vec2LlamaSpecialTokens

Special token indices allocated beyond vocabulary size.

Properties

All special tokens are allocated as vocab_size + offset:

Default/LID Syntax

int
Language ID marker token: vocab_size + 0

Streaming Syntax

int
Streaming language token: vocab_size + 0
int
Last segment marker: vocab_size + 1
int
Regular segment marker: vocab_size + 2

Context Syntax (Zero-Shot)

int
Context start marker: vocab_size + 0
int
Context end marker: vocab_size + 1
int
Context example start marker: vocab_size + 2
int
Context example end marker: vocab_size + 3
int
Context BOS token: vocab_size + 4
int
Context EOS token: vocab_size + 5

Example

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 at src/omnilingual_asr/models/wav2vec2_llama/config.py