Skip to main content

SpidR: Learning Fast and Stable Linguistic Units for Spoken Language Models Without Supervision

[📜 arXiv] · [📖 OpenReview] · [🖋️ BibTeX]

This repository contains the checkpoints and training code for the self-supervised speech models from the SpidR paper.

Overview

SpidR architecture

SpidR is a self-supervised speech representation model that efficiently learns strong representations for spoken language modeling. It is trained on unlabelled speech using a masked prediction objective combined with self-distillation and online clustering. The intermediate layers of the student model learn to predict assignments derived from the teacher intermediate layers. This learning objective stabilizes the online clustering procedure compared to previous approaches, resulting in higher-quality codebooks. SpidR outperforms previous state-of-the-art methods on downstream language modeling metrics.

Using this repository, you can pretrain SpidR for 400k steps in only a day on 16 A100, and in 15 hours on 16 H100. We distribute two checkpoints: SpidR and DinoSR pretrained with this codebase on LibriSpeech.

Installation

This is available as a package on PyPI. To use the pretrained models, the only dependencies are torch>=2.13.0 and numpy>=1.26.4, with Python 3.12 at least. If you want to train your own model, install the optional train dependencies1.

For inference:

pip install spidr

For training:

pip install spidr[train]

Or if you want to tinker with this repository, clone it and create a virtual environment with uv:

git clone https://github.com/facebookresearch/spidr
cd spidr
uv sync --extra train

You need the optional dependencies to import spidr.data, spidr.slurm, spidr.train, spidr.validate, and to run the scripts in paper/. As we use TorchCodec, you will need to have FFmpeg installed for training.

Usage

Using a pretrained model

We distribute two checkpoints used in our paper: spidr_base and dinosr_base_reproduced. Both are pretrained on LibriSpeech 960h. You can load them like this:

from spidr.models import spidr_base, dinosr_base_reproduced

spidr_model = spidr_base().to("cuda")
dinosr_model = dinosr_base_reproduced().to("cuda")

Or if you don't want to install this library, you can use torch.hub.load:

import torch

spidr_model = torch.hub.load("facebookresearch/spidr", "spidr_base")
dinosr_model = torch.hub.load("facebookresearch/spidr", "dinosr_base_reproduced")

Similarly, you can use the spidr.models.dinosr_base_original function to load the original DinoSR checkpoint.

You can also load the SpidR 2.0 checkpoint released with GSLM2, pretrained on LibriSpeech 960h, with spidr.models.spidr2_base or torch.hub.load("facebookresearch/spidr", "spidr2_base").

The forward function of SpidR, SpidR 2.0 and DinoSR returns the loss and the perplexities. To get intermediate representations use the get_intermediate_outputs method, or the get_codebooks method if you prefer to extract the codebook predictions from the student model.

See paper/extract_features.py for an example of how to use the pretrained models.

Launching training runs

Manifest files

First, create a manifest file that contains the paths to the audio files and the number of samples (either CSV file or TSV like in fairseq). We support loading audio files from an uncompressed tar archive. Use spidr.data.write_manifest to easily create it:

❯ python -m spidr.data.write_manifest --help
usage: write_manifest.py [-h] [--ext EXT] [--fairseq] dataset output

Write manifest files.

positional arguments:
  dataset     Path to the dataset directory or uncompressed tar file.
  output      Path to the output manifest file.

options:
  -h, --help  show this help message and exit
  --ext EXT   Extension of audio files. (default: .wav)
  --fairseq   Write a Fairseq-style TSV manifest, instead of CSV.

Configuration

Create a TOML configuration file for the training run. This will be used to create an instance of spidr.config.Config. Check out src/spidr/config.py to see the available fields. You can start from configs/spidr.toml (it only specifies the required fields) for SpidR and config/spidr2.toml for SpidR 2.0.

Training

We provide utilities to launch jobs on a SLURM cluster. The training run is in one job, and the validation is launched in separate jobs to not interrupt training. You can launch a training run from your terminal:

❯ python -m spidr --help
usage: python -m spidr [-h] -A ACCOUNT -N NODES -G GPUS_PER_NODE [-c CPUS_PER_TASK] [--mem-per-gpu MEM_PER_GPU]
                       [-t TIME] [-C CONSTRAINT] [-p PARTITION] [-q QOS] [-x EXCLUDE] [--dump DUMP]
                       configs [configs ...]

Launch training runs.

positional arguments:
  configs               TOML config file(s) for the training run(s).

options:
  -h, --help            show this help message and exit
  -A, --account ACCOUNT
                        Slurm account (default: None)
  -N, --nodes NODES     Number of nodes (default: None)
  -G, --gpus-per-node GPUS_PER_NODE
                        GPUs per node (default: None)
  -c, --cpus-per-task CPUS_PER_TASK
                        CPUs per task (default: None)
  --mem-per-gpu MEM_PER_GPU
                        Memory per GPU (default: None)
  -t, --time TIME       Time limit in minutes (default: None)
  -C, --constraint CONSTRAINT
                        Slurm constraint (default: None)
  -p, --partition PARTITION
                        Slurm partition (default: None)
  -q, --qos QOS         Slurm QoS (default: None)
  -x, --exclude EXCLUDE
                        Slurm nodes to exclude (default: None)
  --dump DUMP           Submitit dump (default: None)

At launch, the code is copied to the dump folder, and every job of the run (training and validation) runs this copy: later local modifications do not affect them. The jobs run in the directory you launched from, so relative paths in the configuration are resolved from there. This directory must be visible from the compute nodes.

By default we use torch.compile, the first batches will be quite slow to process. To speed up training, you can also remove the computation of the perplexities in the source code if you do not care about it.

Citing SpidR

@article{
  poli2025spidr,
  title={SpidR: Learning Fast and Stable Linguistic Units for Spoken Language Models Without Supervision},
  author={Maxime Poli and Mahi Luthra and Youssef Benchekroun and Yosuke Higuchi and Martin Gleize and Jiayi Shen and Robin Algayres and Yu-An Chung and Mido Assran and Juan Pino and Emmanuel Dupoux},
  journal={Transactions on Machine Learning Research},
  issn={2835-8856},
  year={2025},
  url={https://openreview.net/forum?id=E7XAFBpfZs},
}

License

The source code and our two model checkpoints are provided under the CC BY-NC 4.0 License. The SpidR 2.0 checkpoint is also distributed under the CC BY-NC 4.0 License.

  1. polars, submitit, torchcodec, tqdm, viztracer, and wandb ↩

Metadata

Release files for spidr 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spidr 0.3.0
File Size Uploaded Provenance Actions
spidr-0.3.0.tar.gz 45.7 kB With provenance Details for spidr-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for spidr 0.3.0
File Interpreter ABI Platform Actions
spidr-0.3.0-py3-none-any.whl Python 3 none any Details for spidr-0.3.0-py3-none-any.whl

Total release size: 104.0 kB

Release files / spidr-0.3.0.tar.gz

Download URL spidr-0.3.0.tar.gz
Size 45.7 kB
Tags Source
SHA-256 checksum
How to use checksums
91f13fb0f62d6aae7649c0a2cfa41983e1042dc82fcad472c2629d2c54ce81ab
BLAKE2b-256 checksum
How to use checksums
5f44d39095a5a2fae43f11f805dd57013db74328188f2b93aefe4858df28b728
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / spidr-0.3.0-py3-none-any.whl

Download URL spidr-0.3.0-py3-none-any.whl
Size 58.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b238b9b24967201d32fbe4c8e3cfce849f37ebc725e2f2ea14c515c6ccddf2c1
BLAKE2b-256 checksum
How to use checksums
04ed796c4ad5d8013fcbcf2877b8142ce20f317fcce5b820be3dbfbd6c832c7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Security for spidr 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for spidr-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page