sWuggy / README.md
nhamilakis's picture
Update README.md
67cf9cf verified
---
license: afl-3.0
language:
- en
- fr
tags:
- speech
- audio
- benchmark
- evaluation
- spoken-language-model
- lexical-decision
- sWuggy
- zerospeech
pretty_name: sWuggy
configs:
- config_name: inftrain
data_dir: "inftrain"
data_files:
- split: en_testset_1
path: "en/audio/testset_1-*.tar"
- split: en_testset_2
path: "en/audio/testset_2-*.tar"
- split: en_testset_4
path: "en/audio/testset_4-*.tar"
- split: en_testset_8
path: "en/audio/testset_8-*.tar"
- split: en_testset_16
path: "en/audio/testset_16-*.tar"
- split: en_testset_32
path: "en/audio/testset_32-*.tar"
- split: en_testset_64
path: "en/audio/testset_64-*.tar"
- split: fr_testset_1
path: "fr/audio/testset_1-*.tar"
- split: fr_testset_2
path: "fr/audio/testset_2-*.tar"
- split: fr_testset_4
path: "fr/audio/testset_4-*.tar"
- split: fr_testset_8
path: "fr/audio/testset_8-*.tar"
- split: fr_testset_16
path: "fr/audio/testset_16-*.tar"
- split: fr_testset_32
path: "fr/audio/testset_32-*.tar"
- split: fr_testset_64
path: "fr/audio/testset_64-*.tar"
- config_name: zrc2021
data_dir: "zrc2021"
data_files:
- split: en_dev
path: "en/dev-*.tar"
- split: en_test
path: "en/test-*.tar"
---
# sWuggy
sWuggy is a spoken lexical-discrimination benchmark: each item is a pair consisting of a
real word and a phonotactically matched pseudo-word, synthesized as audio. A model is
scored on whether it assigns higher probability to the real word than to its matched
pseudo-word. This repository hosts the audio (as WebDataset tar shards) together with
the per-item metadata needed to run the evaluation.
> **Evaluation only.** This is a held-out benchmark for *evaluating* spoken language
> models. It must **not** be used as training data. Training on these items
> invalidates any sWuggy score and contaminates the benchmark for everyone.
> **Status:** A companion repository with the evaluation code for this benchmark is a
> work in progress and will be linked here once released. For now this repository
> provides the data and the file layout described below.
## Repository layout
Audio is packed into [WebDataset](https://huggingface.co/docs/hub/datasets-webdataset)
tar shards (many small audio files would otherwise hit the Hub's 10,000-files-per-
directory limit and make download/streaming slow). Metadata stays as plain CSV/TXT
files alongside the shards.
```
inftrain/
en/
audio/ testset_{1,2,4,8,16,32,64}-{000000..NNNNNN}.tar # audio shards
frequencies/ testset_{1,2,4,8,16,32,64}.csv # per-item metadata
gold.csv # gold labels
fr/
audio/ testset_{1,2,4,8,16,32,64}-{000000..NNNNNN}.tar
frequencies/ testset_{1,2,4,8,16,32,64}.csv
gold.csv
zrc2021/
en/
dev-{000000..NNNNNN}.tar # audio shards
test-{000000..NNNNNN}.tar
dev_filesmap.txt
dev.gold.csv
test_filesmap.txt
test.gold.csv
```
There are two top-level collections:
- **`inftrain/`** — the main sWuggy evaluation material, split by language (`en`, `fr`)
and by test set (`testset_1``testset_64`). Despite the directory name, this is
evaluation data and is not for training. <!-- TODO: state what the testset_N
numbering means, e.g. number of synthesized voices per item / subset size. -->
- **`zrc2021/`** — the ZeroSpeech 2021 sWuggy split (`dev` / `test`), under `en/`.
### Inside a shard
Each tar shard is a plain POSIX tar. Every audio file is stored under its basename,
so the WebDataset *key* is the filename stem. Files that share a key are grouped into
the same example; here each example is a single audio file, and its label/metadata
lives in the accompanying CSV keyed by the same filename. Audio is
`.ogg` for `inftrain/` and `.wav` for `zrc2021/`.
<!-- TODO: confirm audio format details: sample rate, channels, encoding. -->
### Metadata files
- `gold.csv` / `*.gold.csv` — gold labels per item. <!-- TODO: document columns,
e.g. filename, word, is_real_word (or word vs non-word), pair id. -->
- `frequencies/testset_N.csv` — per-item lexical frequency information.
<!-- TODO: document columns. -->
- `*_filesmap.txt` (zrc2021) — mapping between item identifiers and audio files.
<!-- TODO: document format. -->
## Accessing the data
### Stream the audio with `datasets`
The audio is in WebDataset format, so it is loaded with the `webdataset` builder.
Map a glob of shards to a split with `data_files`, and stream with `streaming=True`
to avoid downloading everything up front:
```python
from datasets import load_dataset
# One test set of the English inftrain material:
ds = load_dataset(
"webdataset",
data_files={"test": "hf://datasets/coml/sWuggy/inftrain/en/audio/testset_1-*.tar"},
split="test",
streaming=True,
)
for sample in ds:
# The audio column is named after the file suffix inside the tar
# ("ogg" for inftrain, "wav" for zrc2021); the key is in sample["__key__"].
key = sample["__key__"]
audio = sample["ogg"] # bytes; decode with soundfile/librosa as needed
break
```
Load several test sets at once by mapping each to its own split:
```python
data_files = {
f"testset_{n}": f"hf://datasets/coml/sWuggy/inftrain/en/audio/testset_{n}-*.tar"
for n in (1, 2, 4, 8, 16, 32, 64)
}
ds = load_dataset("webdataset", data_files=data_files, streaming=True)
```
The ZeroSpeech 2021 split works the same way with the `wav` suffix:
```python
ds = load_dataset(
"webdataset",
data_files={
"dev": "hf://datasets/coml/sWuggy/zrc2021/en/dev-*.tar",
"test": "hf://datasets/coml/sWuggy/zrc2021/en/test-*.tar",
},
streaming=True,
)
```
### Read the metadata
The CSV/TXT metadata can be read directly over `hf://` without downloading the audio:
```python
import polars as pl
gold = pl.read_csv("hf://datasets/coml/sWuggy/inftrain/en/gold.csv")
freqs = pl.read_csv("hf://datasets/coml/sWuggy/inftrain/en/frequencies/testset_1.csv")
```
Join metadata to audio on the WebDataset key (the filename stem) where you need both.
### Download specific files
To pull individual shards or metadata files to local disk:
```python
from huggingface_hub import hf_hub_download
path = hf_hub_download(
repo_id="coml/sWuggy",
repo_type="dataset",
filename="inftrain/en/gold.csv",
)
```
Or snapshot a subset with `huggingface_hub.snapshot_download(..., allow_patterns=...)`.
## Evaluation
The evaluation expects, for each word / pseudo-word pair, a model score (typically a
log-probability or pseudo log-likelihood) for both audio items; accuracy is the
fraction of pairs where the real word is scored above its matched pseudo-word.
Evaluation code that runs this end-to-end is being prepared in a separate repository
and will be linked here. <!-- TODO: link the eval repo when public. -->
## License
Released under the Academic Free License v3.0 (`afl-3.0`).
## Citation
<!-- TODO: add the citation(s) for sWuggy and ZeroSpeech 2021. -->
## Contact
<!-- TODO: maintainer / contact, or point to the Community tab. -->
Questions and issues: please open a discussion in the **Community** tab of this
repository.