openslr/librispeech_asr
Viewer • Updated • 585k • 168k • 258
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).
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.These are the paper's 20 ms (no pooling) models; the paper also studies coarser segmentations.
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.
@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},
}