Instructions to use facebook/w2v-bert-2.0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use facebook/w2v-bert-2.0 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="facebook/w2v-bert-2.0")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModel processor = AutoProcessor.from_pretrained("facebook/w2v-bert-2.0") model = AutoModel.from_pretrained("facebook/w2v-bert-2.0", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md (#14)
Browse files- Update README.md (a7dd3f3a8c51c0c43f9645e48754163b5795b5c1)
- Update README.md (f22c97131d1e6698d1d09c8e0f9937424284e73a)
- Update README.md (39999b3ebd9123a62bc541d9d2b5a161d82e3e86)
Co-authored-by: Yoach Lacombe <ylacombe@users.noreply.huggingface.co>
102 unmodified lines10310410510610710810911011111211311411511611730 unmodified lines148149150151102 unmodified linesWe are open-sourcing our Conformer-based [W2v-BERT 2.0 speech encoder](#w2v-bert-20-speech-encoder) as described in Section 3.2.1 of the [paper](https://arxiv.org/pdf/2312.05187.pdf), which is at the core of our Seamless models.| Model Name | #params | checkpoint || ----------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- || W2v-BERT 2.0 | 600M | [checkpoint](https://huggingface.co/reach-vb/conformer-shaw/resolve/main/conformer_shaw.pt)Scaling data size for self-supervised pre-training has been empirically proven to be a relatively cheap, yet effective way to improve speech representation quality (Zhang et al., 2023a). Following such direction, we continued to add more unlabeled speech data, increasing the amount of our pre-training data from 1M hours (Seamless Communication et al., 2023) to approximately 4.5M hours.Besides leveraging more pre-training data, we removed the random-projection quantizer (RPQ) (Chiu et al., 2022) and its associated loss previously incorporated in SeamlessM4T v1 (Seamless Communication et al., 2023).4 Akin to v1, the v2 w2v-BERT 2.0 comprises 24 Conformer layers (Gulati et al., 2020) with approximately 600M parameters and the same pre-training hyperparameters.Here's how you should do a forward pass through the speech encoder:```pythonimport torch30 unmodified lineswith torch.inference_mode():seqs, padding_mask = model.encoder_frontend(seqs, padding_mask)seqs, padding_mask = model.encoder(seqs, padding_mask)```102 unmodified lines10310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915030 unmodified lines181182183184102 unmodified linesWe are open-sourcing our Conformer-based [W2v-BERT 2.0 speech encoder](#w2v-bert-20-speech-encoder) as described in Section 3.2.1 of the [paper](https://arxiv.org/pdf/2312.05187.pdf), which is at the core of our Seamless models.This model was pre-trained on 4.5M hours of unlabeled audio data covering more than 143 languages. It requires finetuning to be used for downstream tasks such as Automatic Speech Recognition (ASR), or Audio Classification.| Model Name | #params | checkpoint || ----------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- || W2v-BERT 2.0 | 600M | [checkpoint](https://huggingface.co/reach-vb/conformer-shaw/resolve/main/conformer_shaw.pt)**This model and its training are supported by 🤗 Transformers, more on it in the [docs](https://huggingface.co/docs/transformers/main/en/model_doc/wav2vec2-bert).**# 🤗 Transformers usageThis is a bare checkpoint without any modeling head, and thus requires finetuning to be used for downstream tasks such as ASR. You can however use it to extract audio embeddings from the top layer with this code snippet:```pythonfrom transformers import AutoFeatureExtractor, Wav2Vec2BertModelimport torchfrom datasets import load_datasetdataset = load_dataset("hf-internal-testing/librispeech_asr_demo", "clean", split="validation")dataset = dataset.sort("id")sampling_rate = dataset.features["audio"].sampling_rateprocessor = AutoProcessor.from_pretrained("facebook/w2v-bert-2.0")model = Wav2Vec2BertModel.from_pretrained("facebook/w2v-bert-2.0")# audio file is decoded on the flyinputs = processor(dataset[0]["audio"]["array"], sampling_rate=sampling_rate, return_tensors="pt")with torch.no_grad():outputs = model(**inputs)```To learn more about the model use, refer to the following resources:- [its docs](https://huggingface.co/docs/transformers/main/en/model_doc/wav2vec2-bert)- [a blog post showing how to fine-tune it on Mongolian ASR](https://huggingface.co/blog/fine-tune-w2v2-bert)- [a training script example](https://github.com/huggingface/transformers/blob/main/examples/pytorch/speech-recognition/run_speech_recognition_ctc.py)# Seamless Communication usageThis model can be used in [Seamless Communication](https://github.com/facebookresearch/seamless_communication), where it was released.Here's how to make a forward pass through the voice encoder, after having completed the [installation steps](https://github.com/facebookresearch/seamless_communication?tab=readme-ov-file#installation):```pythonimport torch30 unmodified lineswith torch.inference_mode():seqs, padding_mask = model.encoder_frontend(seqs, padding_mask)seqs, padding_mask = model.encoder(seqs, padding_mask)```
README.md+37-4