Skip to main content

Overview

Wav2Vec2LlamaModel combines a Wav2Vec2 encoder with a Llama decoder for automatic speech recognition. It supports three model variants:
  • LLM_ASR: Standard encoder-decoder ASR
  • LLM_ASR_LID: ASR with language identification conditioning
  • ZERO_SHOT: Zero-shot learning with context examples

Constructor

Core Parameters

ModelType
required
Model variant:
  • ModelType.LLM_ASR: Standard ASR
  • ModelType.LLM_ASR_LID: ASR with language ID
  • ModelType.ZERO_SHOT: Zero-shot with context
int
required
Model dimension of the transformer decoder.
Wav2Vec2Frontend
required
Wav2Vec2 encoder frontend for feature extraction.
TransformerEncoder
required
Wav2Vec2 encoder.
nn.Module
required
Projection layer from encoder outputs to decoder dimension.
StandardEmbedding
required
Text token embedding module.
TransformerLMDecoder
required
Llama decoder-only model.
nn.Module
required
Final projection layer from decoder to vocabulary logits.
VocabularyInfo
required
Vocabulary information including size and special token indices.

Optional Parameters

Wav2Vec2Masker | None
default:"None"
Feature masker for Wav2Vec2 (used during training).
int
default:"8192"
Maximum length of generated sequences in decoder.
int
default:"1"
Number of encoder frames to stack before feeding to decoder (for compression).
float
default:"0.0"
Probability of using language embeddings (for LID model). Dropout probability during training.
str
default:"lang"
Name of the batch metadata field containing language information.
StandardEmbedding | None
default:"None"
Language embedding module (required for LID model).
dict[str, int] | None
default:"None"
Mapping from language codes to embedding indices.
bool
default:"False"
Whether to use text-only context (instead of audio+text).
Wav2Vec2LlamaBeamSearchConfig
default:"Wav2Vec2LlamaBeamSearchConfig()"
Beam search configuration for decoding.
Wav2Vec2LlamaStreamingConfig
default:"Wav2Vec2LlamaStreamingConfig()"
Streaming configuration for >30s audio.
TokenEncoder | None
default:"None"
Text encoder for streaming mode.
int
default:"0"
Number of context examples for zero-shot model.
int
default:"42"
Random seed for reproducibility.
Models are typically loaded using load_model("omniASR_LLM_7B") rather than constructed directly.

Forward Pass

Seq2SeqBatch
required
Input batch containing source audio and target text.
bool
default:"False"
Whether to return logits along with loss (for debugging).
bool
default:"False"
Whether to return decoder inputs for beam search (inference mode).

Return Values

Model Architectures

Standard LLM-ASR

Input syntax:

Zero-Shot Model

Input syntax:

Streaming Model

Input syntax:
Segment markers:
  • <regular_segment>: For intermediate segments
  • <last_segment>: For final segment

Embedding Methods

embed_audio

Runs encoder and frontend on audio tensors.
Tensor
required
Audio waveforms [batch_size, time].
List[int]
required
Actual sequence lengths.
Tensor
Embedded audio [batch_size, reduced_time, model_dim].
List[int]
Reduced sequence lengths after encoder.

embed_text

Embeds text tokens.
Tensor
required
Text token indices [batch_size, seq_len].
torch.dtype
required
Target dtype for embeddings.
Tensor
Text embeddings [batch_size, seq_len, model_dim].

Training Example

Inference Example

Model Variants

See Also

Source Reference

See implementation at src/omnilingual_asr/models/wav2vec2_llama/model.py:43