Views
No views yet
| Model | Pre-Training Dataset | Download Link |
|---|---|---|
| LightHuBERT Base | 960 hrs LibriSpeech | huggingface: lighthubert/lighthubert_base.pt |
| LightHuBERT Small | 960 hrs LibriSpeech | huggingface: lighthubert/lighthubert_small.pt |
| LightHuBERT Stage 1 | 960 hrs LibriSpeech | huggingface: lighthubert/lighthubert_stage1.pt |
1import torch
2from lighthubert import LightHuBERT, LightHuBERTConfig
3
4wav_input_16khz = torch.randn(1,10000).cuda()
5
6# load the pre-trained checkpoints
7checkpoint = torch.load('/path/to/lighthubert.pt')
8cfg = LightHuBERTConfig(checkpoint['cfg']['model'])
9cfg.supernet_type = 'base'
10model = LightHuBERT(cfg)
11model = model.cuda()
12model = model.eval()
13print(model.load_state_dict(checkpoint['model'], strict=False))
14
15# (optional) set a subnet
16subnet = model.supernet.sample_subnet()
17model.set_sample_config(subnet)
18params = model.calc_sampled_param_num()
19print(f"subnet (Params {params / 1e6:.0f}M) | {subnet}")
20
21# extract the the representation of last layer
22rep = model.extract_features(wav_input_16khz)[0]
23
24# extract the the representation of each layer
25hs = model.extract_features(wav_input_16khz, ret_hs=True)[0]
26
27print(f"Representation at bottom hidden states: {torch.allclose(rep, hs[-1])}")lighthubert in s3prl.1cd DeepSpeed
2# lighthubert_small
3python testing/s3prl_profiling_test.py -u lighthubert_small --libri_root "libri_root"
4# lighthubert_base
5python testing/s3prl_profiling_test.py -u lighthubert_base --libri_root "libri_root"
6# lighthubert_stage1
7python testing/s3prl_profiling_test.py -u lighthubert_stage1 --libri_root "libri_root"1@article{wang2022lighthubert,
2 title={{LightHuBERT}: Lightweight and Configurable Speech Representation Learning with Once-for-All Hidden-Unit {BERT}},
3 author={Rui Wang and Qibing Bai and Junyi Ao and Long Zhou and Zhixiang Xiong and Zhihua Wei and Yu Zhang and Tom Ko and Haizhou Li},
4 journal={arXiv preprint arXiv:2203.15610},
5 year={2022}
6}rwang@tongji.edu.cn).