Squeezeformer<T>

Models & Types · AiDotNet.SpeechRecognition.ConformerFamily

Squeezeformer speech recognition model with temporal U-Net structure.

Inheritance: NeuralNetworkBase<T> → AudioNeuralNetworkBase<T> → Squeezeformer<T>

Implements: ISpeechRecognizer<T>

For Beginners

Squeezeformer restructures Conformer with: (1) Temporal U-Net: downsamples time resolution in middle layers, upsamples at the end, (2) Micro-macro design: pre-norm (more stable training) replaces post-norm, (3) Simplified block: MHA → Conv → FF (r…

How It Works

References:

  • Paper: “Squeezeformer: An Efficient Transformer for Automatic Speech Recognition” (Kim et al., 2022)

Squeezeformer restructures Conformer with: (1) Temporal U-Net: downsamples time resolution in middle layers, upsamples at the end, (2) Micro-macro design: pre-norm (more stable training) replaces post-norm, (3) Simplified block: MHA → Conv → FF (removes redundant second FF from Conformer). These changes reduce compute by ~30% while matching or exceeding Conformer accuracy.

Example

// Create a Squeezeformer model with temporal U-Net downsampling
var architecture = new NeuralNetworkArchitecture<double>(
    inputType: InputType.OneDimensional,
    taskType: NeuralNetworkTaskType.SpeechRecognition,
    inputHeight: 16000, inputWidth: 1, inputDepth: 1, outputSize: 5000);
var model = new Squeezeformer<double>(architecture);
            
// Or load a pre-trained ONNX model for efficient ASR inference
var onnxModel = new Squeezeformer<double>(architecture, "squeezeformer.onnx");

Constructors

Constructor Summary
Squeezeformer(NeuralNetworkArchitecture<T> architecture, SqueezeformerOptions options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer)
Squeezeformer(NeuralNetworkArchitecture<T> architecture, string modelPath, SqueezeformerOptions options)

Properties

Property Summary
IReadOnlyList<string> SupportedLanguages { get; }
bool SupportsStreaming { get; }
bool SupportsWordTimestamps { get; }

Methods

Method Summary
IReadOnlyDictionary<string, T> DetectLanguageProbabilities(Tensor<T> audio)
IStreamingTranscriptionSession<T> StartStreamingSession(string language)
ModelMetadata<T> GetModelMetadata()
Task<TranscriptionResult<T>> TranscribeAsync(Tensor<T> audio, string language, bool? includeTimestamps, CancellationToken cancellationToken)
TranscriptionResult<T> Transcribe(Tensor<T> audio, string language, bool? includeTimestamps) Transcribes audio using Squeezeformer’s temporal U-Net encoder.
string DetectLanguage(Tensor<T> audio)