All models

torchaudio.models.hubert_pretrain_base

HuBERT's pre-training wrapper: a wav2vec 2.0-style encoder predicting k-means cluster labels for masked frames.

Audio and speech · 520 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (20 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
94.6M
Operations
520
Framework
PyTorch
Recurrent
No
Published
IEEE/ACM TASLP 2021
Cited by
2,951 (as of 18 October 2026)
Authors
Wei-Ning Hsu, Benjamin Bolte, Yao-Hung Hubert Tsai and others
License
MIT
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m10588
Graph hash
30ec0f6a3c62ea45b1fe2b85254e8b0dbf7349a2199c81c281c008829858efcb
Skeleton hash
ffab738b288d5fb8558880377f0340963ace45e9a12648e617e436ff27bb5188
Architecture hash
c8cd893696fd391011488a4d1d686ca5bdb0ffbc560fd7d074945e095d7c81fd
Diagram SHA-256
a9335f11bfad1076a40a16c4b16140ce3e2d4314cbeecbf6baf8293791b1e5d3
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

The base builder sets a 768-dimensional encoder with 12 layers. Its default is 100 target classes, matching the first-iteration k-means teacher.

About this model's family

HuBERT, the Hidden-Unit BERT, is an approach to self-supervised speech representation learning. The members here are the model as used for pre-training, which wraps the encoder with a mask generator that produces the mask for masked prediction during training, rather than exposing the encoder alone. Speech is hard for self-supervision for three reasons the paper names: multiple sound units per utterance, no lexicon of units during pre-training, and variable-length units with no explicit segmentation.

The trick is an offline clustering step that provides aligned target labels for a BERT-like prediction loss. The prediction loss is applied over the masked regions only, which forces the model to learn a combined acoustic and language model over continuous inputs. The targets come from a simple k-means teacher of 100 clusters, refined over two iterations of clustering. The first-iteration labels come from k-means with 100 clusters on 39-dimensional MFCC features. Later iterations use 500 clusters on latent features extracted from the previous iteration's HuBERT model. Architecturally the models follow wav2vec 2.0: a convolutional waveform encoder, a BERT encoder, a projection layer and a code embedding layer. The waveform encoder is identical across configurations, composed of seven 512-channel layers. It produces a feature sequence at a 20ms framerate for audio sampled at 16kHz.

The forward pass of the pre-training model returns logits for the masked frames, logits for the unmasked frames, and a feature mean value used for an additional penalty loss. Three sizes exist, BASE, LARGE and X-LARGE, the last expanding the model to about 1 billion parameters. With that 1B model, HuBERT shows up to 19% and 13% relative WER reduction on the dev-other and test-other subsets.

Key idea. HuBERT pre-trains a speech encoder by predicting offline k-means cluster labels for masked frames only, relying on the consistency of the clustering rather than the intrinsic quality of the labels.

  • HuBERT
  • Hidden-Unit BERT
  • HuBERTPretrainModel
  • hubert_pretrain_base
  • hubert_pretrain_large
  • hubert_pretrain_xlarge
  • self-supervised speech
  • masked prediction of hidden units
  • speech representation learning
  • torchaudio
  • fairseq
  • wav2vec 2.0

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{hsu2021hubertselfsupervisedspeechrepresentation,
      title={HuBERT: Self-Supervised Speech Representation Learning by Masked Prediction of Hidden Units}, 
      author={Wei-Ning Hsu and Benjamin Bolte and Yao-Hung Hubert Tsai and Kushal Lakhotia and Ruslan Salakhutdinov and Abdelrahman Mohamed},
      year={2021},
      eprint={2106.07447},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2106.07447}, 
}