Views
No views yet
mini-bart-g2p is a seq2seq model based on the BART architecture.
We spruce down the number of layers and transformer heads in the original BART architecture to ensure that we can reliably train the model for the grapheme to phoneme conversion task.1from transformers import pipeline
2
3pipe = pipeline(task="text2text-generation", model="cisco-ai/mini-bart-g2p")
4
5text = "hello world"
6# DO NOT DO ```pipe(text)``` as this will produce unexpected results.
7
8pipe(text.split())
9# [{'translation_text': 'HH EH1 L OW0'}, {'translation_text': 'W ER1 L D'}]
10
11text = "co-workers coworkers hunter's hunter"
12pipe(text.split())
13
14# [{'translation_text': 'K OW1 W ER1 K ER0 Z'}, {'translation_text': 'K OW1 W ER1 K ER0 Z'}, {'translation_text': 'HH AH1 N T ER0 Z'}, {'translation_text': 'HH AH1 N T ER0'}]mini-bart-g2p model was trained on a combination of both the Librispeech Alignments dataset and the CMUDict dataset.
The model was trained using the translation training script provided by HuggingFace Transformers repo.
The following parameters were specified in the training script to produce the model.1python run_translation.py \
2--model_name_or_path <MODEL DIR> \
3--source_lang wrd \
4--target_lang phon \
5--num_train_epochs 500 \
6--train_file <TRAIN SPLIT> \
7--validation_file <VAL SPLIT> \
8--test_file <TEST SPLIT> \
9--num_beams 5 \
10--generation_num_beams 5 \
11--max_source_length 128 \
12--max_target_length 128 \
13--overwrite_cache \
14--overwrite_output_dir \
15--do_train \
16--do_eval \
17--do_predict \
18--evaluation_strategy epoch \
19--eval_delay 3 \
20--save_strategy epoch \
21--per_device_train_batch_size 16 \
22--per_device_eval_batch_size 16 \
23--learning_rate 5e-4 \
24--label_smoothing_factor 0.1 \
25--weight_decay 0.00001 \
26--adam_beta1 0.9 \
27--adam_beta2 0.98 \
28--load_best_model_at_end True \
29--predict_with_generate True \
30--generation_max_length 20 \
31--output_dir <OUTPUT DIR> \
32--seed 4664427 \
33--lr_scheduler_type cosine_with_restarts \
34--warmup_steps 120000 \
35--optim adafactor \
36--group_by_length \
37--metric_for_best_model bleu \
38--greater_is_better True \
39--save_total_limit 10 \
40--log_level info \
41--logging_steps 500mini-bart-g2p model is trained to only work on the English language.1text = "world world!"
2pipe(text.split())
3# [{'translation_text': 'W ER1 L D'}, {'translation_text': 'W ER1 L D F'}]
4