SpeechLM-librispeech

Speech language models from Kando, Miyao and Takamichi (Interspeech 2025), trained with SpeechLM: an OPT language model over discrete units of speech. Each model uses a different number of units K, and lives on its own branch:

Branch Units (K)
k128 128
k256 256
k512 512
k1024 1024

main only holds this card. Each branch has the language model (model.safetensors, its config and tokenizer), the k-means (kmeans.safetensors), and the training results (*_results.json).

Model

  • Units: features of layer 9 of HuBERT BASE (torchaudio's HUBERT_BASE, trained on LibriSpeech 960h) at 20 ms frames, assigned to the nearest of K k-means centers, with consecutive repeats merged. The k-means was fit on a 100-hour subset of the LibriSpeech training set.
  • Language model: OPT, 12 layers, 16 attention heads, embedding size 1024, FFN size 4096, trained on LibriSpeech (960h) in chunks of 2,048 units, for up to 50,000 steps at batch size 16, with early stopping on the validation loss.
  • The paper averages three training seeds; these are the models of seed 0.

These are the paper's 20 ms (no pooling) models; the paper also studies coarser segmentations.

Usage

The log likelihood of an utterance (16 kHz, mono):

import torch
import torchaudio
from huggingface_hub import snapshot_download
from safetensors.torch import load_file
from transformers import AutoModelForCausalLM, AutoTokenizer

K = 128
model_dir = snapshot_download("BabyLM-community/SpeechLM-librispeech", revision=f"k{K}")
centers = load_file(f"{model_dir}/kmeans.safetensors")["cluster_centers"]  # (K, 768), float64
tokenizer = AutoTokenizer.from_pretrained(model_dir)
lm = AutoModelForCausalLM.from_pretrained(model_dir).eval()
hubert = torchaudio.pipelines.HUBERT_BASE.get_model().eval()

waveform = ...  # a float tensor of shape (1, samples), at 16 kHz
with torch.inference_mode():
    layers, _ = hubert.extract_features(waveform, num_layers=9)
    units = torch.cdist(layers[-1][0].double(), centers).argmin(dim=1)
    units = torch.unique_consecutive(units)  # merge repeats
    inputs = tokenizer(" ".join(map(str, units.tolist())), return_tensors="pt")  # appends <eos>
    mean_log_likelihood = -lm(**inputs, labels=inputs["input_ids"]).loss.item()

The nearest center is what scikit-learn's MiniBatchKMeans.predict computes; the original k-means was a scikit-learn pickle, converted here to its cluster centers.

Citation

@inproceedings{kando25_interspeech,
  title     = {Exploring the Effect of Segmentation and Vocabulary Size on Speech Tokenization for Speech Language Models},
  author    = {Shunsuke Kando and Yusuke Miyao and Shinnosuke Takamichi},
  booktitle = {Interspeech 2025},
  pages     = {5728--5732},
  year      = {2025},
  doi       = {10.21437/Interspeech.2025-310},
}
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train BabyLM-community/SpeechLM-librispeech

Collection including BabyLM-community/SpeechLM-librispeech