## Guide to Using the Hugging Face Canary-1B Model

The Hugging Face Canary-1B model is a large multi-lingual multi-tasking model developed by NVIDIA. This guide will provide you with step-by-step instructions on how to use the model for both Automatic Speech-to-text Recognition (ASR) and Automatic Speech-to-text Translation (AST).

### Model Architecture

The Canary-1B model is an encoder-decoder model with a FastConformer encoder and a Transformer Decoder. It has 24 encoder layers and 24 decoder layers in total. The model supports automatic speech-to-text recognition in 4 languages (English, German, French, Spanish) and translation between these languages.

### NVIDIA NeMo

To train, fine-tune, or use the model, it is recommended to install the NVIDIA NeMo toolkit. You can install NeMo using the following command:

“`
pip install git+https://github.com/NVIDIA/NeMo.git@r1.23.0#egg=nemo_toolkit[all]
“`

### How to Use this Model

You can use the model as a pre-trained checkpoint for inference or fine-tune it on another dataset. Use the following Python code to load the model:

“`python
from nemo.collections.asr.models import EncDecMultiTaskModel

canary_model = EncDecMultiTaskModel.from_pretrained(‘nvidia/canary-1b’)

decode_cfg = canary_model.cfg.decoding
decode_cfg.beam.beam_size = 1
canary_model.change_decoding_strategy(decode_cfg)
“`

### Input Format

The input to the model can be a directory containing audio files, or a JSON manifest file containing audio file paths and other relevant information. Use the provided Python code or a command-line script for input data processing.

### Output

The model outputs transcribed or translated text corresponding to the input audio, in the specified target language and with or without punctuation and capitalization.

### Training

The Canary-1B model is trained on a total of 85k hrs of speech data. It can be trained using the NVIDIA NeMo toolkit with the provided example script and base configuration.

### Performance

The model’s performance is evaluated using word error rate (WER) for ASR and BLEU score for AST. The performance metrics for different test sets are provided in the guide.

### NVIDIA Riva: Deployment

The Canary-1B model isn’t currently supported by NVIDIA Riva, but it is compatible with other Hugging Face models.

For more details and information on using the Hugging Face Canary-1B model, refer to the provided references and licensing information.

License: CC-BY-NC-4.0. By using this model, you accept the terms and conditions of the license.

For more information, refer to the references and the NVIDIA Riva documentation.

Happy modeling!

Source link
# HuggingFace Canary-1B Model Manual

## Model Architecture
Canary-1B is an encoder-decoder model with a FastConformer encoder and Transformer Decoder. It has 1 billion parameters and supports automatic speech-to-text recognition (ASR) in 4 languages (English, German, French, Spanish) and translation from English to German/French/Spanish and vice versa.

## NVIDIA NeMo
To train, fine-tune or use the model, you need to install NVIDIA NeMo. It’s recommended to install it after you’ve installed Cython and the latest pytorch version. Use the following command to install NeMo:

“`
pip install git+https://github.com/NVIDIA/NeMo.git@r1.23.0#egg=nemo_toolkit[all]
“`

## How to Use this Model
The model is available for use in the NeMo toolkit and can be used as a pre-trained checkpoint for inference or for fine-tuning on another dataset.

### Loading the Model
Here’s a sample code to load the model using Python:
“`python
from nemo.collections.asr.models import EncDecMultiTaskModel

canary_model = EncDecMultiTaskModel.from_pretrained(‘nvidia/canary-1b’)

decode_cfg = canary_model.cfg.decoding
decode_cfg.beam.beam_size = 1
canary_model.change_decoding_strategy(decode_cfg)
“`

### Input Format
The model accepts input in the form of audio files or a JSON manifest file containing information about the audio files, task, source language, target language, and PnC (punctuation and capitalization) tags.

### Output Format
The model outputs transcribed or translated text corresponding to the input audio, in the specified target language and with or without punctuation and capitalization.

## Training
Canary-1B is trained using the NVIDIA NeMo toolkit for 150k steps with dynamic bucketing and specific batch duration per GPU. The model can be trained using the provided example script and base config.

## Datasets
The Canary-1B model is trained on a total of 85k hrs of speech data, consisting of public data and in-house data for English, German, Spanish, and French.

## Performance
The model’s performance is evaluated using word error rate (WER) for ASR and BLEU score for AST (automatic speech-to-text translation).

## NVIDIA Riva: Deployment
Although the Canary-1B model isn’t supported yet by Riva, it provides out-of-the-box accuracy for common languages, word boosting, and scalability.

## References
– Fast Conformer with Linearly Scalable Attention for Efficient Speech Recognition
– Attention is all you need
– Google Sentencepiece Tokenizer
– NVIDIA NeMo Toolkit

## License
The license to use this model is covered by the CC-BY-NC-4.0. By downloading the public and release version of the model, you accept the terms and conditions of the CC-BY-NC-4.0 license.

Model architecture
| Model size
| Language

NVIDIA NeMo Canary is a family of multi-lingual multi-tasking models that achieves state-of-the art performance on multiple benchmarks. With 1 billion parameters, Canary-1B supports automatic speech-to-text recognition (ASR) in 4 languages (English, German, French, Spanish) and translation from English to German/French/Spanish and from German/French/Spanish to English with or without punctuation and capitalization (PnC).



Model Architecture

Canary is an encoder-decoder model with FastConformer [1] encoder and Transformer Decoder [2].
With audio features extracted from the encoder, task tokens such as <source language>, <target language>, <task> and <toggle PnC>
are fed into the Transformer Decoder to trigger the text generation process. Canary uses a concatenated tokenizer from individual
SentencePiece [3] tokenizers of each language, which makes it easy to scale up to more languages.
The Canay-1B model has 24 encoder layers and 24 layers of decoder layers in total.



NVIDIA NeMo

To train, fine-tune or play with the model you will need to install NVIDIA NeMo. We recommend you install it after you’ve installed Cython and latest pytorch version.

pip install git+https://github.com/NVIDIA/NeMo.git@r1.23.0#egg=nemo_toolkit[all]



How to Use this Model

The model is available for use in the NeMo toolkit [4], and can be used as a pre-trained checkpoint for inference or for fine-tuning on another dataset.



Loading the Model

from nemo.collections.asr.models import EncDecMultiTaskModel


canary_model = EncDecMultiTaskModel.from_pretrained('nvidia/canary-1b')


decode_cfg = canary_model.cfg.decoding
decode_cfg.beam.beam_size = 1
canary_model.change_decoding_strategy(decode_cfg)



Input Format

The input to the model can be a directory containing audio files, in which case the model will perform ASR on English and produces text with punctuation and capitalization:

predicted_text = canary_model.trancribe(
    audio_dir="<path to directory containing audios>",
    batch_size=16,  
)

or use:

python [NEMO_GIT_FOLDER]/examples/asr/transcribe_speech.py 
 pretrained_name="nvidia/canary-1b" 
 audio_dir="<path to audio directory>" 

Another recommended option is to use a json manifest as input, where each line in the file is a dictionary containing the following fields:


{
    "audio_filepath": "/path/to/audio.wav",  
    "duration": None,  
    "taskname": "asr",  
    "source_lang": "en",  
    "target_lang": "en",  
    "pnc": "yes",  
}

and then use:

predicted_text = canary_model.transcribe(
    "<path to input manifest file>",
    batch_size=16,  
)

or use:

python [NEMO_GIT_FOLDER]/examples/asr/transcribe_speech.py 
 pretrained_name="nvidia/canary-1b" 
 dataset_manifest="<path to manifest file>" 



Automatic Speech-to-text Recognition (ASR)

An example manifest for transcribing English audios can be:


{
    "audio_filepath": "/path/to/audio.wav",  
    "duration": None,  
    "taskname": "asr",  
    "source_lang": "en", 
    "target_lang": "en", 
    "pnc": "yes",  
}



Automatic Speech-to-text Translation (AST)

An example manifest for transcribing English audios into German text can be:


{
    "audio_filepath": "/path/to/audio.wav",  
    "duration": None,  
    "taskname": "ast",  
    "source_lang": "en", 
    "target_lang": "de", 
    "pnc": "yes",  
}



Input

This model accepts single channel (mono) audio sampled at 16000 Hz, along with the task/languages/PnC tags as input.



Output

The model outputs the transcribed/translated text corresponding to the input audio, in the specified target language and with or without punctuation and capitalization.



Training

Canary-1B is trained using the NVIDIA NeMo toolkit [4] for 150k steps with dynamic bucketing and a batch duration of 360s per GPU on 128 NVIDIA A100 80GB GPUs.
The model can be trained using this example script and base config.

The tokenizers for these models were built using the text transcripts of the train set with this script.



Datasets

The Canary-1B model is trained on a total of 85k hrs of speech data. It consists of 31k hrs of public data, 20k hrs collected by Suno, and 34k hrs of in-house data.

The constituents of public data are as follows.



