Fast ABX evaluation
fastabx is a Python package for efficient computation of ABX discriminability.
The ABX discriminability measures how well categories of interest are separated in the representation space by determining whether tokens from the same category are closer to each other than to those from a different category. While ABX has been mostly used to evaluate speech representations, it is a generic framework that can be applied to other domains of representation learning.
This package provides a simple interface that can be adapted to any ABX conditions, and to any input modality.
- Generic: any ON, BY and ACROSS conditions, on dense or discrete representations, in any modality.
- Fast: triplets are built with lazy polars queries, and distances are computed in batch on CPU or GPU, with DTW running as a PyTorch C++/CUDA extension.
- Ready to use:
zerospeech_abxand thefastabxcommand line interface reproduce the ZeroSpeech triphone and phoneme ABX out of the box.
Check out the documentation for more information: https://docs.cognitive-ml.fr/fastabx
Install
Install the pre-built package in your environment:
pip install fastabx
It requires Python 3.12 or later, and depends on PyTorch 2.10.0 or later, NumPy, Polars, tqdm, and torchdtw.
Quickstart
Simple example:
import numpy as np
from fastabx import Dataset, Score, Task
rng = np.random.default_rng(0)
features = np.concatenate([rng.normal(0, 1, (50, 8)), rng.normal(2, 1, (50, 8))])
labels = {"phone": ["a"] * 50 + ["b"] * 50, "speaker": ["s1", "s2"] * 50}
dataset = Dataset.from_numpy(features, labels) # What to compare
task = Task(dataset, on="phone", by=["speaker"]) # Which triplets to build
score = Score(task, "euclidean") # How to compare them
print(score.collapse(levels=["speaker"])) # ABX error rate
# 0.03059999644756317
On speech, build the dataset from an item file and a directory of features instead, then run the same
Task / Score pipeline:
from fastabx import Dataset
dataset = Dataset.from_item("./triphone-dev-clean.item", "./hubert-l11-dev-clean", frequency=50)
task = Task(dataset, on="#phone", by=["speaker", "next-phone", "prev-phone"])
score = Score(task, "angular")
print(score.collapse(levels=[("next-phone", "prev-phone"), "speaker"]))
The standard ZeroSpeech evaluation is available as a single function, and as a CLI:
from fastabx import zerospeech_abx
error_rate = zerospeech_abx(
"./triphone-dev-clean.item",
"./hubert-l11-dev-clean",
max_size_group=10,
speaker="within",
context="within",
)
fastabx ./triphone-dev-clean.item ./hubert-l11-dev-clean --max-size-group 10
# ABX error rate: 3.378%
See the user guide for the full pipeline, the API reference for every option, and the examples for subsampling, pooling and constraints.
Citation
A preprint is available on arXiv: https://arxiv.org/abs/2505.02692
If you use fastabx in your work, please cite it:
@misc{fastabx,
title={fastabx: A library for efficient computation of ABX discriminability},
author={Maxime Poli and Emmanuel Chemla and Emmanuel Dupoux},
year={2025},
eprint={2505.02692},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2505.02692},
}
License
fastabx is released under the MIT license.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastabx-0.9.0.tar.gz.
File metadata
- Download URL: fastabx-0.9.0.tar.gz
- Upload date:
- Size: 466.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50239c061d47820b2f98b750a26f3d5d796453154e1e57e8605e629a530edec2
|
|
| MD5 |
4afd507509e6a5d6298edc954289ecc6
|
|
| BLAKE2b-256 |
e3913f18096666ce91dfac6beb58fed006182062e6cea487d4cea4cc57e9ac29
|
Provenance
The following attestation bundles were made for fastabx-0.9.0.tar.gz:
Publisher:
release.yml on bootphon/fastabx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastabx-0.9.0.tar.gz -
Subject digest:
50239c061d47820b2f98b750a26f3d5d796453154e1e57e8605e629a530edec2 - Sigstore transparency entry: 2820612032
- Sigstore integration time:
-
Permalink:
bootphon/fastabx@fb233635e5dbd4543ef1c945bb40882a453534fa -
Branch / Tag:
refs/tags/0.9.0 - Owner: https://github.com/bootphon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fb233635e5dbd4543ef1c945bb40882a453534fa -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastabx-0.9.0-py3-none-any.whl.
File metadata
- Download URL: fastabx-0.9.0-py3-none-any.whl
- Upload date:
- Size: 43.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae00922dec668bec72c96eef14c029270b128860e70692d0e4f1419125fed927
|
|
| MD5 |
ff463b701f25a1d41b08ebb79fd42b9e
|
|
| BLAKE2b-256 |
af6581893a4af11f66739c3c616400d0e2f294162b8efa5d120b4abe3dd3d7b8
|
Provenance
The following attestation bundles were made for fastabx-0.9.0-py3-none-any.whl:
Publisher:
release.yml on bootphon/fastabx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastabx-0.9.0-py3-none-any.whl -
Subject digest:
ae00922dec668bec72c96eef14c029270b128860e70692d0e4f1419125fed927 - Sigstore transparency entry: 2820611977
- Sigstore integration time:
-
Permalink:
bootphon/fastabx@fb233635e5dbd4543ef1c945bb40882a453534fa -
Branch / Tag:
refs/tags/0.9.0 - Owner: https://github.com/bootphon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fb233635e5dbd4543ef1c945bb40882a453534fa -
Trigger Event:
push
-
Statement type: