RNN Transducer Model

RNN Transducer Model

class openspeech.models.rnn_transducer.model.RNNTransducerModel(configs: omegaconf.dictconfig.DictConfig, tokenizer: openspeech.tokenizers.tokenizer.Tokenizer)[source]

RNN-Transducer are a form of sequence-to-sequence models that do not employ attention mechanisms. Unlike most sequence-to-sequence models, which typically need to process the entire input sequence (the waveform in our case) to produce an output (the sentence), the RNN-T continuously processes input samples and streams output symbols, a property that is welcome for speech dictation. In our implementation, the output symbols are the characters of the alphabet.

Parameters
  • configs (DictConfig) – configuration set.

  • tokenizer (Tokenizer) – tokenizer is in charge of preparing the inputs for a model.

Inputs:
  • inputs (torch.FloatTensor): A input sequence passed to encoders. Typically for inputs this will be a padded FloatTensor of size (batch, seq_length, dimension).

  • input_lengths (torch.LongTensor): The length of input tensor. (batch)

Returns

Result of model predictions.

Return type

outputs (dict)

RNN Transducer Configuration

class openspeech.models.rnn_transducer.configurations.RNNTransducerConfigs(model_name: str = 'rnn_transducer', encoder_hidden_state_dim: int = 320, decoder_hidden_state_dim: int = 512, num_encoder_layers: int = 4, num_decoder_layers: int = 1, encoder_dropout_p: float = 0.2, decoder_dropout_p: float = 0.2, bidirectional: bool = True, rnn_type: str = 'lstm', output_dim: int = 512, optimizer: str = 'adam')[source]

This is the configuration class to store the configuration of a RNNTransducer.

It is used to initiated an RNNTransducer model.

Configuration objects inherit from :class: ~openspeech.dataclass.configs.OpenspeechDataclass.

Parameters
  • model_name (str) – Model name (default: transformer_transducer)

  • encoder_hidden_state_dim (int) – Hidden state dimension of encoder (default: 312)

  • decoder_hidden_state_dim (int) – Hidden state dimension of decoder (default: 512)

  • num_encoder_layers (int) – The number of encoder layers. (default: 4)

  • num_decoder_layers (int) – The number of decoder layers. (default: 1)

  • encoder_dropout_p (float) – The dropout probability of encoder. (default: 0.2)

  • decoder_dropout_p (float) – The dropout probability of decoder. (default: 0.2)

  • bidirectional (bool) – If True, becomes a bidirectional encoders (default: True)

  • rnn_type (str) – Type of rnn cell (rnn, lstm, gru) (default: lstm)

  • output_dim (int) – dimension of model output. (default: 512)

  • optimizer (str) – Optimizer for training. (default: adam)