English (25.5k hours)

  • Librispeech 960 hours
  • Fisher Corpus
  • Switchboard-1 Dataset
  • WSJ-0 and WSJ-1
  • National Speech Corpus (Part 1, Part 6)
  • VCTK
  • VoxPopuli (EN)
  • Europarl-ASR (EN)
  • Multilingual Librispeech (MLS EN) – 2,000 hour subset
  • Mozilla Common Voice (v7.0)
  • People’s Speech – 12,000 hour subset
  • Mozilla Common Voice (v11.0) – 1,474 hour subset



German (2.5k hours)

  • Mozilla Common Voice (v12.0) – 800 hour subset
  • Multilingual Librispeech (MLS DE) – 1,500 hour subset
  • VoxPopuli (DE) – 200 hr subset



Spanish (1.4k hours)

  • Mozilla Common Voice (v12.0) – 395 hour subset
  • Multilingual Librispeech (MLS ES) – 780 hour subset
  • VoxPopuli (ES) – 108 hour subset
  • Fisher – 141 hour subset



French (1.8k hours)

  • Mozilla Common Voice (v12.0) – 708 hour subset
  • Multilingual Librispeech (MLS FR) – 926 hour subset
  • VoxPopuli (FR) – 165 hour subset



Performance

In both ASR and AST experiments, predictions were generated using beam search with width 5 and length penalty 1.0.



ASR Performance (w/o PnC)

The ASR performance is measured with word error rate (WER), and we process the groundtruth and predicted text with whisper-normalizer.

WER on MCV-16.1 test set:

Version Model En De Es Fr
1.23.0 canary-1b 7.97 4.61 3.99 6.53

WER on MLS test set:

Version Model En De Es Fr
1.23.0 canary-1b 3.06 4.19 3.15 4.12

More details on evaluation can be found at HuggingFace ASR Leaderboard



AST Performance

We evaluate AST performance with BLEU score, and use native annotations with punctuation and capitalization in the datasets.

BLEU score on FLEURS test set:

Version Model En->De En->Es En->Fr De->En Es->En Fr->En
1.23.0 canary-1b 22.66 41.11 40.76 32.64 32.15 23.57

BLEU score on COVOST-v2 test set:

Version Model De->En Es->En Fr->En
1.23.0 canary-1b 37.67 40.7 40.42

BLEU score on mExpresso test set:

Version Model En->De En->Es En->Fr
1.23.0 canary-1b 23.84 35.74 28.29



NVIDIA Riva: Deployment

NVIDIA Riva, is an accelerated speech AI SDK deployable on-prem, in all clouds, multi-cloud, hybrid, on edge, and embedded.
Additionally, Riva provides:

  • World-class out-of-the-box accuracy for the most common languages with model checkpoints trained on proprietary data with hundreds of thousands of GPU-compute hours
  • Best in class accuracy with run-time word boosting (e.g., brand and product names) and customization of acoustic model, language model, and inverse text normalization
  • Streaming speech recognition, Kubernetes compatible scaling, and enterprise-grade support

Although this model isn’t supported yet by Riva, the list of supported models is here.
Check out Riva live demo.



References

[1] Fast Conformer with Linearly Scalable Attention for Efficient Speech Recognition

[2] Attention is all you need

[3] Google Sentencepiece Tokenizer

[4] NVIDIA NeMo Toolkit



Licence

License to use this model is covered by the CC-BY-NC-4.0. By downloading the public and release version of the model, you accept the terms and conditions of the CC-BY-NC-4.0 license.

The

tag in HTML is a generic container element that is used to divide the content of a web page into smaller, more manageable sections. It can be used to group together elements for styling purposes, and it can be used to apply javascript to a group of elements.

One common use case for the

tag is to create a container for a group of related elements. This can be useful for styling purposes, as it allows the developer to apply styling to a group of elements at once, rather than having to apply the same styling to each individual element.

Another common use case for the

tag is to create a grid layout on a web page. By using

elements with specific styling, developers can create complex grid layouts for their web pages, which can be used to display content in a more organized and visually appealing way.

The

tag is also often used to create responsive designs for web pages. By using

elements with flexible widths and heights, developers can create layouts that adjust and reflow based on the size of the user’s screen, making the web page more user-friendly and accessible on different devices.

In the context of the provided HTML code, the

tag is being used to structure the content of a web page. The code includes headings, paragraphs, images, and tables, all enclosed within

tags. This allows for the grouping of related content and the application of styling and scripting to the entire group of elements.

In summary, the

tag in HTML has a wide range of use cases, from structuring content and creating layouts, to applying styles and scripts to a group of related elements. Its flexibility and versatility make it an essential element in the development of modern, responsive web pages.

2024-02-09T20:37:55+01:00