mstar.model.omnilingual_asr.components.wav2vec2#
The Omnilingual ASR CTC network: a wav2vec 2.0 encoder plus a linear head.
- waveform (N, S), normalized per utterance, 16 kHz
-> 7 strided convs, each LayerNorm (in fp32) + GELU (x320: 50 frames/s) -> LayerNorm, Linear 512 -> model_dim -> + GELU(grouped conv positional encoding) (kernel 128, 16 groups) -> pre-norm Transformer encoder, final LayerNorm -> Linear model_dim -> vocab (CTC logits)
Module and parameter names follow the fairseq2 checkpoint (encoder_frontend,
encoder, final_proj), so the state dict loads with only the positional
conv’s weight norm folded. Every module here is plain torch with no M* imports,
so the parity harness can run it inside the reference’s own environment.
Batches are right-padded. seq_lens gives each row’s sample count; the
padding never reaches a valid frame: the convolutions only look backwards
from a valid output frame over valid samples, padded frames are zeroed before
the positional convolution, and attention keys past a row’s length are masked.
Functions
|
|
Classes
|
|
|
Pre-norm Transformer layer (fairseq2 |
|
Conv1d -> LayerNorm over channels (computed in fp32) -> GELU. |
|
|
|
|
|
|
|
Adds |
|
|
|
Omnilingual ASR CTC model (fairseq2 |
- class mstar.model.omnilingual_asr.components.wav2vec2.Encoder(cfg)[source]#
Bases:
Module- forward(x, attn_mask)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class mstar.model.omnilingual_asr.components.wav2vec2.EncoderLayer(cfg)[source]#
Bases:
ModulePre-norm Transformer layer (fairseq2
TransformerNormOrder.PRE).- forward(x, attn_mask)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class mstar.model.omnilingual_asr.components.wav2vec2.FeatureExtractionLayer(in_dim, out_dim, kernel_size, stride, eps)[source]#
Bases:
ModuleConv1d -> LayerNorm over channels (computed in fp32) -> GELU.
- forward(x)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class mstar.model.omnilingual_asr.components.wav2vec2.FeatureExtractor(layer_descs, eps)[source]#
Bases:
Module- forward(waveforms)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class mstar.model.omnilingual_asr.components.wav2vec2.FeedForward(model_dim, inner_dim)[source]#
Bases:
Module- forward(x)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class mstar.model.omnilingual_asr.components.wav2vec2.PositionEncoder(model_dim, kernel_size, num_groups)[source]#
Bases:
ModuleAdds
GELU(conv(x))with a grouped, even-kernel conv (its last output column dropped, so the output keeps the input length). The checkpoint’s weight norm (weight_g/weight_v) is folded intoconv.weightat load.- forward(x, frame_mask)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class mstar.model.omnilingual_asr.components.wav2vec2.SelfAttention(model_dim, num_heads)[source]#
Bases:
Module- forward(x, attn_mask)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class mstar.model.omnilingual_asr.components.wav2vec2.Wav2Vec2CTC(cfg)[source]#
Bases:
ModuleOmnilingual ASR CTC model (fairseq2
Wav2Vec2AsrModelat inference).