Downloads · 30 days
0
LeoFeng/superb_wav2vec_submit
superb_wav2vec_submit is a machine learning model from LeoFeng. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Welcome to the SUPERB Challenge! SUPERB is a collection of benchmarking resources to evaluate the capability of a universal shared representation for speech processing. It comes with a benchmark on the publicly availa…
Downloads · 30 days
0
Access
Public
Updated Jul 11, 2022
Repo size
—
Likes
0
Public
Click a slice to open those files.
Other12.5 KB · 47%
From the Hugging Face model README
Welcome to the SUPERB Challenge! SUPERB is a collection of benchmarking resources to evaluate the capability of a universal shared representation for speech processing. It comes with a benchmark on the publicly available datasets and a challenge on a secret/not released hidden dataset. In SUPERB Challenge, a challenging hidden dataset is newly recorded to evaluate the ultimate generaliziblity across various tasks and data.
You can participate the challenge by simply submitting your self-supervised (SSL) pretrained models (model definition & pretrained weights), and we benchmark it with the hidden datasets. This repository constains useful tools to let you easliy submit your models privately for evaluation to the challenge hidden-set leaderboard.
We accept pre-trained models in PyTorch by default. If you wish to submit upstreams in non-PyTorch frameworks, please mail to [email protected]!
If you are not feasible to submit the pre-trained model, please mail to [email protected] for us to see how to help!
Extract features from waveforms.
Input: A list of waveforms in 16000 Hz
SAMPLE_RATE = 16000
BATCH_SIZE = 8
EXAMPLE_SEC = 10
wavs = [torch.randn(SAMPLE_RATE * EXAMPLE_SEC).cuda() for _ in range(BATCH_SIZE)]
Output: A dictionary with a key "hidden_states" (for compatiblility with old ver.). The value is a list of padded sequences in the same shape of (batch_size, max_sequence_length_of_batch, hidden_size) for weighted-sum to work. It is welcome to perform some task-specified / independent pre- / post-processing on the upstream's raw hidden-sets, including upsampling and downsampling. However, all the values must come from a single upstream model:
tasks = ["hidden_states", "PR", "SID", "ER", "ASR", "ASV", "SD", "QbE", "ST", "SS", "SE", "secret"]
for task in tasks:
# you can do task-specified pre- / post-processing depend on the arg "upstream_feature_selection"
results = upstream(wavs, upstream_feature_selection=task)
hidden_states = results["hidden_states"]
assert isinstance(results, dict)
assert isinstance(hidden_states, list)
for state in hidden_states:
assert isinstance(state, torch.Tensor)
assert state.dim() == 3, "(batch_size, max_sequence_length_of_batch, hidden_size)"
assert state.shape == hidden_states[0].shape
Provide the downsample rate from 16000 Hz waveforms for each task's representation in the dict. For the standard 10ms stride representation, the downsample rate is 160.
SAMPLE_RATE = 16000
MSEC_PER_SEC = 1000
downsample_rate = SAMPLE_RATE * 10 / MSEC_PER_SEC # 160
The downsample rate will be used to:
for task in tasks:
assert isinstance(task, str)
downsample_rate = upstream.get_downsample_rate(task)
assert isinstance(downsample_rate, int)
print("The upstream's representation for {task}"
f" has the downsample rate of {downsample_rate}.")
First create an account on the Hugging Face Hub and you can sign up here if you haven't already! Next, create a new organization and invite the SUPERB Hidden Set Committee to join. You will upload your model to a repository under this organization so that members inside it can access the model which is not publicly available.
The next step is to create a template repository on your local machine that contains various files and a CLI to help you validate and submit your pretrained models. The Hugging Face Hub uses Git Large File Storage (LFS) to manage large files, so first install it if you don't have it already. For example, on macOS you can run:
brew install git-lfs
git lfs install
Next, run the following commands to create the repository. We recommend creating a Python virtual environment for the project, e.g. with Anaconda:
# Create and activate a virtual environment
conda create -n superb-submit python=3.8 && conda activate superb-submit
# Install the following libraries
pip install cookiecutter huggingface-hub==0.0.16
# Create the template repository
cookiecutter git+https://huggingface.co/superb/superb-submission
This will ask you to specify your Hugging Face Hub username, password, organisation, and the name of the repository:
hf_hub_username [<huggingface>]:
hf_hub_password [<password>]:
hf_hub_organisation [superb-submissions]:
repo_name [<my-superb-submissions>]:
This will trigger the following steps:
{hf_hub_organisation}/{repo_name}The resulting repository should have the following structure:
my-superb-submission
├── LICENSE
├── README.md <- The README with submission instructions
├── cli.py <- The CLI for validating predictions etc
└── requirements.txt <- The requirements packages for the submissions
├── expert.py <- Your model definition
└── model.pt <- Your model weights
The final step is to install the project's dependencies:
# Navigate to the template repository
cd my-superb-submission
# Install dependencies
python -m pip install -r requirements.txt
That's it! You're now all set to start pretraining your speech models - see the instructions below on how to submit them to the Hub.
To make a submission to the leaderboard, there are 4 main steps:
Modify expert.py and change model.pt so we can initialize an upstream model following the challenge policy by:
upstream = UpstreamExpert(ckpt="./model.pt")
Package Dependency: Note that we only install torch package so far by following the above steps. If your model needs more packages, you can modify the requirement.txt to meet your need and install them inside the current conda environment. We will install the packages you list in the requirement.txt before initializing the upstream model.
Validate the upstream model's interface meets the requirements in the challenge policy. If everything is correct, you should see the following message: "All submission files validated! Now you can make a submission."
python cli.py validate
Push the model to the Hub! If there are no errors, you should see the following message: "Upload successful!"
python cli.py upload "commit message: my best model"
Make a submission at SUPERB website by uniquely indentifying this uploaded model with the following information, which can be shown by:
python cli.py info
After you finish the above 4 steps. You will see a new entry in your SUPERB profile page (need login) which does not have any benchmark numbers yet. Please wait for us to finetuned it on the hidden dataset and get the benchmark results. The results will be revealed within one week. Please stay tuned!