├── LICENSE ├── MTLA.py ├── NOTICE ├── README.md ├── assets ├── mtla.png └── variant.py └── experiments ├── speech_recognition ├── README.md ├── cmd.sh ├── espnet.sh ├── infer.sh ├── local │ ├── ami_download.sh │ ├── ami_ihm_data_prep.sh │ ├── ami_ihm_scoring_data_prep.sh │ ├── ami_split_segments.pl │ ├── ami_text_prep.sh │ ├── ami_xml2text.sh │ ├── convert2stm.pl │ ├── data.sh │ ├── generate_vocab.py │ ├── kaldi_to_tsv.py │ ├── split_REAMDE.txt │ ├── split_dev.orig │ ├── split_eval.orig │ ├── split_train.orig │ └── wav2ssl.py ├── path.sh ├── prepare.sh ├── pyscripts ├── scripts ├── train.sh └── utils ├── speech_translation ├── README.md ├── infer.sh ├── prepare.sh └── train.sh ├── spoken_language_understanding ├── README.md ├── cmd.sh ├── espnet.sh ├── infer.sh ├── local │ ├── config.yaml │ ├── data.sh │ ├── kaldi_to_tsv.py │ ├── prepare_slurp_data.py │ └── run_spm.sh ├── path.sh ├── prepare.sh ├── pyscripts ├── scripts ├── train.sh └── utils ├── text_summarisation ├── README.md ├── infer.sh ├── prepare.sh └── train.sh └── tools ├── cmd.sh ├── espnet.sh ├── fairseq ├── .github │ ├── CODEOWNERS │ ├── ISSUE_TEMPLATE.md │ ├── ISSUE_TEMPLATE │ │ ├── bug_report.md │ │ ├── documentation.md │ │ ├── feature_request.md │ │ └── how-to-question.md │ ├── PULL_REQUEST_TEMPLATE.md │ ├── stale.yml │ └── workflows │ │ ├── build.yml │ │ ├── depreview.yml │ │ └── release.yml ├── .gitignore ├── .gitmodules ├── .pre-commit-config.yaml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── MANIFEST.in ├── README.md ├── RELEASE.md ├── docs │ ├── Makefile │ ├── command_line_tools.rst │ ├── conf.py │ ├── criterions.rst │ ├── data.rst │ ├── docutils.conf │ ├── fairseq.gif │ ├── fairseq_logo.png │ ├── getting_started.rst │ ├── hydra_integration.md │ ├── index.rst │ ├── lr_scheduler.rst │ ├── make.bat │ ├── models.rst │ ├── modules.rst │ ├── optim.rst │ ├── overview.rst │ ├── tasks.rst │ ├── tutorial_classifying_names.rst │ └── tutorial_simple_lstm.rst ├── examples │ ├── .gitignore │ ├── MMPT │ │ ├── .gitignore │ │ ├── CONFIG.md │ │ ├── DATASET.md │ │ ├── README.md │ │ ├── endtask.md │ │ ├── locallaunch.py │ │ ├── mmpt │ │ │ ├── __init__.py │ │ │ ├── datasets │ │ │ │ ├── __init__.py │ │ │ │ ├── fairseqmmdataset.py │ │ │ │ └── mmdataset.py │ │ │ ├── evaluators │ │ │ │ ├── __init__.py │ │ │ │ ├── evaluator.py │ │ │ │ ├── metric.py │ │ │ │ └── predictor.py │ │ │ ├── losses │ │ │ │ ├── __init__.py │ │ │ │ ├── fairseqmmloss.py │ │ │ │ ├── loss.py │ │ │ │ └── nce.py │ │ │ ├── models │ │ │ │ ├── __init__.py │ │ │ │ ├── fairseqmmmodel.py │ │ │ │ ├── mmfusion.py │ │ │ │ ├── mmfusionnlg.py │ │ │ │ └── transformermodel.py │ │ │ ├── modules │ │ │ │ ├── __init__.py │ │ │ │ ├── mm.py │ │ │ │ ├── retri.py │ │ │ │ └── vectorpool.py │ │ │ ├── processors │ │ │ │ ├── __init__.py │ │ │ │ ├── dedupprocessor.py │ │ │ │ ├── dsprocessor.py │ │ │ │ ├── how2processor.py │ │ │ │ ├── how2retriprocessor.py │ │ │ │ ├── models │ │ │ │ │ └── s3dg.py │ │ │ │ └── processor.py │ │ │ ├── tasks │ │ │ │ ├── __init__.py │ │ │ │ ├── fairseqmmtask.py │ │ │ │ ├── milncetask.py │ │ │ │ ├── retritask.py │ │ │ │ ├── task.py │ │ │ │ └── vlmtask.py │ │ │ └── utils │ │ │ │ ├── __init__.py │ │ │ │ ├── load_config.py │ │ │ │ └── shardedtensor.py │ │ ├── mmpt_cli │ │ │ ├── localjob.py │ │ │ └── predict.py │ │ ├── pretraining.md │ │ ├── projects │ │ │ ├── mfmmlm.yaml │ │ │ ├── mtm │ │ │ │ ├── mmfusionmtm.yaml │ │ │ │ ├── vlm.yaml │ │ │ │ └── vlm │ │ │ │ │ ├── coin.yaml │ │ │ │ │ ├── crosstask.yaml │ │ │ │ │ ├── how2.yaml │ │ │ │ │ ├── test_coin.yaml │ │ │ │ │ ├── test_crosstask.yaml │ │ │ │ │ ├── test_crosstask_zs.yaml │ │ │ │ │ ├── test_vtt.yaml │ │ │ │ │ ├── test_vttqa.yaml │ │ │ │ │ ├── test_youcook.yaml │ │ │ │ │ ├── test_youcookcap.yaml │ │ │ │ │ ├── vtt.yaml │ │ │ │ │ ├── vttqa.yaml │ │ │ │ │ ├── youcook.yaml │ │ │ │ │ └── youcookcap.yaml │ │ │ ├── retri │ │ │ │ ├── videoclip.yaml │ │ │ │ ├── videoclip │ │ │ │ │ ├── coin_videoclip.yaml │ │ │ │ │ ├── crosstask_videoclip.yaml │ │ │ │ │ ├── how2.yaml │ │ │ │ │ ├── test_coin_videoclip.yaml │ │ │ │ │ ├── test_coin_zs.yaml │ │ │ │ │ ├── test_crosstask_videoclip.yaml │ │ │ │ │ ├── test_crosstask_zs_videoclip.yaml │ │ │ │ │ ├── test_didemo_zs.yaml │ │ │ │ │ ├── test_vtt_videoclip.yaml │ │ │ │ │ ├── test_vtt_zs.yaml │ │ │ │ │ ├── test_vttqa_videoclip.yaml │ │ │ │ │ ├── test_vttqa_zs.yaml │ │ │ │ │ ├── test_youcook_videoclip.yaml │ │ │ │ │ ├── test_youcook_zs.yaml │ │ │ │ │ ├── vtt_videoclip.yaml │ │ │ │ │ ├── vttqa_videoclip.yaml │ │ │ │ │ └── youcook_videoclip.yaml │ │ │ │ └── videoretri.yaml │ │ │ └── task │ │ │ │ ├── coin.yaml │ │ │ │ ├── coin_videoclip.yaml │ │ │ │ ├── crosstask.yaml │ │ │ │ ├── crosstask_videoclip.yaml │ │ │ │ ├── default.yaml │ │ │ │ ├── ft.yaml │ │ │ │ ├── how2.yaml │ │ │ │ ├── test.yaml │ │ │ │ ├── test_coin.yaml │ │ │ │ ├── test_coin_videoclip.yaml │ │ │ │ ├── test_coin_zs.yaml │ │ │ │ ├── test_crosstask.yaml │ │ │ │ ├── test_crosstask_videoclip.yaml │ │ │ │ ├── test_crosstask_zs.yaml │ │ │ │ ├── test_crosstask_zs_videoclip.yaml │ │ │ │ ├── test_didemo_zs.yaml │ │ │ │ ├── test_vtt.yaml │ │ │ │ ├── test_vtt_videoclip.yaml │ │ │ │ ├── test_vtt_zs.yaml │ │ │ │ ├── test_vttqa.yaml │ │ │ │ ├── test_vttqa_videoclip.yaml │ │ │ │ ├── test_vttqa_zs.yaml │ │ │ │ ├── test_youcook.yaml │ │ │ │ ├── test_youcook_videoclip.yaml │ │ │ │ ├── test_youcook_zs.yaml │ │ │ │ ├── test_youcookcap.yaml │ │ │ │ ├── vtt.yaml │ │ │ │ ├── vtt_videoclip.yaml │ │ │ │ ├── vttqa.yaml │ │ │ │ ├── vttqa_videoclip.yaml │ │ │ │ ├── youcook.yaml │ │ │ │ ├── youcook_videoclip.yaml │ │ │ │ └── youcookcap.yaml │ │ ├── scripts │ │ │ ├── text_token_extractor │ │ │ │ ├── configs │ │ │ │ │ └── bert-base-uncased.yaml │ │ │ │ └── pretokenization.py │ │ │ └── video_feature_extractor │ │ │ │ ├── extract.py │ │ │ │ ├── how2 │ │ │ │ └── s3d.sh │ │ │ │ ├── model.py │ │ │ │ ├── pathbuilder.py │ │ │ │ ├── preprocessing.py │ │ │ │ ├── random_sequence_shuffler.py │ │ │ │ ├── shard_feature.py │ │ │ │ └── videoreader.py │ │ ├── setup.py │ │ ├── videoclip.png │ │ └── vlm.png │ ├── __init__.py │ ├── adaptive_span │ │ ├── README.md │ │ ├── __init__.py │ │ ├── adagrad_with_grad_clip.py │ │ ├── adaptive_span_attention.py │ │ ├── adaptive_span_loss.py │ │ ├── adaptive_span_model.py │ │ ├── adaptive_span_model_wrapper.py │ │ └── truncated_bptt_lm_task.py │ ├── attention_head_selection │ │ ├── README.md │ │ └── src │ │ │ ├── __init__.py │ │ │ ├── data │ │ │ ├── __init__.py │ │ │ └── speech_to_text_dataset_with_domain.py │ │ │ ├── loss │ │ │ ├── __init__.py │ │ │ └── attention_head_selection.py │ │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── head_selection_s2t_transformer.py │ │ │ └── head_selection_transformer.py │ │ │ ├── modules │ │ │ ├── __init__.py │ │ │ ├── attn_head_selector.py │ │ │ ├── head_selection_transformer_layer.py │ │ │ ├── multihead_attention_selection.py │ │ │ └── multihead_functional.py │ │ │ └── speech_to_text_head_selection.py │ ├── audio_nlp │ │ └── nlu │ │ │ ├── README.md │ │ │ ├── configs │ │ │ └── nlu_finetuning.yaml │ │ │ ├── create_dict_stop.sh │ │ │ └── generate_manifests.py │ ├── backtranslation │ │ ├── README.md │ │ ├── deduplicate_lines.py │ │ ├── extract_bt_data.py │ │ ├── prepare-de-monolingual.sh │ │ ├── prepare-wmt18en2de.sh │ │ ├── sacrebleu.sh │ │ └── tokenized_bleu.sh │ ├── bart │ │ ├── README.glue.md │ │ ├── README.md │ │ ├── README.summarization.md │ │ └── summarize.py │ ├── byte_level_bpe │ │ ├── README.md │ │ ├── get_bitext.py │ │ ├── get_data.sh │ │ └── gru_transformer.py │ ├── camembert │ │ └── README.md │ ├── constrained_decoding │ │ ├── README.md │ │ ├── normalize.py │ │ └── tok.py │ ├── conv_seq2seq │ │ └── README.md │ ├── criss │ │ ├── README.md │ │ ├── download_and_preprocess_flores_test.sh │ │ ├── download_and_preprocess_tatoeba.sh │ │ ├── mining │ │ │ ├── mine.py │ │ │ └── mine_example.sh │ │ ├── save_encoder.py │ │ ├── sentence_retrieval │ │ │ ├── encoder_analysis.py │ │ │ └── sentence_retrieval_tatoeba.sh │ │ └── unsupervised_mt │ │ │ └── eval.sh │ ├── cross_lingual_language_model │ │ └── README.md │ ├── data2vec │ │ ├── README.md │ │ ├── __init__.py │ │ ├── config │ │ │ ├── audio │ │ │ │ ├── classification │ │ │ │ │ ├── base_classification.yaml │ │ │ │ │ └── run_config │ │ │ │ │ │ ├── slurm_1.yaml │ │ │ │ │ │ ├── slurm_1g.yaml │ │ │ │ │ │ └── slurm_2.yaml │ │ │ │ └── pretraining │ │ │ │ │ ├── audioset.yaml │ │ │ │ │ ├── base_librispeech.yaml │ │ │ │ │ └── run_config │ │ │ │ │ ├── local.yaml │ │ │ │ │ ├── slurm_1.yaml │ │ │ │ │ ├── slurm_1_aws.yaml │ │ │ │ │ ├── slurm_2.yaml │ │ │ │ │ ├── slurm_2_aws.yaml │ │ │ │ │ ├── slurm_3.yaml │ │ │ │ │ ├── slurm_4.yaml │ │ │ │ │ ├── slurm_4_aws.yaml │ │ │ │ │ ├── slurm_6_aws.yaml │ │ │ │ │ └── slurm_8_aws.yaml │ │ │ ├── text │ │ │ │ └── pretraining │ │ │ │ │ ├── base.yaml │ │ │ │ │ └── run_config │ │ │ │ │ ├── local.yaml │ │ │ │ │ ├── slurm_1_aws.yaml │ │ │ │ │ ├── slurm_2.yaml │ │ │ │ │ ├── slurm_2_aws.yaml │ │ │ │ │ ├── slurm_3.yaml │ │ │ │ │ ├── slurm_4.yaml │ │ │ │ │ ├── slurm_4_aws.yaml │ │ │ │ │ └── slurm_8_aws.yaml │ │ │ ├── v2 │ │ │ │ ├── base_audio_only_task.yaml │ │ │ │ ├── base_images_only_task.yaml │ │ │ │ ├── base_text_only_task.yaml │ │ │ │ ├── huge_images14_only_task.yaml │ │ │ │ ├── huge_images_only_task.yaml │ │ │ │ ├── large_audio_only_task.yaml │ │ │ │ ├── large_images_only_task.yaml │ │ │ │ ├── large_text_only_task.yaml │ │ │ │ ├── large_text_only_task_pgrp_1M.yaml │ │ │ │ ├── run_config │ │ │ │ │ ├── local.yaml │ │ │ │ │ ├── slurm_1.yaml │ │ │ │ │ ├── slurm_1_aws.yaml │ │ │ │ │ ├── slurm_2.yaml │ │ │ │ │ ├── slurm_2_aws.yaml │ │ │ │ │ ├── slurm_3.yaml │ │ │ │ │ ├── slurm_4.yaml │ │ │ │ │ ├── slurm_4_aws.yaml │ │ │ │ │ ├── slurm_6_aws.yaml │ │ │ │ │ ├── slurm_8.yaml │ │ │ │ │ └── slurm_8_aws.yaml │ │ │ │ └── text_finetuning │ │ │ │ │ ├── cola.yaml │ │ │ │ │ ├── mnli.yaml │ │ │ │ │ ├── mrpc.yaml │ │ │ │ │ ├── qnli.yaml │ │ │ │ │ ├── qqp.yaml │ │ │ │ │ ├── rte.yaml │ │ │ │ │ ├── run_config │ │ │ │ │ └── local.yaml │ │ │ │ │ ├── sst_2.yaml │ │ │ │ │ └── sts_b.yaml │ │ │ └── vision │ │ │ │ ├── finetuning │ │ │ │ ├── imagenet.yaml │ │ │ │ ├── mae_imagenet_clean.yaml │ │ │ │ ├── mae_imagenet_huge_clean.yaml │ │ │ │ ├── mae_imagenet_large_clean.yaml │ │ │ │ └── run_config │ │ │ │ │ ├── local.yaml │ │ │ │ │ ├── slurm_1.yaml │ │ │ │ │ ├── slurm_1_aws.yaml │ │ │ │ │ ├── slurm_2.yaml │ │ │ │ │ ├── slurm_2_aws.yaml │ │ │ │ │ ├── slurm_3.yaml │ │ │ │ │ ├── slurm_4.yaml │ │ │ │ │ ├── slurm_4_aws.yaml │ │ │ │ │ ├── slurm_6_aws.yaml │ │ │ │ │ └── slurm_8_aws.yaml │ │ │ │ └── pretraining │ │ │ │ ├── base_imagenet.yaml │ │ │ │ ├── base_imagenet_d2v1.yaml │ │ │ │ ├── base_mae_imagenet.yaml │ │ │ │ └── run_config │ │ │ │ ├── local.yaml │ │ │ │ ├── slurm_1.yaml │ │ │ │ ├── slurm_1_aws.yaml │ │ │ │ ├── slurm_2.yaml │ │ │ │ ├── slurm_2_aws.yaml │ │ │ │ ├── slurm_3.yaml │ │ │ │ ├── slurm_4.yaml │ │ │ │ ├── slurm_4_aws.yaml │ │ │ │ ├── slurm_6_aws.yaml │ │ │ │ └── slurm_8_aws.yaml │ │ ├── data │ │ │ ├── __init__.py │ │ │ ├── add_class_target_dataset.py │ │ │ ├── image_dataset.py │ │ │ ├── mae_finetuning_image_dataset.py │ │ │ ├── mae_image_dataset.py │ │ │ ├── modality.py │ │ │ └── path_dataset.py │ │ ├── fb_convert_beit_cp.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── audio_classification.py │ │ │ ├── data2vec2.py │ │ │ ├── data2vec_audio.py │ │ │ ├── data2vec_image_classification.py │ │ │ ├── data2vec_text.py │ │ │ ├── data2vec_text_classification.py │ │ │ ├── data2vec_vision.py │ │ │ ├── mae.py │ │ │ ├── mae_image_classification.py │ │ │ ├── modalities │ │ │ │ ├── __init__.py │ │ │ │ ├── audio.py │ │ │ │ ├── base.py │ │ │ │ ├── images.py │ │ │ │ ├── modules.py │ │ │ │ └── text.py │ │ │ └── utils.py │ │ ├── scripts │ │ │ ├── convert_audioset_labels.py │ │ │ ├── multi │ │ │ │ ├── finetune_all_fair_aws_local_lr.sh │ │ │ │ ├── finetune_all_fair_aws_local_lr_nodep.sh │ │ │ │ └── finetune_all_fair_local_lr.sh │ │ │ └── text │ │ │ │ ├── finetune_all_char_fair_aws_local_lr.sh │ │ │ │ ├── finetune_all_fair.sh │ │ │ │ ├── finetune_all_fair_aws.sh │ │ │ │ ├── finetune_all_fair_aws_local_lr.sh │ │ │ │ ├── finetune_all_fair_aws_lr.sh │ │ │ │ ├── finetune_all_fair_local_lr.sh │ │ │ │ ├── finetune_all_fair_nodep.sh │ │ │ │ ├── finetune_all_fair_nodep_aws.sh │ │ │ │ ├── finetune_all_fair_nodep_aws_local_lr.sh │ │ │ │ ├── finetune_all_fair_nodep_aws_lr.sh │ │ │ │ ├── finetune_all_fair_nodep_aws_lr_nopos.sh │ │ │ │ ├── finetune_all_large_fair_aws_local_lr.sh │ │ │ │ ├── finetune_all_large_fair_local_lr.sh │ │ │ │ ├── finetune_all_large_fair_nodep_aws_local_lr.sh │ │ │ │ ├── finetune_sst2_qnli_sweep_fair_nodep.sh │ │ │ │ ├── glue.py │ │ │ │ ├── glue_lr.py │ │ │ │ ├── unprocess_data.py │ │ │ │ └── valids.py │ │ └── tasks │ │ │ ├── __init__.py │ │ │ ├── audio_classification.py │ │ │ ├── image_classification.py │ │ │ ├── image_pretraining.py │ │ │ ├── mae_image_classification.py │ │ │ ├── mae_image_pretraining.py │ │ │ └── multimodal.py │ ├── discriminative_reranking_nmt │ │ ├── README.md │ │ ├── __init__.py │ │ ├── config │ │ │ └── deen.yaml │ │ ├── criterions │ │ │ ├── __init__.py │ │ │ └── discriminative_reranking_criterion.py │ │ ├── drnmt_rerank.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ └── discriminative_reranking_model.py │ │ ├── scripts │ │ │ └── prep_data.py │ │ └── tasks │ │ │ ├── __init__.py │ │ │ └── discriminative_reranking_task.py │ ├── emotion_conversion │ │ ├── README.md │ │ ├── emotion_models │ │ │ ├── __init__.py │ │ │ ├── duration_predictor.py │ │ │ ├── duration_predictor.yaml │ │ │ ├── pitch_predictor.py │ │ │ ├── pitch_predictor.yaml │ │ │ └── utils.py │ │ ├── fairseq_models │ │ │ └── __init__.py │ │ ├── preprocess │ │ │ ├── __init__.py │ │ │ ├── build_hifigan_manifest.py │ │ │ ├── build_translation_manifests.py │ │ │ ├── create_core_manifest.py │ │ │ ├── extract_f0.py │ │ │ ├── process_km.py │ │ │ ├── split_emov_km_tsv_by_uttid.py │ │ │ ├── split_km.py │ │ │ └── split_km_tsv.py │ │ ├── requirements.txt │ │ └── synthesize.py │ ├── fast_noisy_channel │ │ ├── README.md │ │ ├── __init__.py │ │ ├── noisy_channel_beam_search.py │ │ ├── noisy_channel_sequence_generator.py │ │ └── noisy_channel_translation.py │ ├── flores101 │ │ ├── README.md │ │ └── flores_logo.png │ ├── fully_sharded_data_parallel │ │ └── README.md │ ├── gottbert │ │ └── README.md │ ├── hubert │ │ ├── README.md │ │ ├── config │ │ │ ├── decode │ │ │ │ ├── ax_sweep │ │ │ │ │ ├── ngram.yaml │ │ │ │ │ └── transformer.yaml │ │ │ │ ├── infer_fsqlm.yaml │ │ │ │ ├── infer_kenlm.yaml │ │ │ │ ├── infer_viterbi.yaml │ │ │ │ └── run │ │ │ │ │ ├── submitit_slurm.yaml │ │ │ │ │ └── submitit_slurm_8gpu.yaml │ │ │ ├── finetune │ │ │ │ ├── base_10h.yaml │ │ │ │ ├── ckpt │ │ │ │ │ └── it1.yaml │ │ │ │ ├── lm │ │ │ │ │ └── ls_4gram.yaml │ │ │ │ └── run │ │ │ │ │ └── submitit_reg.yaml │ │ │ └── pretrain │ │ │ │ ├── data │ │ │ │ ├── iter1.yaml │ │ │ │ └── iter2.yaml │ │ │ │ ├── hubert_base_librispeech.yaml │ │ │ │ ├── hubert_large_librivox.yaml │ │ │ │ ├── hubert_xlarge_librivox.yaml │ │ │ │ └── run │ │ │ │ └── submitit_reg.yaml │ │ ├── measure_teacher_quality.py │ │ ├── simple_kmeans │ │ │ ├── README.md │ │ │ ├── dump_hubert_feature.py │ │ │ ├── dump_hubert_feature_s2t.py │ │ │ ├── dump_km_label.py │ │ │ ├── dump_mfcc_feature.py │ │ │ ├── dump_w2v2_feature.py │ │ │ ├── feature_utils.py │ │ │ └── learn_kmeans.py │ │ ├── tests │ │ │ ├── 6313-76958-0021.flac │ │ │ ├── sample.base.L9.km500.km │ │ │ ├── sample.base.L9.len │ │ │ ├── sample.base.L9.npy │ │ │ ├── sample.large.L20.len │ │ │ ├── sample.large.L20.npy │ │ │ ├── sample.large.hypo.word │ │ │ ├── sample.xlarge.L30.len │ │ │ ├── sample.xlarge.L30.npy │ │ │ ├── sample.xlarge.hypo.word │ │ │ ├── test_feature_and_unit.sh │ │ │ └── test_finetuned_asr.sh │ │ └── update_ckpt.py │ ├── joint_alignment_translation │ │ ├── README.md │ │ └── prepare-wmt18en2de_no_norm_no_escape_no_agressive.sh │ ├── language_model │ │ ├── README.adaptive_inputs.md │ │ ├── README.conv.md │ │ ├── README.md │ │ └── prepare-wikitext-103.sh │ ├── laser │ │ ├── README.md │ │ └── laser_src │ │ │ ├── __init__.py │ │ │ ├── laser_lstm.py │ │ │ ├── laser_task.py │ │ │ ├── laser_transformer.py │ │ │ └── multitask_data_utils.py │ ├── latent_depth │ │ ├── README.md │ │ └── latent_depth_src │ │ │ ├── __init__.py │ │ │ ├── loss │ │ │ ├── __init__.py │ │ │ └── latent_depth.py │ │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── latent_multilingual_transformer.py │ │ │ └── latent_transformer.py │ │ │ ├── modules │ │ │ ├── __init__.py │ │ │ └── latent_layers.py │ │ │ └── multilingual_translation_latent_depth.py │ ├── layerdrop │ │ └── README.md │ ├── linformer │ │ ├── README.md │ │ └── linformer_src │ │ │ ├── __init__.py │ │ │ ├── models │ │ │ ├── __init__.py │ │ │ └── linformer_roberta.py │ │ │ └── modules │ │ │ ├── __init__.py │ │ │ ├── linformer_sentence_encoder.py │ │ │ ├── linformer_sentence_encoder_layer.py │ │ │ └── multihead_linear_attention.py │ ├── m2m_100 │ │ ├── README.md │ │ ├── install_dependecies.sh │ │ ├── process_data │ │ │ ├── clean_histogram.py │ │ │ ├── dedup_data.py │ │ │ └── remove_too_much_punc.py │ │ ├── tok.sh │ │ └── tokenizers │ │ │ ├── README.md │ │ │ ├── seg_ja.sh │ │ │ ├── seg_ko.sh │ │ │ ├── thirdparty │ │ │ └── .gitignore │ │ │ ├── tokenize_indic.py │ │ │ ├── tokenize_thai.py │ │ │ ├── tokenize_zh.py │ │ │ └── tokenizer_ar.sh │ ├── mbart │ │ └── README.md │ ├── megatron_11b │ │ ├── README.md │ │ └── detok.py │ ├── mms │ │ ├── MODEL_CARD.md │ │ ├── README.md │ │ ├── asr │ │ │ ├── config │ │ │ │ └── infer_common.yaml │ │ │ ├── infer │ │ │ │ ├── example_infer_adapter.sh │ │ │ │ └── mms_infer.py │ │ │ └── tutorial │ │ │ │ └── MMS_ASR_Inference_Colab.ipynb │ │ ├── data_prep │ │ │ ├── README.md │ │ │ ├── align_and_segment.py │ │ │ ├── align_utils.py │ │ │ ├── norm_config.py │ │ │ ├── punctuations.lst │ │ │ └── text_normalization.py │ │ ├── lid │ │ │ ├── infer.py │ │ │ └── tutorial │ │ │ │ └── MMS_LID_Inference_Colab.ipynb │ │ ├── lid_rerank │ │ │ ├── README.md │ │ │ ├── cer_langs.txt │ │ │ ├── mala │ │ │ │ └── infer.py │ │ │ ├── mms-zs │ │ │ │ ├── falign.py │ │ │ │ ├── lib.py │ │ │ │ └── uromanize.py │ │ │ ├── mms │ │ │ │ ├── make_parallel_single_runs.py │ │ │ │ ├── merge_by_lang.py │ │ │ │ ├── prep_wav_list.py │ │ │ │ ├── run_single_lang.py │ │ │ │ └── split_by_lang.py │ │ │ ├── nllb │ │ │ │ └── infer.py │ │ │ ├── requirements.txt │ │ │ ├── rerank │ │ │ │ ├── rerank.py │ │ │ │ └── tune_coefficients.py │ │ │ └── whisper │ │ │ │ ├── infer_asr.py │ │ │ │ ├── infer_lid.py │ │ │ │ └── lid_mapping.txt │ │ ├── misc │ │ │ └── get_sample_size.py │ │ ├── tts │ │ │ ├── infer.py │ │ │ └── tutorial │ │ │ │ └── MMS_TTS_Inference_Colab.ipynb │ │ └── zero_shot │ │ │ └── README.md │ ├── moe_lm │ │ ├── README.md │ │ ├── data_card.md │ │ └── model_card.md │ ├── mr_hubert │ │ ├── README.md │ │ ├── config │ │ │ ├── decode │ │ │ │ ├── infer.yaml │ │ │ │ ├── infer_lm.yaml │ │ │ │ └── run │ │ │ │ │ ├── submitit_slurm.yaml │ │ │ │ │ └── submitit_slurm_8gpu.yaml │ │ │ ├── finetune │ │ │ │ ├── base_100h.yaml │ │ │ │ ├── base_100h_large.yaml │ │ │ │ ├── base_10h.yaml │ │ │ │ ├── base_10h_large.yaml │ │ │ │ ├── base_1h.yaml │ │ │ │ └── base_1h_large.yaml │ │ │ └── pretrain │ │ │ │ ├── mrhubert_base_librispeech.yaml │ │ │ │ ├── mrhubert_large_librilight.yaml │ │ │ │ └── run │ │ │ │ └── submitit_reg.yaml │ │ ├── decode.sh │ │ ├── finetune.sh │ │ ├── simple_kmeans │ │ └── train.sh │ ├── multilingual │ │ ├── ML50_langs.txt │ │ ├── README.md │ │ ├── data_scripts │ │ │ ├── README.md │ │ │ ├── binarize.py │ │ │ ├── check_iswlt_test_data.py │ │ │ ├── check_self_overlaps.py │ │ │ ├── check_valid_test_overlaps.py │ │ │ ├── dedup_all.py │ │ │ ├── download_ML50_v1.sh │ │ │ ├── download_af_xh.sh │ │ │ ├── download_flores_data.sh │ │ │ ├── download_iitb.sh │ │ │ ├── download_iwslt_and_extract.sh │ │ │ ├── download_lotus.sh │ │ │ ├── download_ted_and_extract.py │ │ │ ├── download_wat19_my.sh │ │ │ ├── download_wmt19_and_before.py │ │ │ ├── download_wmt20.sh │ │ │ ├── preprocess_ML50_v1.sh │ │ │ ├── remove_valid_test_in_train.py │ │ │ ├── requirement.txt │ │ │ └── utils │ │ │ │ ├── dedup.py │ │ │ │ ├── fasttext_multi_filter.py │ │ │ │ └── strip_sgm.sh │ │ ├── finetune_multilingual_model.sh │ │ ├── multilingual_fairseq_gen.sh │ │ └── train_multilingual_model.sh │ ├── noisychannel │ │ ├── README.md │ │ ├── __init__.py │ │ ├── rerank.py │ │ ├── rerank_generate.py │ │ ├── rerank_options.py │ │ ├── rerank_score_bw.py │ │ ├── rerank_score_lm.py │ │ ├── rerank_tune.py │ │ └── rerank_utils.py │ ├── nonautoregressive_translation │ │ ├── README.md │ │ └── scripts.md │ ├── normformer │ │ ├── README.md │ │ └── train_lm.sh │ ├── operators │ │ ├── alignment_train_cpu.cpp │ │ ├── alignment_train_cuda.cpp │ │ ├── alignment_train_cuda.h │ │ ├── alignment_train_kernel.cu │ │ └── utils.h │ ├── paraphraser │ │ ├── README.md │ │ └── paraphrase.py │ ├── pay_less_attention_paper │ │ └── README.md │ ├── pointer_generator │ │ ├── README.md │ │ ├── README.xsum.md │ │ ├── pointer_generator_src │ │ │ ├── __init__.py │ │ │ └── transformer_pg.py │ │ ├── postprocess.py │ │ └── preprocess.py │ ├── quant_noise │ │ ├── README.md │ │ └── transformer_quantization_config.yaml │ ├── roberta │ │ ├── README.custom_classification.md │ │ ├── README.glue.md │ │ ├── README.md │ │ ├── README.pretraining.md │ │ ├── README.race.md │ │ ├── commonsense_qa │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── commonsense_qa_task.py │ │ │ └── download_cqa_data.sh │ │ ├── config │ │ │ ├── finetuning │ │ │ │ ├── cola.yaml │ │ │ │ ├── mnli.yaml │ │ │ │ ├── mrpc.yaml │ │ │ │ ├── qnli.yaml │ │ │ │ ├── qqp.yaml │ │ │ │ ├── rte.yaml │ │ │ │ ├── run_config │ │ │ │ │ ├── local.yaml │ │ │ │ │ ├── slurm_1g.yaml │ │ │ │ │ └── slurm_1g_aws.yaml │ │ │ │ ├── sst_2.yaml │ │ │ │ └── sts_b.yaml │ │ │ └── pretraining │ │ │ │ ├── base.yaml │ │ │ │ └── run_config │ │ │ │ ├── local.yaml │ │ │ │ ├── slurm_2.yaml │ │ │ │ ├── slurm_2_aws.yaml │ │ │ │ ├── slurm_3.yaml │ │ │ │ └── slurm_4.yaml │ │ ├── fb_multilingual │ │ │ └── README.multilingual.pretraining.md │ │ ├── multiprocessing_bpe_encoder.py │ │ ├── preprocess_GLUE_tasks.sh │ │ ├── preprocess_RACE.py │ │ ├── preprocess_RACE.sh │ │ └── wsc │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── wsc_criterion.py │ │ │ ├── wsc_task.py │ │ │ └── wsc_utils.py │ ├── rxf │ │ ├── README.md │ │ ├── __init__.py │ │ └── rxf_src │ │ │ ├── __init__.py │ │ │ ├── label_smoothed_cross_entropy_r3f.py │ │ │ └── sentence_prediction_r3f.py │ ├── scaling_nmt │ │ └── README.md │ ├── shuffled_word_order │ │ ├── README.finetuning.md │ │ └── README.md │ ├── simultaneous_translation │ │ ├── README.md │ │ ├── __init__.py │ │ ├── docs │ │ │ ├── ende-mma.md │ │ │ └── enja-waitk.md │ │ ├── eval │ │ │ └── agents │ │ │ │ └── simul_t2t_enja.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── convtransformer_simul_trans.py │ │ │ └── transformer_monotonic_attention.py │ │ ├── modules │ │ │ ├── __init__.py │ │ │ ├── fixed_pre_decision.py │ │ │ ├── monotonic_multihead_attention.py │ │ │ └── monotonic_transformer_layer.py │ │ ├── tests │ │ │ ├── test_alignment_train.py │ │ │ └── test_text_models.py │ │ └── utils │ │ │ ├── __init__.py │ │ │ ├── functions.py │ │ │ ├── monotonic_attention.py │ │ │ └── p_choose_strategy.py │ ├── speech_recognition │ │ ├── README.md │ │ ├── __init__.py │ │ ├── criterions │ │ │ ├── ASG_loss.py │ │ │ ├── __init__.py │ │ │ └── cross_entropy_acc.py │ │ ├── data │ │ │ ├── __init__.py │ │ │ ├── asr_dataset.py │ │ │ ├── collaters.py │ │ │ ├── data_utils.py │ │ │ └── replabels.py │ │ ├── datasets │ │ │ ├── asr_prep_json.py │ │ │ └── prepare-librispeech.sh │ │ ├── infer.py │ │ ├── kaldi │ │ │ ├── __init__.py │ │ │ ├── add-self-loop-simple.cc │ │ │ ├── config │ │ │ │ └── kaldi_initializer.yaml │ │ │ ├── kaldi_decoder.py │ │ │ └── kaldi_initializer.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── vggtransformer.py │ │ │ └── w2l_conv_glu_enc.py │ │ ├── new │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── conf │ │ │ │ ├── hydra │ │ │ │ │ └── sweeper │ │ │ │ │ │ ├── ax.yaml │ │ │ │ │ │ └── ax_sil.yaml │ │ │ │ ├── infer.yaml │ │ │ │ └── run_config │ │ │ │ │ ├── fb_slurm_1.yaml │ │ │ │ │ └── fb_slurm_2g.yaml │ │ │ ├── decoders │ │ │ │ ├── __init__.py │ │ │ │ ├── base_decoder.py │ │ │ │ ├── decoder.py │ │ │ │ ├── decoder_config.py │ │ │ │ ├── flashlight_decoder.py │ │ │ │ └── viterbi_decoder.py │ │ │ └── infer.py │ │ ├── tasks │ │ │ ├── __init__.py │ │ │ └── speech_recognition.py │ │ ├── utils │ │ │ └── wer_utils.py │ │ └── w2l_decoder.py │ ├── speech_synthesis │ │ ├── README.md │ │ ├── __init__.py │ │ ├── data_utils.py │ │ ├── docs │ │ │ ├── common_voice_example.md │ │ │ ├── ljspeech_example.md │ │ │ └── vctk_example.md │ │ ├── evaluation │ │ │ ├── __init__.py │ │ │ ├── eval_asr.py │ │ │ ├── eval_f0.py │ │ │ ├── eval_sp.py │ │ │ └── get_eval_manifest.py │ │ ├── generate_waveform.py │ │ ├── preprocessing │ │ │ ├── __init__.py │ │ │ ├── denoise_and_vad_audio.py │ │ │ ├── denoiser │ │ │ │ ├── __init__.py │ │ │ │ ├── demucs.py │ │ │ │ ├── pretrained.py │ │ │ │ ├── resample.py │ │ │ │ └── utils.py │ │ │ ├── get_common_voice_audio_manifest.py │ │ │ ├── get_feature_manifest.py │ │ │ ├── get_ljspeech_audio_manifest.py │ │ │ ├── get_speaker_embedding.py │ │ │ ├── get_vctk_audio_manifest.py │ │ │ ├── speaker_embedder │ │ │ │ └── __init__.py │ │ │ └── vad │ │ │ │ └── __init__.py │ │ └── utils.py │ ├── speech_text_joint_to_text │ │ ├── README.md │ │ ├── __init__.py │ │ ├── configs │ │ │ └── mustc_noise.list │ │ ├── criterions │ │ │ ├── __init__.py │ │ │ ├── multi_modality_compound.py │ │ │ ├── multi_modality_cross_entropy.py │ │ │ └── text_guide_cross_entropy_acc.py │ │ ├── data │ │ │ └── pair_denoising_dataset.py │ │ ├── docs │ │ │ ├── ende-mustc.md │ │ │ ├── iwslt2021.md │ │ │ └── pre-training.md │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── joint_speech_text_pretrain_transformer.py │ │ │ ├── s2t_dualinputtransformer.py │ │ │ ├── s2t_dualinputwavtransformer.py │ │ │ └── s2t_dualinputxmtransformer.py │ │ ├── scripts │ │ │ ├── convert_model.py │ │ │ └── g2p_encode.py │ │ └── tasks │ │ │ ├── __init__.py │ │ │ ├── pair_denoising.py │ │ │ ├── speech_text_denoise_pretrain.py │ │ │ └── speech_text_joint.py │ ├── speech_to_speech │ │ ├── README.md │ │ ├── __init__.py │ │ ├── asr_bleu │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── asr_model_cfgs.json │ │ │ ├── compute_asr_bleu.py │ │ │ ├── requirements.txt │ │ │ └── utils.py │ │ ├── benchmarking │ │ │ ├── README.md │ │ │ ├── configs │ │ │ │ ├── 2StageS2ST.yaml │ │ │ │ ├── 3StageS2ST.yaml │ │ │ │ ├── DirectS2U.yaml │ │ │ │ └── S2T.yaml │ │ │ ├── core.py │ │ │ ├── data_utils.py │ │ │ └── get_metrics.py │ │ ├── docs │ │ │ ├── data_augmentation.md │ │ │ ├── direct_s2st_discrete_units.md │ │ │ ├── enhanced_direct_s2st_discrete_units.md │ │ │ └── textless_s2st_real_data.md │ │ ├── generate_waveform_from_code.py │ │ ├── preprocessing │ │ │ ├── __init__.py │ │ │ ├── data_utils.py │ │ │ ├── prep_s2spect_data.py │ │ │ ├── prep_s2ut_data.py │ │ │ ├── prep_sn_data.py │ │ │ └── prep_sn_output_data.py │ │ └── unity │ │ │ ├── __init__.py │ │ │ ├── sequence_generator.py │ │ │ └── sequence_generator_multi_decoder.py │ ├── speech_to_text │ │ ├── README.md │ │ ├── data_utils.py │ │ ├── docs │ │ │ ├── covost_example.md │ │ │ ├── librispeech_example.md │ │ │ ├── mtedx_example.md │ │ │ ├── mustc_example.md │ │ │ └── simulst_mustc_example.md │ │ ├── prep_covost_data.py │ │ ├── prep_librispeech_data.py │ │ ├── prep_mtedx_data.py │ │ ├── prep_mustc_data.py │ │ ├── seg_mustc_data.py │ │ └── simultaneous_translation │ │ │ └── agents │ │ │ └── fairseq_simul_st_agent.py │ ├── stories │ │ └── README.md │ ├── textless_nlp │ │ ├── dgslm │ │ │ ├── README.md │ │ │ ├── create_code_file.py │ │ │ ├── dgslm_utils.py │ │ │ ├── hubert_fisher │ │ │ │ └── README.md │ │ │ ├── sample_speech_dlm.py │ │ │ └── vocoder_hifigan │ │ │ │ ├── README.md │ │ │ │ └── generate_stereo_waveform.py │ │ ├── gslm │ │ │ ├── README.md │ │ │ ├── metrics │ │ │ │ ├── README.md │ │ │ │ ├── abx_metrics │ │ │ │ │ ├── README.md │ │ │ │ │ └── dump_abx_feats.py │ │ │ │ └── asr_metrics │ │ │ │ │ ├── README.md │ │ │ │ │ ├── continuation_eval.py │ │ │ │ │ ├── misc │ │ │ │ │ ├── bleu_utils.py │ │ │ │ │ ├── cut_as.py │ │ │ │ │ └── dict.ltr.txt │ │ │ │ │ ├── ppx.py │ │ │ │ │ └── self_auto_bleu.py │ │ │ ├── speech2unit │ │ │ │ ├── README.md │ │ │ │ ├── __init__.py │ │ │ │ ├── clustering │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── cluster_kmeans.py │ │ │ │ │ ├── dump_feats.py │ │ │ │ │ ├── quantize_with_kmeans.py │ │ │ │ │ └── utils.py │ │ │ │ └── pretrained │ │ │ │ │ ├── cpc_feature_reader.py │ │ │ │ │ ├── hubert_feature_reader.py │ │ │ │ │ ├── logmel_feature_reader.py │ │ │ │ │ ├── utils.py │ │ │ │ │ └── w2v2_feature_reader.py │ │ │ ├── tools │ │ │ │ ├── README.md │ │ │ │ └── resynthesize_speech.py │ │ │ ├── ulm │ │ │ │ ├── README.md │ │ │ │ └── sample.py │ │ │ └── unit2speech │ │ │ │ ├── README.md │ │ │ │ ├── convert_to_16k.py │ │ │ │ ├── glow.py │ │ │ │ ├── multiproc.py │ │ │ │ ├── synthesize_audio_from_units.py │ │ │ │ ├── tacotron2 │ │ │ │ ├── __init__.py │ │ │ │ ├── audio_processing.py │ │ │ │ ├── cleaners.py │ │ │ │ ├── cmudict.py │ │ │ │ ├── layers.py │ │ │ │ ├── model.py │ │ │ │ ├── numbers.py │ │ │ │ ├── stft.py │ │ │ │ ├── symbols.py │ │ │ │ ├── text.py │ │ │ │ ├── utils.py │ │ │ │ └── waveglow_denoiser.py │ │ │ │ ├── tts_data.py │ │ │ │ └── utils.py │ │ ├── pgslm │ │ │ ├── README.md │ │ │ ├── data_utils.py │ │ │ ├── eval │ │ │ │ ├── __init__.py │ │ │ │ └── cont_metrics.py │ │ │ ├── generate_waveform.py │ │ │ ├── inference_dataset.py │ │ │ ├── naive_decoder.py │ │ │ ├── prepare_dataset.py │ │ │ ├── preprocess_f0.py │ │ │ ├── quantize_f0.py │ │ │ ├── sample │ │ │ │ ├── __init__.py │ │ │ │ └── sample.py │ │ │ ├── scripts │ │ │ │ ├── join_units_manifest.py │ │ │ │ ├── prepare_data.sh │ │ │ │ └── prepare_f0_quantization.sh │ │ │ └── truncated_laplace.py │ │ └── speech-resynth │ │ │ ├── README.md │ │ │ └── img │ │ │ └── fig.png │ ├── translation │ │ ├── README.md │ │ ├── prepare-iwslt14.sh │ │ ├── prepare-iwslt17-multilingual.sh │ │ ├── prepare-wmt14en2de.sh │ │ └── prepare-wmt14en2fr.sh │ ├── translation_moe │ │ ├── README.md │ │ ├── score.py │ │ └── translation_moe_src │ │ │ ├── __init__.py │ │ │ ├── logsumexp_moe.py │ │ │ ├── mean_pool_gating_network.py │ │ │ └── translation_moe.py │ ├── truncated_bptt │ │ ├── README.md │ │ ├── __init__.py │ │ ├── transformer_xl_model.py │ │ └── truncated_bptt_lm_task.py │ ├── unsupervised_quality_estimation │ │ ├── README.md │ │ ├── aggregate_scores.py │ │ ├── meteor.py │ │ └── repeat_lines.py │ ├── wav2vec │ │ ├── README.md │ │ ├── __init__.py │ │ ├── config │ │ │ ├── finetuning │ │ │ │ ├── base_100h.yaml │ │ │ │ ├── base_10h.yaml │ │ │ │ ├── base_10m.yaml │ │ │ │ ├── base_1h.yaml │ │ │ │ ├── base_960h.yaml │ │ │ │ ├── run_config │ │ │ │ │ ├── slurm_1.yaml │ │ │ │ │ ├── slurm_16.yaml │ │ │ │ │ ├── slurm_1_aws.yaml │ │ │ │ │ ├── slurm_1_old.yaml │ │ │ │ │ ├── slurm_2.yaml │ │ │ │ │ ├── slurm_2_aws.yaml │ │ │ │ │ ├── slurm_2g.yaml │ │ │ │ │ ├── slurm_3.yaml │ │ │ │ │ ├── slurm_4g.yaml │ │ │ │ │ ├── slurm_4g_aws.yaml │ │ │ │ │ └── slurm_8.yaml │ │ │ │ ├── vox_100h.yaml │ │ │ │ ├── vox_100h_2.yaml │ │ │ │ ├── vox_100h_2_aws.yaml │ │ │ │ ├── vox_100h_3.yaml │ │ │ │ ├── vox_10h.yaml │ │ │ │ ├── vox_10h_2.yaml │ │ │ │ ├── vox_10h_2_aws.yaml │ │ │ │ ├── vox_10h_aws.yaml │ │ │ │ ├── vox_10h_aws_v100.yaml │ │ │ │ ├── vox_10m.yaml │ │ │ │ ├── vox_10m_2.yaml │ │ │ │ ├── vox_10m_2_aws.yaml │ │ │ │ ├── vox_10m_3.yaml │ │ │ │ ├── vox_1h.yaml │ │ │ │ ├── vox_1h_2.yaml │ │ │ │ ├── vox_1h_2_aws.yaml │ │ │ │ ├── vox_1h_3.yaml │ │ │ │ ├── vox_1h_4.yaml │ │ │ │ ├── vox_1h_aws.yaml │ │ │ │ ├── vox_960h.yaml │ │ │ │ ├── vox_960h_2.yaml │ │ │ │ ├── vox_960h_2_aws.yaml │ │ │ │ └── vox_960h_3.yaml │ │ │ └── pretraining │ │ │ │ ├── wav2vec2_base_librispeech.yaml │ │ │ │ ├── wav2vec2_conformer_base_librispeech.yaml │ │ │ │ ├── wav2vec2_conformer_large_librivox.yaml │ │ │ │ ├── wav2vec2_large_librivox.yaml │ │ │ │ ├── wav2vec2_large_librivox_tpu-pod.yaml │ │ │ │ └── wav2vec2_large_librivox_tpu.yaml │ │ ├── libri_labels.py │ │ ├── scripts │ │ │ └── binarize_manifest.sh │ │ ├── unsupervised │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── config │ │ │ │ ├── finetuning │ │ │ │ │ └── w2v_finetune.yaml │ │ │ │ ├── gan │ │ │ │ │ ├── w2vu.yaml │ │ │ │ │ └── w2vu2.yaml │ │ │ │ ├── generate │ │ │ │ │ └── viterbi.yaml │ │ │ │ ├── timit_matched │ │ │ │ │ ├── test.uid │ │ │ │ │ ├── train.uid │ │ │ │ │ ├── train_text.uid │ │ │ │ │ └── valid.uid │ │ │ │ └── timit_unmatched │ │ │ │ │ ├── test.uid │ │ │ │ │ ├── train.uid │ │ │ │ │ ├── train_text.uid │ │ │ │ │ └── valid.uid │ │ │ ├── data │ │ │ │ ├── __init__.py │ │ │ │ ├── extracted_features_dataset.py │ │ │ │ └── random_input_dataset.py │ │ │ ├── kaldi_self_train │ │ │ │ ├── README.md │ │ │ │ └── st │ │ │ │ │ ├── cmd.sh │ │ │ │ │ ├── decode_phone.sh │ │ │ │ │ ├── decode_word_step1.sh │ │ │ │ │ ├── decode_word_step2.sh │ │ │ │ │ ├── local │ │ │ │ │ ├── copy_aligned_text.py │ │ │ │ │ ├── decode.sh │ │ │ │ │ ├── prepare_data_from_w2v.py │ │ │ │ │ ├── prepare_lang.sh │ │ │ │ │ ├── prepare_lang_word.sh │ │ │ │ │ ├── prepare_lm.sh │ │ │ │ │ ├── score.sh │ │ │ │ │ ├── show_wer.sh │ │ │ │ │ ├── train_subset_lgbeam.sh │ │ │ │ │ ├── unsup_select.py │ │ │ │ │ ├── unsup_select_decode.sh │ │ │ │ │ └── unsup_select_decode_word.sh │ │ │ │ │ ├── path.sh │ │ │ │ │ ├── steps │ │ │ │ │ ├── steps_gan │ │ │ │ │ ├── train_deltas.sh │ │ │ │ │ ├── train_lda_mllt.sh │ │ │ │ │ └── train_sat.sh │ │ │ │ │ ├── train.sh │ │ │ │ │ └── utils │ │ │ ├── models │ │ │ │ ├── __init__.py │ │ │ │ └── wav2vec_u.py │ │ │ ├── scripts │ │ │ │ ├── apply_pca.py │ │ │ │ ├── copy_labels.py │ │ │ │ ├── filter_lexicon.py │ │ │ │ ├── filter_tsv.py │ │ │ │ ├── g2p_wrd_to_phn.py │ │ │ │ ├── ltr_to_wrd.py │ │ │ │ ├── mean_pool.py │ │ │ │ ├── merge_clusters.py │ │ │ │ ├── normalize_and_filter_text.py │ │ │ │ ├── normalize_text.py │ │ │ │ ├── pca.py │ │ │ │ ├── phonemize_with_sil.py │ │ │ │ ├── prepare_audio.sh │ │ │ │ ├── prepare_audio_v2.sh │ │ │ │ ├── prepare_text.sh │ │ │ │ ├── prepare_timit.sh │ │ │ │ ├── remove_silence.py │ │ │ │ ├── vads.py │ │ │ │ ├── wav2vec_apply_cluster_faiss.py │ │ │ │ ├── wav2vec_cluster_faiss.py │ │ │ │ ├── wav2vec_extract_features.py │ │ │ │ ├── wer.py │ │ │ │ └── wrd_to_ltr.py │ │ │ ├── tasks │ │ │ │ ├── __init__.py │ │ │ │ └── unpaired_audio_text.py │ │ │ └── w2vu_generate.py │ │ ├── vq-wav2vec_featurize.py │ │ ├── wav2vec_featurize.py │ │ ├── wav2vec_manifest.py │ │ └── xlsr │ │ │ ├── README.md │ │ │ ├── config │ │ │ └── finetune.yaml │ │ │ └── scripts │ │ │ ├── eval_speaker_clf_task.py │ │ │ └── gen_audio_embedding.py │ ├── wmt19 │ │ └── README.md │ ├── wmt20 │ │ └── README.md │ ├── wmt21 │ │ ├── README.md │ │ ├── eval.sh │ │ └── scripts │ │ │ ├── normalize-punctuation.perl │ │ │ └── replace-unicode-punctuation.perl │ ├── womens_bios │ │ ├── README.md │ │ └── query_occupations_from_wikidata.py │ ├── xformers │ │ └── README.md │ ├── xglm │ │ ├── README.md │ │ ├── XStoryCloze.md │ │ └── model_card.md │ ├── xlmr │ │ └── README.md │ └── xmod │ │ ├── README.md │ │ └── preprocess_nli.py ├── fairseq │ ├── __init__.py │ ├── benchmark │ │ ├── __init__.py │ │ ├── benchmark_multihead_attention.py │ │ ├── dummy_dataset.py │ │ ├── dummy_lm.py │ │ ├── dummy_masked_lm.py │ │ ├── dummy_model.py │ │ └── dummy_mt.py │ ├── binarizer.py │ ├── checkpoint_utils.py │ ├── clib │ │ ├── cuda │ │ │ ├── ngram_repeat_block_cuda.cpp │ │ │ └── ngram_repeat_block_cuda_kernel.cu │ │ ├── libbase │ │ │ └── balanced_assignment.cpp │ │ ├── libbleu │ │ │ ├── libbleu.cpp │ │ │ └── module.cpp │ │ ├── libnat │ │ │ └── edit_dist.cpp │ │ └── libnat_cuda │ │ │ ├── binding.cpp │ │ │ ├── edit_dist.cu │ │ │ └── edit_dist.h │ ├── config │ │ ├── __init__.py │ │ ├── config.yaml │ │ ├── fb_run_config │ │ │ └── slurm.yaml │ │ └── model │ │ │ ├── transformer_lm │ │ │ ├── transformer_lm_baevski_gbw.yaml │ │ │ ├── transformer_lm_baevski_wiki103.yaml │ │ │ ├── transformer_lm_big.yaml │ │ │ ├── transformer_lm_gbw.yaml │ │ │ ├── transformer_lm_gpt.yaml │ │ │ ├── transformer_lm_gpt2_big.yaml │ │ │ ├── transformer_lm_gpt2_medium.yaml │ │ │ ├── transformer_lm_gpt2_small.yaml │ │ │ └── transformer_lm_wiki103.yaml │ │ │ ├── wav2vec │ │ │ └── vq_wav2vec_gumbel.yaml │ │ │ └── wav2vec2 │ │ │ ├── wav2vec2_base.yaml │ │ │ └── wav2vec2_large.yaml │ ├── criterions │ │ ├── __init__.py │ │ ├── adaptive_loss.py │ │ ├── composite_loss.py │ │ ├── cross_entropy.py │ │ ├── ctc.py │ │ ├── fairseq_criterion.py │ │ ├── fastspeech2_loss.py │ │ ├── hubert_criterion.py │ │ ├── label_smoothed_cross_entropy.py │ │ ├── label_smoothed_cross_entropy_latency_augmented.py │ │ ├── label_smoothed_cross_entropy_with_alignment.py │ │ ├── label_smoothed_cross_entropy_with_ctc.py │ │ ├── label_smoothed_cross_entropy_with_rdrop.py │ │ ├── legacy_masked_lm.py │ │ ├── masked_lm.py │ │ ├── model_criterion.py │ │ ├── nat_loss.py │ │ ├── sentence_prediction.py │ │ ├── sentence_prediction_adapters.py │ │ ├── sentence_ranking.py │ │ ├── speech_dlm_criterion.py │ │ ├── speech_to_speech_criterion.py │ │ ├── speech_ulm_criterion.py │ │ ├── tacotron2_loss.py │ │ └── wav2vec_criterion.py │ ├── data │ │ ├── __init__.py │ │ ├── add_class_target_dataset.py │ │ ├── add_target_dataset.py │ │ ├── append_token_dataset.py │ │ ├── audio │ │ │ ├── __init__.py │ │ │ ├── audio_utils.py │ │ │ ├── data_cfg.py │ │ │ ├── dataset_transforms │ │ │ │ ├── __init__.py │ │ │ │ ├── concataugment.py │ │ │ │ └── noisyoverlapaugment.py │ │ │ ├── feature_transforms │ │ │ │ ├── __init__.py │ │ │ │ ├── delta_deltas.py │ │ │ │ ├── global_cmvn.py │ │ │ │ ├── specaugment.py │ │ │ │ └── utterance_cmvn.py │ │ │ ├── frm_text_to_speech_dataset.py │ │ │ ├── hubert_dataset.py │ │ │ ├── multi_modality_dataset.py │ │ │ ├── raw_audio_dataset.py │ │ │ ├── speech_to_speech_dataset.py │ │ │ ├── speech_to_text_dataset.py │ │ │ ├── speech_to_text_joint_dataset.py │ │ │ ├── text_to_speech_dataset.py │ │ │ └── waveform_transforms │ │ │ │ ├── __init__.py │ │ │ │ └── noiseaugment.py │ │ ├── backtranslation_dataset.py │ │ ├── base_wrapper_dataset.py │ │ ├── bucket_pad_length_dataset.py │ │ ├── codedataset.py │ │ ├── colorize_dataset.py │ │ ├── concat_dataset.py │ │ ├── concat_sentences_dataset.py │ │ ├── data_utils.py │ │ ├── data_utils_fast.pyx │ │ ├── denoising_dataset.py │ │ ├── dictionary.py │ │ ├── encoders │ │ │ ├── __init__.py │ │ │ ├── byte_bpe.py │ │ │ ├── byte_utils.py │ │ │ ├── bytes.py │ │ │ ├── characters.py │ │ │ ├── fastbpe.py │ │ │ ├── gpt2_bpe.py │ │ │ ├── gpt2_bpe_utils.py │ │ │ ├── hf_bert_bpe.py │ │ │ ├── hf_byte_bpe.py │ │ │ ├── moses_tokenizer.py │ │ │ ├── nltk_tokenizer.py │ │ │ ├── sentencepiece_bpe.py │ │ │ ├── space_tokenizer.py │ │ │ ├── subword_nmt_bpe.py │ │ │ └── utils.py │ │ ├── fairseq_dataset.py │ │ ├── fasta_dataset.py │ │ ├── huffman │ │ │ ├── __init__.py │ │ │ ├── huffman_coder.py │ │ │ └── huffman_mmap_indexed_dataset.py │ │ ├── id_dataset.py │ │ ├── indexed_dataset.py │ │ ├── iterators.py │ │ ├── language_pair_dataset.py │ │ ├── legacy │ │ │ ├── __init__.py │ │ │ ├── block_pair_dataset.py │ │ │ ├── masked_lm_dataset.py │ │ │ └── masked_lm_dictionary.py │ │ ├── list_dataset.py │ │ ├── lm_context_window_dataset.py │ │ ├── lru_cache_dataset.py │ │ ├── mask_tokens_dataset.py │ │ ├── monolingual_dataset.py │ │ ├── multi_corpus_dataset.py │ │ ├── multi_corpus_sampled_dataset.py │ │ ├── multilingual │ │ │ ├── __init__.py │ │ │ ├── multilingual_data_manager.py │ │ │ ├── multilingual_utils.py │ │ │ ├── sampled_multi_dataset.py │ │ │ ├── sampled_multi_epoch_dataset.py │ │ │ └── sampling_method.py │ │ ├── nested_dictionary_dataset.py │ │ ├── noising.py │ │ ├── num_samples_dataset.py │ │ ├── numel_dataset.py │ │ ├── offset_tokens_dataset.py │ │ ├── pad_dataset.py │ │ ├── padding_mask_dataset.py │ │ ├── plasma_utils.py │ │ ├── prepend_dataset.py │ │ ├── prepend_token_dataset.py │ │ ├── raw_label_dataset.py │ │ ├── replace_dataset.py │ │ ├── resampling_dataset.py │ │ ├── roll_dataset.py │ │ ├── round_robin_zip_datasets.py │ │ ├── shorten_dataset.py │ │ ├── sort_dataset.py │ │ ├── span_mask_tokens_dataset.py │ │ ├── speech_dlm_dataset.py │ │ ├── strip_token_dataset.py │ │ ├── subsample_dataset.py │ │ ├── text_compressor.py │ │ ├── token_block_dataset.py │ │ ├── token_block_utils_fast.pyx │ │ ├── transform_eos_concat_langpair_dataset.py │ │ ├── transform_eos_dataset.py │ │ └── transform_eos_lang_pair_dataset.py │ ├── dataclass │ │ ├── __init__.py │ │ ├── configs.py │ │ ├── constants.py │ │ ├── initialize.py │ │ └── utils.py │ ├── distributed │ │ ├── __init__.py │ │ ├── distributed_timeout_wrapper.py │ │ ├── fully_sharded_data_parallel.py │ │ ├── legacy_distributed_data_parallel.py │ │ ├── module_proxy_wrapper.py │ │ ├── tpu_distributed_data_parallel.py │ │ └── utils.py │ ├── file_chunker_utils.py │ ├── file_io.py │ ├── file_utils.py │ ├── hub_utils.py │ ├── incremental_decoding_utils.py │ ├── iterative_refinement_generator.py │ ├── logging │ │ ├── __init__.py │ │ ├── meters.py │ │ ├── metrics.py │ │ └── progress_bar.py │ ├── model_parallel │ │ ├── __init__.py │ │ ├── criterions │ │ │ ├── __init__.py │ │ │ └── vocab_parallel_cross_entropy.py │ │ ├── megatron_trainer.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── pipeline_parallel_transformer │ │ │ │ ├── __init__.py │ │ │ │ ├── layers.py │ │ │ │ └── model.py │ │ │ ├── roberta │ │ │ │ ├── __init__.py │ │ │ │ └── model.py │ │ │ ├── transformer.py │ │ │ └── transformer_lm.py │ │ └── modules │ │ │ ├── __init__.py │ │ │ ├── multihead_attention.py │ │ │ └── transformer_layer.py │ ├── models │ │ ├── __init__.py │ │ ├── bart │ │ │ ├── __init__.py │ │ │ ├── hub_interface.py │ │ │ └── model.py │ │ ├── composite_encoder.py │ │ ├── distributed_fairseq_model.py │ │ ├── ema │ │ │ ├── __init__.py │ │ │ └── ema.py │ │ ├── fairseq_decoder.py │ │ ├── fairseq_encoder.py │ │ ├── fairseq_incremental_decoder.py │ │ ├── fairseq_model.py │ │ ├── fconv.py │ │ ├── fconv_lm.py │ │ ├── fconv_self_att.py │ │ ├── hubert │ │ │ ├── __init__.py │ │ │ ├── hubert.py │ │ │ └── hubert_asr.py │ │ ├── huggingface │ │ │ ├── __init__.py │ │ │ └── hf_gpt2.py │ │ ├── lightconv.py │ │ ├── lightconv_lm.py │ │ ├── lstm.py │ │ ├── lstm_lm.py │ │ ├── masked_lm.py │ │ ├── model_utils.py │ │ ├── multilingual_transformer.py │ │ ├── multires_hubert │ │ │ ├── __init__.py │ │ │ ├── multires_hubert.py │ │ │ └── multires_hubert_asr.py │ │ ├── nat │ │ │ ├── __init__.py │ │ │ ├── cmlm_transformer.py │ │ │ ├── fairseq_nat_model.py │ │ │ ├── insertion_transformer.py │ │ │ ├── iterative_nonautoregressive_transformer.py │ │ │ ├── levenshtein_transformer.py │ │ │ ├── levenshtein_utils.py │ │ │ ├── nat_crf_transformer.py │ │ │ ├── nonautoregressive_ensembles.py │ │ │ └── nonautoregressive_transformer.py │ │ ├── roberta │ │ │ ├── __init__.py │ │ │ ├── alignment_utils.py │ │ │ ├── enc_dec.py │ │ │ ├── hub_interface.py │ │ │ ├── model.py │ │ │ ├── model_camembert.py │ │ │ ├── model_gottbert.py │ │ │ └── model_xlmr.py │ │ ├── speech_dlm │ │ │ ├── __init__.py │ │ │ ├── hub_interface.py │ │ │ ├── modules │ │ │ │ ├── __init__.py │ │ │ │ ├── speech_dlm_decoder.py │ │ │ │ └── speech_dlm_decoder_layer.py │ │ │ ├── sequence_generator │ │ │ │ ├── __init__.py │ │ │ │ ├── multichannel_search.py │ │ │ │ └── multichannel_sequence_generator.py │ │ │ └── speech_dlm.py │ │ ├── speech_to_speech │ │ │ ├── __init__.py │ │ │ ├── modules │ │ │ │ ├── __init__.py │ │ │ │ ├── ctc_decoder.py │ │ │ │ ├── stacked_embedding.py │ │ │ │ ├── transformer_decoder_aug.py │ │ │ │ └── transformer_encoder.py │ │ │ ├── s2s_conformer.py │ │ │ ├── s2s_conformer_translatotron2.py │ │ │ ├── s2s_conformer_unity.py │ │ │ └── s2s_transformer.py │ │ ├── speech_to_text │ │ │ ├── __init__.py │ │ │ ├── berard.py │ │ │ ├── convtransformer.py │ │ │ ├── hub_interface.py │ │ │ ├── modules │ │ │ │ ├── __init__.py │ │ │ │ ├── augmented_memory_attention.py │ │ │ │ ├── convolution.py │ │ │ │ └── emformer.py │ │ │ ├── multi_modality_model.py │ │ │ ├── s2t_conformer.py │ │ │ ├── s2t_transformer.py │ │ │ ├── s2t_wav_transformer.py │ │ │ ├── utils.py │ │ │ ├── xm_transformer.py │ │ │ └── xm_transformer_unity.py │ │ ├── text_to_speech │ │ │ ├── __init__.py │ │ │ ├── codehifigan.py │ │ │ ├── fastspeech2.py │ │ │ ├── hifigan.py │ │ │ ├── hub_interface.py │ │ │ ├── tacotron2.py │ │ │ ├── tts_transformer.py │ │ │ └── vocoder.py │ │ ├── transformer │ │ │ ├── __init__.py │ │ │ ├── transformer_base.py │ │ │ ├── transformer_config.py │ │ │ ├── transformer_decoder.py │ │ │ ├── transformer_decoder_aug.py │ │ │ ├── transformer_encoder.py │ │ │ └── transformer_legacy.py │ │ ├── transformer_align.py │ │ ├── transformer_from_pretrained_xlm.py │ │ ├── transformer_lm.py │ │ ├── transformer_ulm.py │ │ ├── wav2vec │ │ │ ├── __init__.py │ │ │ ├── utils.py │ │ │ ├── wav2vec.py │ │ │ ├── wav2vec2.py │ │ │ ├── wav2vec2_asr.py │ │ │ ├── wav2vec2_classification.py │ │ │ └── wav2vec2_laser.py │ │ └── xmod │ │ │ ├── __init__.py │ │ │ ├── hub_interface.py │ │ │ ├── model.py │ │ │ └── transformer_layer_xmod.py │ ├── modules │ │ ├── __init__.py │ │ ├── adaptive_input.py │ │ ├── adaptive_softmax.py │ │ ├── base_layer.py │ │ ├── beamable_mm.py │ │ ├── character_token_embedder.py │ │ ├── checkpoint_activations.py │ │ ├── conformer_layer.py │ │ ├── conv_tbc.py │ │ ├── cross_entropy.py │ │ ├── cuda_utils.cu │ │ ├── downsampled_multihead_attention.py │ │ ├── dynamic_convolution.py │ │ ├── dynamic_crf_layer.py │ │ ├── dynamicconv_layer │ │ │ ├── __init__.py │ │ │ ├── cuda_function_gen.py │ │ │ ├── dynamicconv_cuda.cpp │ │ │ ├── dynamicconv_cuda.cuh │ │ │ ├── dynamicconv_cuda_kernel.cu │ │ │ ├── dynamicconv_layer.py │ │ │ ├── dynamiconv_cpu.cpp │ │ │ └── setup.py │ │ ├── ema_module.py │ │ ├── espnet_multihead_attention.py │ │ ├── fairseq_dropout.py │ │ ├── fp32_batch_norm.py │ │ ├── fp32_group_norm.py │ │ ├── fp32_instance_norm.py │ │ ├── gelu.py │ │ ├── grad_multiply.py │ │ ├── gumbel_vector_quantizer.py │ │ ├── kmeans_attention.py │ │ ├── kmeans_vector_quantizer.py │ │ ├── layer_drop.py │ │ ├── layer_norm.py │ │ ├── learned_positional_embedding.py │ │ ├── lightconv_layer │ │ │ ├── __init__.py │ │ │ ├── cuda_function_gen.py │ │ │ ├── lightconv_cuda.cpp │ │ │ ├── lightconv_cuda.cuh │ │ │ ├── lightconv_cuda_kernel.cu │ │ │ ├── lightconv_layer.py │ │ │ └── setup.py │ │ ├── lightweight_convolution.py │ │ ├── linearized_convolution.py │ │ ├── location_attention.py │ │ ├── lstm_cell_with_zoneout.py │ │ ├── multihead_attention.py │ │ ├── positional_embedding.py │ │ ├── positional_encoding.py │ │ ├── quant_noise.py │ │ ├── quantization │ │ │ ├── __init__.py │ │ │ ├── pq │ │ │ │ ├── __init__.py │ │ │ │ ├── em.py │ │ │ │ ├── modules │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── qconv.py │ │ │ │ │ ├── qemb.py │ │ │ │ │ └── qlinear.py │ │ │ │ ├── pq.py │ │ │ │ └── utils.py │ │ │ ├── quantization_options.py │ │ │ └── scalar │ │ │ │ ├── __init__.py │ │ │ │ ├── modules │ │ │ │ ├── __init__.py │ │ │ │ ├── qact.py │ │ │ │ ├── qconv.py │ │ │ │ ├── qemb.py │ │ │ │ └── qlinear.py │ │ │ │ ├── ops.py │ │ │ │ └── utils.py │ │ ├── rotary_positional_embedding.py │ │ ├── same_pad.py │ │ ├── scalar_bias.py │ │ ├── sinusoidal_positional_embedding.py │ │ ├── sparse_multihead_attention.py │ │ ├── sparse_transformer_sentence_encoder.py │ │ ├── sparse_transformer_sentence_encoder_layer.py │ │ ├── transformer_layer.py │ │ ├── transformer_layer_aug.py │ │ ├── transformer_sentence_encoder.py │ │ ├── transformer_sentence_encoder_layer.py │ │ ├── transpose_last.py │ │ ├── unfold.py │ │ └── vggblock.py │ ├── nan_detector.py │ ├── ngram_repeat_block.py │ ├── optim │ │ ├── __init__.py │ │ ├── adadelta.py │ │ ├── adafactor.py │ │ ├── adagrad.py │ │ ├── adam.py │ │ ├── adamax.py │ │ ├── amp_optimizer.py │ │ ├── bmuf.py │ │ ├── composite.py │ │ ├── cpu_adam.py │ │ ├── dynamic_loss_scaler.py │ │ ├── fairseq_optimizer.py │ │ ├── fp16_optimizer.py │ │ ├── fused_adam.py │ │ ├── fused_lamb.py │ │ ├── lr_scheduler │ │ │ ├── __init__.py │ │ │ ├── cosine_lr_scheduler.py │ │ │ ├── fairseq_lr_scheduler.py │ │ │ ├── fixed_schedule.py │ │ │ ├── inverse_square_root_schedule.py │ │ │ ├── manual_lr_scheduler.py │ │ │ ├── pass_through.py │ │ │ ├── polynomial_decay_schedule.py │ │ │ ├── reduce_lr_on_plateau.py │ │ │ ├── step_lr_scheduler.py │ │ │ ├── tri_stage_lr_scheduler.py │ │ │ └── triangular_lr_scheduler.py │ │ ├── nag.py │ │ ├── sgd.py │ │ └── shard.py │ ├── options.py │ ├── pdb.py │ ├── quantization_utils.py │ ├── registry.py │ ├── scoring │ │ ├── __init__.py │ │ ├── bertscore.py │ │ ├── bleu.py │ │ ├── chrf.py │ │ ├── meteor.py │ │ ├── tokenizer.py │ │ └── wer.py │ ├── search.py │ ├── sequence_generator.py │ ├── sequence_scorer.py │ ├── speech_generator.py │ ├── tasks │ │ ├── __init__.py │ │ ├── audio_classification.py │ │ ├── audio_finetuning.py │ │ ├── audio_pretraining.py │ │ ├── cross_lingual_lm.py │ │ ├── denoising.py │ │ ├── fairseq_task.py │ │ ├── frm_text_to_speech.py │ │ ├── hubert_pretraining.py │ │ ├── language_modeling.py │ │ ├── legacy_masked_lm.py │ │ ├── masked_lm.py │ │ ├── multilingual_denoising.py │ │ ├── multilingual_language_modeling.py │ │ ├── multilingual_masked_lm.py │ │ ├── multilingual_translation.py │ │ ├── multires_hubert_pretraining.py │ │ ├── nlu_finetuning.py │ │ ├── online_backtranslation.py │ │ ├── semisupervised_translation.py │ │ ├── sentence_prediction.py │ │ ├── sentence_prediction_adapters.py │ │ ├── sentence_ranking.py │ │ ├── simultaneous_translation.py │ │ ├── span_masked_lm.py │ │ ├── speech_dlm_task.py │ │ ├── speech_to_speech.py │ │ ├── speech_to_text.py │ │ ├── speech_ulm_task.py │ │ ├── text_to_speech.py │ │ ├── translation.py │ │ ├── translation_from_pretrained_bart.py │ │ ├── translation_from_pretrained_xlm.py │ │ ├── translation_lev.py │ │ └── translation_multi_simple_epoch.py │ ├── token_generation_constraints.py │ ├── tokenizer.py │ ├── trainer.py │ ├── utils.py │ └── version.txt ├── fairseq_cli │ ├── __init__.py │ ├── eval_lm.py │ ├── generate.py │ ├── hydra_train.py │ ├── hydra_validate.py │ ├── interactive.py │ ├── preprocess.py │ ├── score.py │ ├── train.py │ └── validate.py ├── hubconf.py ├── hydra_plugins │ └── dependency_submitit_launcher │ │ ├── hydra_plugins │ │ └── dependency_submitit_launcher │ │ │ ├── __init__.py │ │ │ ├── config.py │ │ │ └── launcher.py │ │ └── setup.py ├── pyproject.toml ├── release_utils.py ├── scripts │ ├── __init__.py │ ├── average_checkpoints.py │ ├── build_sym_alignment.py │ ├── check_installation.py │ ├── compare_namespaces.py │ ├── compound_split_bleu.sh │ ├── constraints │ │ ├── extract.py │ │ └── validate.py │ ├── convert_dictionary.lua │ ├── convert_model.lua │ ├── count_docs.py │ ├── read_binarized.py │ ├── rm_pt.py │ ├── sacrebleu.sh │ ├── shard_docs.py │ ├── split_train_valid_docs.py │ ├── spm_decode.py │ ├── spm_encode.py │ ├── spm_train.py │ └── test_fsdp.sh ├── setup.cfg ├── setup.py ├── tests │ ├── __init__.py │ ├── distributed │ │ ├── __init__.py │ │ ├── test_bmuf.py │ │ ├── test_distributed_timeout_wrapper.py │ │ ├── test_module_proxy_wrapper.py │ │ ├── test_utils.py │ │ └── utils.py │ ├── gpu │ │ ├── __init__.py │ │ ├── test_binaries_gpu.py │ │ ├── test_ema_gpu.py │ │ └── transformer_quantization_config.yaml │ ├── speech │ │ ├── __init__.py │ │ ├── test_convtransformer_simul_trans.py │ │ ├── test_dual_input_wav_transformer.py │ │ ├── test_dualinput_s2t_transformer.py │ │ ├── test_fastspeech2.py │ │ ├── test_s2s_transformer.py │ │ ├── test_s2t_conformer.py │ │ ├── test_s2t_transformer.py │ │ ├── test_tts_transformer.py │ │ ├── test_wav2vec2.py │ │ └── test_xm_transformer.py │ ├── speech_recognition │ │ ├── __init__.py │ │ ├── asr_test_base.py │ │ ├── test_collaters.py │ │ ├── test_cross_entropy.py │ │ ├── test_data_utils.py │ │ └── test_vggtransformer.py │ ├── tasks │ │ ├── test_denoising.py │ │ ├── test_masked_lm.py │ │ ├── test_multilingual_denoising.py │ │ └── test_span_masked_lm.py │ ├── test_activation_checkpointing.py │ ├── test_amp_optimizer.py │ ├── test_average_checkpoints.py │ ├── test_backtranslation_dataset.py │ ├── test_binaries.py │ ├── test_binarizer.py │ ├── test_character_token_embedder.py │ ├── test_checkpoint_utils.py │ ├── test_checkpoint_utils_for_task_level_attributes.py │ ├── test_concat_dataset.py │ ├── test_constraints.py │ ├── test_convtbc.py │ ├── test_data_utils.py │ ├── test_dataclass_utils.py │ ├── test_dataset.py │ ├── test_dictionary.py │ ├── test_ema.py │ ├── test_espnet_multihead_attention.py │ ├── test_export.py │ ├── test_file_chunker_utils.py │ ├── test_file_io.py │ ├── test_fp16_optimizer.py │ ├── test_hf_hub.py │ ├── test_huffman.py │ ├── test_inference_dropout.py │ ├── test_iopath.py │ ├── test_iterators.py │ ├── test_label_smoothing.py │ ├── test_lm_context_window.py │ ├── test_lstm_jitable.py │ ├── test_memory_efficient_fp16.py │ ├── test_metrics.py │ ├── test_multi_corpus_dataset.py │ ├── test_multi_corpus_sampled_dataset.py │ ├── test_multihead_attention.py │ ├── test_noising.py │ ├── test_online_backtranslation.py │ ├── test_plasma_utils.py │ ├── test_positional_encoding.py │ ├── test_reproducibility.py │ ├── test_resampling_dataset.py │ ├── test_roberta.py │ ├── test_rotary_positional_embedding.py │ ├── test_sequence_generator.py │ ├── test_sequence_scorer.py │ ├── test_sparse_multihead_attention.py │ ├── test_token_block_dataset.py │ ├── test_train.py │ ├── test_transformer.py │ ├── test_utils.py │ ├── test_valid_subset_checks.py │ └── utils.py └── train.py ├── pyscripts ├── README.md ├── audio │ ├── compute_vad.py │ ├── format_wav_scp.py │ └── trim_silence.py ├── feats │ ├── apply_pca.py │ ├── apply_pca_cuml.py │ ├── dump_km_label.py │ ├── dump_ssl_feature.py │ ├── feat-to-shape.py │ ├── feats_apply_cluster_cuml.py │ ├── feats_apply_cluster_faiss.py │ ├── feats_cluster_cuml.py │ ├── feats_cluster_faiss.py │ ├── mean_pool_scp.py │ ├── measure_teacher_quality.py │ ├── merge_clusters.py │ ├── pca.py │ ├── pca_cuml.py │ ├── ssl_feature_utils.py │ └── unique_pseudo_labels.py ├── k2 │ ├── compile_hlg.py │ └── prepare_lang.py ├── text │ ├── combine_text_and_vocab.py │ ├── make_text_scp.py │ └── post_processing.py └── utils │ ├── asvspoof_score.py │ ├── calculate_bitrate.py │ ├── calculate_eer_mindcf.py │ ├── calculate_rtf.py │ ├── calculate_speech_metrics.py │ ├── check_align.py │ ├── convert_rttm.py │ ├── convert_text_to_phn.py │ ├── convert_to_avg_spk_embed.py │ ├── convert_token2json.py │ ├── create_README_file.py │ ├── eval_perm_free_error.py │ ├── evaluate_cfsd.py │ ├── evaluate_f0.py │ ├── evaluate_mcd.py │ ├── evaluate_pseudomos.py │ ├── evaluate_secs.py │ ├── evaluate_semitone.py │ ├── evaluate_speechbertscore.py │ ├── evaluate_speechbleu.py │ ├── evaluate_vuv.py │ ├── evaluate_whisper_inference.py │ ├── extract_spk_embed.py │ ├── format_score_scp.py │ ├── generate_cohort_list.py │ ├── generate_qmf_train_list.py │ ├── get_model_names.py │ ├── get_yaml.py │ ├── learn_kmeans.py │ ├── make_rttm.py │ ├── make_token_list_from_config.py │ ├── mfa_format.py │ ├── plot_sinc_filters.py │ ├── prep_segments.py │ ├── prep_segments_from_xml.py │ ├── print_args.py │ ├── remove_duplicate_keys.py │ ├── rotate_logfile.py │ ├── score_intent.py │ ├── score_lang_id.py │ ├── score_summarization.py │ ├── simuleval_agent.py │ ├── sklearn_km.py │ ├── spk_apply_qmf_func.py │ ├── spk_apply_score_norm.py │ ├── spk_calculate_scores_from_embeddings.py │ └── utt2spk_to_utt2sid.py ├── scripts ├── README.md ├── TEMPLATE_Readme.md ├── audio │ ├── compute_vad.sh │ ├── format_score_scp.sh │ ├── format_wav_scp.sh │ └── trim_silence.sh ├── feats │ ├── feat_to_shape.sh │ ├── feats_clustering.sh │ ├── feats_clustering_cuml.sh │ ├── make_fbank.sh │ ├── make_stft.sh │ └── perform_kmeans.sh ├── k2 │ └── make_lexicon.sh ├── text │ └── run_spm.sh └── utils │ ├── TEMPLATE_HF_Readme.md │ ├── calculate_speech_metrics.sh │ ├── download_from_google_drive.sh │ ├── enhance_dataset.sh │ ├── evaluate_asr.sh │ ├── evaluate_asr_bleu.sh │ ├── mfa.sh │ ├── perturb_data_dir_speed.sh │ ├── perturb_enh_data_dir_speed.sh │ ├── print_args.sh │ ├── remove_punctuation.pl │ ├── score_der.sh │ ├── show_asr_result.sh │ ├── show_asvspoof_result.sh │ ├── show_diar_result.sh │ ├── show_enh_score.sh │ ├── show_spk_result.py │ ├── show_translation_result.sh │ ├── simple_dict.sh │ └── upload_models_to_hub.sh ├── sentencepiece_commands ├── spm_decode ├── spm_encode └── spm_train └── utils ├── README.md ├── apply_map.pl ├── combine_data.sh ├── copy_data_dir.sh ├── create_data_link.pl ├── create_split_dir.pl ├── data ├── combine_data.sh ├── extend_segment_times.py ├── fix_data_dir.sh ├── get_reco2dur.sh ├── get_segments_for_data.sh ├── get_utt2dur.sh ├── internal │ └── modify_speaker_info.py ├── modify_speaker_info.sh ├── remove_dup_utts.sh ├── resample_data_dir.sh ├── split_data.sh └── subset_data_dir.sh ├── download_from_google_drive.sh ├── filter_scp.pl ├── filter_scps.pl ├── fix_data_dir.sh ├── parallel ├── pbs.pl ├── queue.pl ├── retry.pl ├── run.pl └── slurm.pl ├── parse_options.sh ├── pbs.pl ├── queue.pl ├── retry.pl ├── run.pl ├── shuffle_list.pl ├── simple_dict.sh ├── slurm.pl ├── spk2utt_to_utt2spk.pl ├── split_scp.pl ├── subset_data_dir.sh ├── subset_data_dir_tr_cv.sh ├── subset_scp.pl ├── utt2spk_to_spk2utt.pl ├── validate_data_dir.sh └── validate_text.pl /assets/mtla.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/assets/mtla.png -------------------------------------------------------------------------------- /experiments/speech_recognition/cmd.sh: -------------------------------------------------------------------------------- 1 | ../tools/cmd.sh -------------------------------------------------------------------------------- /experiments/speech_recognition/espnet.sh: -------------------------------------------------------------------------------- 1 | ../tools/espnet.sh -------------------------------------------------------------------------------- /experiments/speech_recognition/infer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2025 Keqi Deng (University of Cambridge) 4 | # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) 5 | 6 | # ======= Default config ======= 7 | DATA_ROOT="" 8 | SAVE_DIR="" 9 | CHECKPOINT_FILENAME=avg_10_checkpoint.pt 10 | 11 | # ======= Option parsing ======= 12 | . ./../tools/utils/parse_options.sh || exit 1; 13 | 14 | # ======= Run inference ======= 15 | fairseq-generate ${DATA_ROOT} \ 16 | --config-yaml config_infer.yaml --gen-subset ihm_eval_infer --task speech_to_text \ 17 | --path ${SAVE_DIR}/${CHECKPOINT_FILENAME} \ 18 | --max-tokens 60000 --beam 20 --scoring wer 19 | -------------------------------------------------------------------------------- /experiments/speech_recognition/local/split_REAMDE.txt: -------------------------------------------------------------------------------- 1 | The splits in this directory follow the official AMI Corpus Full-ASR split 2 | on train, dev and eval sets. 3 | 4 | If for some reason ones need to use different split the way to do so is 5 | to create split_*.final versions in this directory and run the recipe. 6 | -------------------------------------------------------------------------------- /experiments/speech_recognition/local/split_dev.orig: -------------------------------------------------------------------------------- 1 | ES2011a 2 | ES2011b 3 | ES2011c 4 | ES2011d 5 | IB4001 6 | IB4002 7 | IB4003 8 | IB4004 9 | IB4010 10 | IB4011 11 | IS1008a 12 | IS1008b 13 | IS1008c 14 | IS1008d 15 | TS3004a 16 | TS3004b 17 | TS3004c 18 | TS3004d 19 | -------------------------------------------------------------------------------- /experiments/speech_recognition/local/split_eval.orig: -------------------------------------------------------------------------------- 1 | EN2002a 2 | EN2002b 3 | EN2002c 4 | EN2002d 5 | ES2004a 6 | ES2004b 7 | ES2004c 8 | ES2004d 9 | IS1009a 10 | IS1009b 11 | IS1009c 12 | IS1009d 13 | TS3003a 14 | TS3003b 15 | TS3003c 16 | TS3003d 17 | -------------------------------------------------------------------------------- /experiments/speech_recognition/path.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/speech_recognition/path.sh -------------------------------------------------------------------------------- /experiments/speech_recognition/pyscripts: -------------------------------------------------------------------------------- 1 | ../tools/pyscripts -------------------------------------------------------------------------------- /experiments/speech_recognition/scripts: -------------------------------------------------------------------------------- 1 | ../tools/scripts -------------------------------------------------------------------------------- /experiments/speech_recognition/utils: -------------------------------------------------------------------------------- 1 | ../tools/utils -------------------------------------------------------------------------------- /experiments/speech_translation/infer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2025 Keqi Deng (University of Cambridge) 4 | # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) 5 | 6 | # ======= Default config ======= 7 | MUSTC_ROOT="" 8 | ST_SAVE_DIR="" 9 | CHECKPOINT_FILENAME=avg_10_checkpoint.pt 10 | 11 | # ======= Option parsing ======= 12 | . ./../tools/utils/parse_options.sh || exit 1; 13 | 14 | # ======= Run inference ======= 15 | fairseq-generate ${MUSTC_ROOT}/en-de \ 16 | --config-yaml config_st.yaml --gen-subset tst-COMMON_st --task speech_to_text \ 17 | --path ${ST_SAVE_DIR}/${CHECKPOINT_FILENAME} \ 18 | --max-tokens 50000 --beam 50 --scoring sacrebleu 19 | -------------------------------------------------------------------------------- /experiments/spoken_language_understanding/cmd.sh: -------------------------------------------------------------------------------- 1 | ../tools/cmd.sh -------------------------------------------------------------------------------- /experiments/spoken_language_understanding/espnet.sh: -------------------------------------------------------------------------------- 1 | ../tools/espnet.sh -------------------------------------------------------------------------------- /experiments/spoken_language_understanding/infer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2025 Keqi Deng (University of Cambridge) 4 | # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) 5 | 6 | # ======= Default config ======= 7 | LS_ROOT="" 8 | SAVE_DIR="" 9 | CHECKPOINT_FILENAME=avg_10_checkpoint.pt 10 | 11 | # ======= Option parsing ======= 12 | . ./../tools/utils/parse_options.sh || exit 1; 13 | 14 | # ======= Run inference ======= 15 | fairseq-generate ${LS_ROOT} \ 16 | --config-yaml config.yaml --gen-subset test --task speech_to_text \ 17 | --path ${SAVE_DIR}/${CHECKPOINT_FILENAME} \ 18 | --max-tokens 130000 --beam 10 --scoring ic_accuracy 19 | -------------------------------------------------------------------------------- /experiments/spoken_language_understanding/local/config.yaml: -------------------------------------------------------------------------------- 1 | input_channels: 1 2 | input_feat_per_channel: 80 3 | specaugment: 4 | freq_mask_F: 27 5 | freq_mask_N: 1 6 | time_mask_N: 1 7 | time_mask_T: 100 8 | time_mask_p: 1.0 9 | time_wrap_W: 0 10 | transforms: 11 | '*': 12 | - utterance_cmvn 13 | _train: 14 | - utterance_cmvn 15 | - specaugment 16 | vocab_filename: vocab.txt 17 | -------------------------------------------------------------------------------- /experiments/spoken_language_understanding/local/kaldi_to_tsv.py: -------------------------------------------------------------------------------- 1 | ../../speech_recognition/local/kaldi_to_tsv.py -------------------------------------------------------------------------------- /experiments/spoken_language_understanding/path.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/spoken_language_understanding/path.sh -------------------------------------------------------------------------------- /experiments/spoken_language_understanding/pyscripts: -------------------------------------------------------------------------------- 1 | ../tools/pyscripts/ -------------------------------------------------------------------------------- /experiments/spoken_language_understanding/scripts: -------------------------------------------------------------------------------- 1 | ../tools/scripts/ -------------------------------------------------------------------------------- /experiments/spoken_language_understanding/utils: -------------------------------------------------------------------------------- 1 | ../tools/utils/ -------------------------------------------------------------------------------- /experiments/text_summarisation/infer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2025 Keqi Deng (University of Cambridge) 4 | # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) 5 | 6 | # ======= Default config ======= 7 | SUM_SAVE_DIR="" 8 | CHECKPOINT_FILENAME=avg_10_checkpoint.pt 9 | 10 | # ======= Option parsing ======= 11 | . ./../tools/utils/parse_options.sh || exit 1; 12 | 13 | # ======= Run inference ======= 14 | fairseq-generate xsum_data/bin \ 15 | --path ${SUM_SAVE_DIR}/${CHECKPOINT_FILENAME} \ 16 | --max-tokens 70000 --beam 10 --scoring rouge_l --skip-invalid-size-inputs-valid-test --remove-bpe --temperature 0.9 17 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## 👉 [Please follow one of these issue templates](https://github.com/pytorch/fairseq/issues/new/choose) 👈 2 | 3 | Note: to keep the backlog clean and actionable, issues may be immediately closed if they do not follow one of the above issue templates. 4 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/.github/ISSUE_TEMPLATE/documentation.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 📚 Documentation/Typos 3 | about: Report an issue related to documentation or a typo 4 | labels: 'documentation, needs triage' 5 | --- 6 | 7 | ## 📚 Documentation 8 | 9 | For typos and doc fixes, please go ahead and: 10 | 11 | 1. Create an issue. 12 | 2. Fix the typo. 13 | 3. Submit a PR. 14 | 15 | Thanks! 16 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🚀 Feature Request 3 | about: Submit a proposal/request for a new feature 4 | labels: 'enhancement, help wanted, needs triage' 5 | --- 6 | 7 | ## 🚀 Feature Request 8 | 9 | 10 | ### Motivation 11 | 12 | 13 | 14 | ### Pitch 15 | 16 | 17 | 18 | ### Alternatives 19 | 20 | 21 | 22 | ### Additional context 23 | 24 | 25 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/.github/ISSUE_TEMPLATE/how-to-question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: ❓ Questions/Help 3 | about: If you have questions, please first search existing issues and docs 4 | labels: 'question, needs triage' 5 | --- 6 | 7 | ## ❓ Questions and Help 8 | 9 | ### Before asking: 10 | 1. search the issues. 11 | 2. search the docs. 12 | 13 | 14 | 15 | #### What is your question? 16 | 17 | #### Code 18 | 19 | 20 | 21 | #### What have you tried? 22 | 23 | #### What's your environment? 24 | 25 | - fairseq Version (e.g., 1.0 or main): 26 | - PyTorch Version (e.g., 1.0) 27 | - OS (e.g., Linux): 28 | - How you installed fairseq (`pip`, source): 29 | - Build command you used (if compiling from source): 30 | - Python version: 31 | - CUDA/cuDNN version: 32 | - GPU models and configuration: 33 | - Any other relevant information: 34 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Before submitting 2 | 3 | - [ ] Was this discussed/approved via a Github issue? (no need for typos, doc improvements) 4 | - [ ] Did you read the [contributor guideline](https://github.com/pytorch/fairseq/blob/main/CONTRIBUTING.md)? 5 | - [ ] Did you make sure to update the docs? 6 | - [ ] Did you write any new necessary tests? 7 | 8 | ## What does this PR do? 9 | Fixes # (issue). 10 | 11 | ## PR review 12 | Anyone in the community is free to review the PR once the tests have passed. 13 | If we didn't discuss your PR in Github issues there's a high chance it will not be merged. 14 | 15 | ## Did you have fun? 16 | Make sure you had fun coding 🙃 17 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/.github/workflows/depreview.yml: -------------------------------------------------------------------------------- 1 | name: 'Dependency Review' 2 | on: [pull_request] 3 | 4 | permissions: 5 | contents: read 6 | 7 | jobs: 8 | dependency-review: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: 'Checkout Repository' 12 | uses: actions/checkout@v4 13 | - name: Dependency Review 14 | uses: actions/dependency-review-action@v4 15 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "fairseq/model_parallel/megatron"] 2 | path = fairseq/model_parallel/megatron 3 | url = https://github.com/ngoyal2707/Megatron-LM 4 | branch = fairseq 5 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include fairseq/version.txt 2 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/RELEASE.md: -------------------------------------------------------------------------------- 1 | # Creating a New Release 2 | 3 | In order to create a new release: 4 | 5 | 1. Navigate to the [Fairseq Workflows](https://github.com/facebookresearch/fairseq/actions) and find the one named _Fairseq Release_. 6 | 7 | 2. Under _Run Workflow_ choose the branch `main` and for _Release Type_ enter either `major`, `minor`, or `patch`. 8 | 9 | 3. A branch named `$new_version-release` will be created where the `version.txt` file is updated. Merge those changes into `main`. 10 | 11 | 4. Make sure that a [new PYPI package](https://pypi.org/project/fairseq/) has been uploaded. 12 | 13 | 5. Make sure that a [new github release](https://github.com/facebookresearch/fairseq/releases) has been created. 14 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = python -msphinx 7 | SPHINXPROJ = fairseq 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /experiments/tools/fairseq/docs/criterions.rst: -------------------------------------------------------------------------------- 1 | .. role:: hidden 2 | :class: hidden-section 3 | 4 | .. _Criterions: 5 | 6 | Criterions 7 | ========== 8 | 9 | Criterions compute the loss function given the model and batch, roughly:: 10 | 11 | loss = criterion(model, batch) 12 | 13 | .. automodule:: fairseq.criterions 14 | :members: 15 | 16 | .. autoclass:: fairseq.criterions.FairseqCriterion 17 | :members: 18 | :undoc-members: 19 | 20 | .. autoclass:: fairseq.criterions.adaptive_loss.AdaptiveLoss 21 | :members: 22 | :undoc-members: 23 | .. autoclass:: fairseq.criterions.composite_loss.CompositeLoss 24 | :members: 25 | :undoc-members: 26 | .. autoclass:: fairseq.criterions.cross_entropy.CrossEntropyCriterion 27 | :members: 28 | :undoc-members: 29 | .. autoclass:: fairseq.criterions.label_smoothed_cross_entropy.LabelSmoothedCrossEntropyCriterion 30 | :members: 31 | :undoc-members: 32 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/docs/docutils.conf: -------------------------------------------------------------------------------- 1 | [writers] 2 | option-limit=0 3 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/docs/fairseq.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/docs/fairseq.gif -------------------------------------------------------------------------------- /experiments/tools/fairseq/docs/fairseq_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/docs/fairseq_logo.png -------------------------------------------------------------------------------- /experiments/tools/fairseq/docs/modules.rst: -------------------------------------------------------------------------------- 1 | Modules 2 | ======= 3 | 4 | Fairseq provides several stand-alone :class:`torch.nn.Module` classes that may 5 | be helpful when implementing a new :class:`~fairseq.models.BaseFairseqModel`. 6 | 7 | .. automodule:: fairseq.modules 8 | :members: 9 | :undoc-members: 10 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/.gitignore: -------------------------------------------------------------------------------- 1 | !*/*.sh 2 | !*/*.md 3 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/mmpt/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | try: 6 | # fairseq user dir 7 | from .datasets import FairseqMMDataset 8 | from .losses import FairseqCriterion 9 | from .models import FairseqMMModel 10 | from .tasks import FairseqMMTask 11 | except ImportError: 12 | pass 13 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/mmpt/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | from .mmdataset import * 6 | 7 | try: 8 | from .fairseqmmdataset import * 9 | except ImportError: 10 | pass 11 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/mmpt/evaluators/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | from .metric import * 6 | from .evaluator import * 7 | 8 | 9 | # experimental. 10 | try: 11 | from .expmetric import * 12 | except ImportError: 13 | pass 14 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/mmpt/losses/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | from .loss import * 6 | from .nce import * 7 | 8 | try: 9 | from .fairseqmmloss import * 10 | except ImportError: 11 | pass 12 | 13 | try: 14 | from .expnce import * 15 | except ImportError: 16 | pass 17 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/mmpt/models/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | from .mmfusion import * 6 | from .transformermodel import * 7 | from .mmfusionnlg import * 8 | 9 | try: 10 | from .fairseqmmmodel import * 11 | except ImportError: 12 | pass 13 | 14 | try: 15 | from .expmmfusion import * 16 | except ImportError: 17 | pass 18 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/mmpt/modules/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | from .mm import * 6 | 7 | try: 8 | from .expmm import * 9 | except ImportError: 10 | pass 11 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/mmpt/processors/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | from .processor import * 6 | 7 | from .how2processor import * 8 | from .how2retriprocessor import * 9 | 10 | from .dsprocessor import * 11 | 12 | try: 13 | from .rawvideoprocessor import * 14 | from .codecprocessor import * 15 | from .webvidprocessor import * 16 | from .expprocessor import * 17 | from .exphow2processor import * 18 | from .exphow2retriprocessor import * 19 | from .expcodecprocessor import * 20 | from .expfeatureencoder import * 21 | from .expdsprocessor import * 22 | except ImportError: 23 | pass 24 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/mmpt/tasks/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | from .task import * 6 | from .vlmtask import * 7 | from .retritask import * 8 | 9 | try: 10 | from .fairseqmmtask import * 11 | except ImportError: 12 | pass 13 | 14 | try: 15 | from .milncetask import * 16 | except ImportError: 17 | pass 18 | 19 | try: 20 | from .expretritask import * 21 | except ImportError: 22 | pass 23 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/mtm/mmfusionmtm.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/mfmmlm.yaml 2 | project_dir: mtm/mmfusionmtm 3 | task_group: 4 | pretrain: 5 | task: VLMTask # reproducible 6 | dataset: 7 | aligner: MFMMLMAligner 8 | model: 9 | use_seg_emb: True # reproducible 10 | model_cls: MMFusionMTM 11 | mm_encoder_cls: MMBertForMFMMLM 12 | loss: 13 | loss_cls: MTM 14 | finetune: 15 | model: 16 | use_seg_emb: True # reproducible 17 | test: 18 | model: 19 | use_seg_emb: True # reproducible 20 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/mtm/vlm.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/mtm/mmfusionmtm.yaml 2 | project_dir: mtm/vlm 3 | task_group: 4 | pretrain: 5 | dataset: 6 | sampled_min_len: 8 7 | loss: 8 | loss_cls: MTM 9 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/mtm/vlm/test_vtt.yaml: -------------------------------------------------------------------------------- 1 | slurm_config: big 2 | task_type: local_predict 3 | dataset: 4 | split: test 5 | video_processor: VideoProcessor 6 | aligner: DSAligner 7 | bert_name: bert-base-uncased 8 | meta_processor: MSRVTTMetaProcessor 9 | test_path: data/msrvtt/MSRVTT_JSFUSION_test.csv 10 | vfeat_dir: data/feat/feat_vtt_s3d 11 | text_processor: MSRVTTTextProcessor 12 | num_iso_layer: 12 13 | max_video_len: 32 14 | max_len: 96 15 | fairseq: 16 | dataset: 17 | batch_size: 256 18 | valid_subset: test 19 | num_workers: 2 20 | common_eval: 21 | path: runs/mtm/vlm/vtt/checkpoint_last.pt 22 | model: 23 | model_cls: MMFusionJoint 24 | mm_encoder_cls: MMBertForJoint 25 | use_seg_emb: true 26 | eval: 27 | save_path: runs/mtm/vlm/vtt/eval 28 | metric: RetrievalMetric 29 | predictor: RetrievalPredictor 30 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/mtm/vlm/test_vttqa.yaml: -------------------------------------------------------------------------------- 1 | slurm_config: big 2 | task_type: local_predict 3 | dataset: 4 | split: test 5 | video_processor: VideoProcessor 6 | aligner: MSRVTTQAAligner 7 | bert_name: bert-base-uncased 8 | meta_processor: MSRVTTQAMetaProcessor 9 | test_path: data/msrvtt-qa/MSR_MC_test.csv 10 | vfeat_dir: data/feat/feat_vtt_s3d 11 | text_processor: MSRVTTQATextProcessor 12 | num_iso_layer: 12 13 | max_video_len: 32 14 | max_len: 96 15 | fairseq: 16 | dataset: 17 | batch_size: 256 18 | valid_subset: test 19 | num_workers: 2 20 | common_eval: 21 | path: runs/mtm/vlm/vttqa/checkpoint_last.pt 22 | model: 23 | model_cls: MMFusionJoint 24 | mm_encoder_cls: MMBertForJoint 25 | use_seg_emb: true 26 | eval: 27 | save_path: runs/mtm/vlm/vttqa/eval 28 | metric: QAMetric 29 | predictor: QAPredictor 30 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/retri/videoclip.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/retri/videoretri.yaml 2 | project_dir: retri/videoclip 3 | task_group: 4 | pretrain: 5 | model: 6 | model_cls: MMFusionSeparate 7 | mm_encoder_cls: 8 | video_encoder_cls: MMBertForEncoder 9 | text_encoder_cls: BertModel 10 | num_hidden_video_layers: 6 11 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/retri/videoclip/test_didemo_zs.yaml: -------------------------------------------------------------------------------- 1 | slurm_config: big 2 | task_type: local_predict 3 | dataset: 4 | split: test 5 | video_processor: VideoProcessor 6 | aligner: DiDeMoAligner 7 | bert_name: bert-base-uncased 8 | meta_processor: DiDeMoMetaProcessor 9 | test_path: data/didemo/test_data.json 10 | vfeat_dir: data/feat/feat_didemo_s3d 11 | text_processor: DiDeMoTextProcessor 12 | num_iso_layer: 12 13 | max_video_len: 32 14 | max_len: 96 15 | fairseq: 16 | dataset: 17 | batch_size: 256 18 | valid_subset: test 19 | num_workers: 2 20 | common_eval: 21 | path: runs/retri/videoclip/checkpoint_best.pt 22 | model: 23 | model_cls: MMFusionSeparate 24 | mm_encoder_cls: null 25 | video_encoder_cls: MMBertForEncoder 26 | text_encoder_cls: BertModel 27 | num_hidden_video_layers: 6 28 | eval: 29 | save_path: runs/retri/videoclip/didemo_zs/eval 30 | metric: DiDeMoMetric 31 | predictor: DiDeMoPredictor 32 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/retri/videoclip/test_vttqa_zs.yaml: -------------------------------------------------------------------------------- 1 | slurm_config: big 2 | task_type: local_predict 3 | dataset: 4 | split: test 5 | video_processor: VideoProcessor 6 | aligner: MSRVTTQAAligner 7 | bert_name: bert-base-uncased 8 | meta_processor: MSRVTTQAMetaProcessor 9 | test_path: data/msrvtt-qa/MSR_MC_test.csv 10 | vfeat_dir: data/feat/feat_vtt_s3d 11 | text_processor: MSRVTTQATextProcessor 12 | num_iso_layer: 12 13 | max_video_len: 32 14 | max_len: 96 15 | fairseq: 16 | dataset: 17 | batch_size: 256 18 | valid_subset: test 19 | num_workers: 2 20 | common_eval: 21 | path: runs/retri/videoclip/checkpoint_best.pt 22 | model: 23 | model_cls: MMFusionSeparate 24 | mm_encoder_cls: null 25 | video_encoder_cls: MMBertForEncoder 26 | text_encoder_cls: BertModel 27 | num_hidden_video_layers: 6 28 | eval: 29 | save_path: runs/retri/videoclip/vttqa_zs/eval 30 | metric: QAMetric 31 | predictor: QAPredictor 32 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/coin.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/ft.yaml 2 | task_type: sweep_big 3 | dataset: 4 | meta_processor: COINActionSegmentationMetaProcessor 5 | train_path: data/coin/COIN.json 6 | val_path: data/coin/COIN.json 7 | vfeat_dir: data/feat/feat_coin_s3d 8 | video_processor: VideoProcessor 9 | text_processor: COINActionSegmentationTextProcessor 10 | aligner: COINActionSegmentationAligner 11 | num_iso_layer: 12 12 | sliding_window: 8 13 | sliding_window_size: 32 14 | model: 15 | model_cls: MMFusionActionSegmentation 16 | mm_encoder_cls: MMBertForTokenClassification 17 | loss: 18 | loss_cls: CrossEntropy 19 | fairseq: 20 | dataset: 21 | batch_size: 1 22 | optimization: 23 | max_epoch: 8 24 | checkpoint: 25 | save_dir: runs/task/coin 26 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/coin_videoclip.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/coin.yaml 2 | model: 3 | model_cls: MMFusionSeparateActionSegmentation 4 | mm_encoder_cls: 5 | video_encoder_cls: MMBertForTokenClassification 6 | text_encoder_cls: BertModel # dummy, not used. 7 | num_hidden_video_layers: 6 8 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/crosstask_videoclip.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/crosstask.yaml 2 | model: 3 | model_cls: MMFusionSeparateActionLocalization 4 | mm_encoder_cls: 5 | video_encoder_cls: MMBertForEncoder 6 | text_encoder_cls: BertModel # dummy, not used. 7 | num_hidden_video_layers: 6 8 | fairseq: 9 | checkpoint: 10 | restore_file: runs/task/checkpoint_best.pt # overwrite the default of VLM. 11 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/default.yaml: -------------------------------------------------------------------------------- 1 | # this yaml cannot be run alone. you must use `how2.yaml`, `vtt.yaml` etc for training. 2 | dataset: 3 | video_processor: VideoProcessor 4 | bert_name: bert-base-uncased 5 | fairseq: 6 | common: 7 | tensorboard_logdir: run 8 | log_interval: 1000 9 | dataset: 10 | num_workers: 4 11 | optimization: 12 | lr: [ 0.00005 ] 13 | clip_norm: 2.0 14 | optimizer: adam 15 | adam_betas: (0.9, 0.98) 16 | lr_scheduler: polynomial_decay 17 | total_num_update: 1000000 # backward compatible on fairseq 1.0.0a0+af0389f for reproducibility. 18 | warmup_updates: 1000 19 | weight_decay: 0.0 20 | ddp_backend: no_c10d 21 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/ft.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/default.yaml 2 | # all derived config will be run by fairseq-train. 3 | task_type: sweep_small 4 | fairseq: 5 | optimization: 6 | warmup_updates: 122 # copied from roberta glue: https://github.com/pytorch/fairseq/blob/master/examples/roberta/README.glue.md 7 | checkpoint: 8 | # save_interval_updates: 512 9 | # borrowed from Roberta script. 10 | restore_file: runs/task/checkpoint_best.pt 11 | reset_optimizer: True 12 | reset_dataloader: True 13 | reset_meters: True 14 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/how2.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/default.yaml 2 | task_type: sweep_big 3 | slurm_config: big 4 | dataset: 5 | meta_processor: ShardedHow2MetaProcessor 6 | train_path: data/how2/how2_s3d_train.lst 7 | val_path: data/how2/how2_s3d_val.lst 8 | video_processor: ShardedVideoProcessor 9 | vfeat_dir: data/feat/feat_how2_s3d_shard_small 10 | text_processor: ShardedTextProcessor 11 | tfeat_dir: data/feat/feat_how2_s3d_shard_small/raw_caption_dedup.bert-base-uncased. 12 | aligner: FixedLenAligner 13 | # disable direct running of this yaml 14 | eval: 15 | save_path: runs/task 16 | fairseq: 17 | checkpoint: 18 | save_dir: runs/task 19 | save_interval_updates: 1024 20 | keep_interval_updates: 2 21 | keep_last_epochs: 30 22 | 23 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/test.yaml: -------------------------------------------------------------------------------- 1 | # this yaml cannot be run alone: implement a test_${dataset}.yaml 2 | slurm_config: big 3 | task_type: local_predict 4 | dataset: 5 | split: test 6 | video_processor: VideoProcessor 7 | aligner: DSAligner 8 | bert_name: bert-base-uncased 9 | fairseq: 10 | dataset: 11 | batch_size: 256 12 | valid_subset: test 13 | num_workers: 2 14 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/test_coin.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/test.yaml 2 | dataset: 3 | split: test 4 | test_path: data/coin/COIN.json 5 | meta_processor: COINActionSegmentationMetaProcessor 6 | vfeat_dir: data/feat/feat_coin_s3d 7 | video_processor: VideoProcessor 8 | text_processor: COINActionSegmentationTextProcessor 9 | aligner: COINActionSegmentationAligner 10 | num_iso_layer: 12 11 | sliding_window: 16 12 | sliding_window_size: 32 13 | model: 14 | model_cls: MMFusionActionSegmentation 15 | mm_encoder_cls: MMBertForTokenClassification 16 | eval: 17 | save_path: runs/task/coin/eval 18 | fairseq: 19 | dataset: 20 | batch_size: 1 21 | common_eval: 22 | path: runs/task/coin/checkpoint_best.pt 23 | metric: COINActionSegmentationMetric 24 | predictor: COINPredictor 25 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/test_coin_videoclip.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/test_coin.yaml 2 | model: 3 | model_cls: MMFusionSeparateActionSegmentation 4 | mm_encoder_cls: 5 | video_encoder_cls: MMBertForTokenClassification 6 | text_encoder_cls: BertModel # dummy, not used. 7 | num_hidden_video_layers: 6 8 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/test_coin_zs.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/test_coin.yaml 2 | model: 3 | model_cls: MMFusionSeparate 4 | mm_encoder_cls: 5 | video_encoder_cls: MMBertForEncoder 6 | text_encoder_cls: BertModel 7 | num_hidden_video_layers: 6 8 | eval: 9 | save_path: runs/task/coin_zs/eval 10 | fairseq: 11 | common_eval: 12 | path: runs/task/checkpoint_best.pt 13 | predictor: COINZSPredictor 14 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/test_crosstask_videoclip.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/test_crosstask.yaml 2 | model: 3 | model_cls: MMFusionSeparateActionLocalization 4 | mm_encoder_cls: 5 | video_encoder_cls: MMBertForEncoder 6 | text_encoder_cls: BertModel # dummy, not used. 7 | num_hidden_video_layers: 6 8 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/test_crosstask_zs_videoclip.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/test_crosstask_zs.yaml 2 | model: 3 | model_cls: MMFusionSeparateActionLocalization 4 | mm_encoder_cls: 5 | video_encoder_cls: MMBertForEncoder 6 | text_encoder_cls: BertModel # dummy, not used. 7 | num_hidden_video_layers: 6 8 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/test_didemo_zs.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/test.yaml 2 | dataset: 3 | meta_processor: DiDeMoMetaProcessor 4 | test_path: data/didemo/test_data.json 5 | video_processor: VideoProcessor 6 | vfeat_dir: data/feat/feat_didemo_s3d 7 | text_processor: DiDeMoTextProcessor 8 | aligner: DiDeMoAligner 9 | num_iso_layer: 12 10 | model: 11 | model_cls: MMFusionSeparate 12 | mm_encoder_cls: 13 | video_encoder_cls: MMBertForEncoder 14 | text_encoder_cls: BertModel 15 | num_hidden_video_layers: 6 16 | eval: 17 | save_path: runs/task/didemo_zs/eval 18 | fairseq: 19 | # read code and find what is the checkpoint arg. 20 | common_eval: 21 | path: runs/task/checkpoint_best.pt 22 | metric: DiDeMoMetric 23 | predictor: DiDeMoPredictor 24 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/test_vtt.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/test.yaml 2 | dataset: 3 | meta_processor: MSRVTTMetaProcessor 4 | test_path: data/msrvtt/MSRVTT_JSFUSION_test.csv 5 | video_processor: VideoProcessor 6 | vfeat_dir: data/feat/feat_vtt_s3d 7 | text_processor: MSRVTTTextProcessor 8 | num_iso_layer: 12 9 | model: 10 | model_cls: MMFusionJoint 11 | mm_encoder_cls: MMBertForJoint 12 | eval: 13 | save_path: runs/task/vtt/eval 14 | fairseq: 15 | # read code and find what is the checkpoint arg. 16 | common_eval: 17 | path: runs/task/vtt/checkpoint_last.pt 18 | metric: RetrievalMetric 19 | predictor: RetrievalPredictor 20 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/test_vtt_videoclip.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/test_vtt.yaml 2 | model: 3 | model_cls: MMFusionSeparate 4 | mm_encoder_cls: 5 | video_encoder_cls: MMBertForEncoder 6 | text_encoder_cls: BertModel 7 | num_hidden_video_layers: 6 8 | 9 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/test_vtt_zs.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/test_vtt.yaml 2 | model: 3 | model_cls: MMFusionSeparate 4 | mm_encoder_cls: 5 | video_encoder_cls: MMBertForEncoder 6 | text_encoder_cls: BertModel 7 | num_hidden_video_layers: 6 8 | eval: 9 | save_path: runs/task/vtt_zs/eval 10 | fairseq: 11 | # read code and find what is the checkpoint arg. 12 | common_eval: 13 | path: runs/task/checkpoint_best.pt 14 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/test_vttqa.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/test.yaml 2 | dataset: 3 | meta_processor: MSRVTTQAMetaProcessor 4 | test_path: data/msrvtt-qa/MSR_MC_test.csv 5 | video_processor: VideoProcessor 6 | vfeat_dir: data/feat/feat_vtt_s3d 7 | text_processor: MSRVTTQATextProcessor 8 | aligner: MSRVTTQAAligner 9 | num_iso_layer: 12 10 | model: 11 | model_cls: MMFusionJoint 12 | mm_encoder_cls: MMBertForJoint 13 | eval: 14 | save_path: runs/task/vttqa/eval 15 | fairseq: 16 | # read code and find what is the checkpoint arg. 17 | common_eval: 18 | path: runs/task/vttqa/checkpoint_last.pt 19 | metric: QAMetric 20 | predictor: QAPredictor 21 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/test_vttqa_videoclip.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/test_vttqa.yaml 2 | model: 3 | model_cls: MMFusionSeparate 4 | mm_encoder_cls: 5 | video_encoder_cls: MMBertForEncoder 6 | text_encoder_cls: BertModel 7 | num_hidden_video_layers: 6 8 | 9 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/test_vttqa_zs.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/test_vttqa.yaml 2 | model: 3 | model_cls: MMFusionSeparate 4 | mm_encoder_cls: 5 | video_encoder_cls: MMBertForEncoder 6 | text_encoder_cls: BertModel 7 | num_hidden_video_layers: 6 8 | eval: 9 | save_path: runs/task/vttqa_zs/eval 10 | fairseq: 11 | # read code and find what is the checkpoint arg. 12 | common_eval: 13 | path: runs/task/checkpoint_best.pt 14 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/test_youcook.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/test.yaml 2 | dataset: 3 | meta_processor: YoucookMetaProcessor 4 | test_path: data/youcook/youcook_val.pkl 5 | trainval_annotation: data/youcook/youcookii_annotations_trainval.json 6 | use_annotation_text: True 7 | video_processor: YoucookVideoProcessor 8 | vfeat_dir: data/feat/feat_youcook_s3d # /checkpoint/huxu/feat/youcook_vmz # /checkpoint/prarora/berniehuang/feat_youcook_vmz 9 | text_processor: TextProcessor 10 | aligner: DSAligner 11 | num_iso_layer: 12 12 | model: 13 | model_cls: MMFusionJoint 14 | mm_encoder_cls: MMBertForJoint 15 | eval: 16 | save_path: runs/task/youcook/eval 17 | fairseq: 18 | # read code and find what is the checkpoint arg. 19 | common_eval: 20 | path: runs/task/youcook/checkpoint_last.pt 21 | metric: RetrievalMetric 22 | predictor: RetrievalPredictor 23 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/test_youcook_videoclip.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/test_youcook.yaml 2 | model: 3 | model_cls: MMFusionSeparate 4 | mm_encoder_cls: 5 | video_encoder_cls: MMBertForEncoder 6 | text_encoder_cls: BertModel 7 | num_hidden_video_layers: 6 8 | 9 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/test_youcook_zs.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/test_youcook.yaml 2 | model: 3 | model_cls: MMFusionSeparate 4 | mm_encoder_cls: 5 | video_encoder_cls: MMBertForEncoder 6 | text_encoder_cls: BertModel 7 | num_hidden_video_layers: 6 8 | eval: 9 | save_path: runs/task/youcook_zs/eval 10 | fairseq: 11 | # read code and find what is the checkpoint arg. 12 | common_eval: 13 | path: runs/task/checkpoint_best.pt 14 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/test_youcookcap.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/test.yaml 2 | dataset: 3 | meta_processor: YoucookNLGMetaProcessor 4 | test_path: data/youcook/val_list.txt 5 | trainval_annotation: data/youcook/youcookii_annotations_trainval.json 6 | video_processor: YoucookVideoProcessor 7 | vfeat_dir: data/feat/feat_youcook_s3d 8 | text_processor: NLGTextProcessor 9 | aligner: DSNLGAligner 10 | model: 11 | model_cls: MMFusionNLG 12 | mm_encoder_cls: MMBertForNLG 13 | max_decode_length: 24 14 | eval: 15 | save_path: runs/task/youcookcap/eval 16 | fairseq: 17 | # read code and find what is the checkpoint arg. 18 | common_eval: 19 | path: runs/task/youcookcap/checkpoint_best.pt 20 | metric: NLGMetric 21 | predictor: NLGPredictor 22 | gen_param: 23 | num_beams: 5 24 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/vtt.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/ft.yaml 2 | dataset: 3 | meta_processor: MSRVTTMetaProcessor 4 | train_path: data/msrvtt/MSRVTT_train.csv 5 | jsfusion_path: data/msrvtt/MSRVTT_JSFUSION_test.csv 6 | full_test_path: data/msrvtt/MSRVTT_FULL_test.csv 7 | dup: 20 8 | val_path: data/msrvtt/MSRVTT_JSFUSION_test.csv 9 | vfeat_dir: data/feat/feat_vtt_s3d 10 | text_processor: MSRVTTTextProcessor 11 | json_path: data/msrvtt/MSRVTT_data.json 12 | aligner: DSAligner 13 | num_iso_layer: 12 14 | model: 15 | model_cls: MMFusionJoint 16 | mm_encoder_cls: MMBertForJoint 17 | loss: 18 | loss_cls: T2VContraLoss 19 | fairseq: 20 | dataset: 21 | batch_size: 256 22 | optimization: 23 | max_epoch: 10 24 | checkpoint: 25 | save_dir: runs/task/vtt 26 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/vtt_videoclip.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/vtt.yaml 2 | model: 3 | model_cls: MMFusionSeparate 4 | mm_encoder_cls: 5 | video_encoder_cls: MMBertForEncoder 6 | text_encoder_cls: BertModel 7 | num_hidden_video_layers: 6 8 | fairseq: 9 | dataset: 10 | batch_size: 224 11 | # model_cls: MMFusionShare 12 | # mm_encoder_cls: MMBertForEncoder 13 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/vttqa.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/ft.yaml 2 | dataset: 3 | meta_processor: MSRVTTMetaProcessor 4 | train_path: data/msrvtt/MSRVTT_train.csv 5 | dup: 20 6 | val_path: data/msrvtt/MSRVTT_JSFUSION_test.csv 7 | vfeat_dir: data/feat/feat_vtt_s3d 8 | text_processor: MSRVTTTextProcessor 9 | json_path: data/msrvtt/MSRVTT_data.json 10 | aligner: DSAligner 11 | num_iso_layer: 12 12 | model: 13 | model_cls: MMFusionJoint 14 | mm_encoder_cls: MMBertForJoint 15 | loss: 16 | loss_cls: V2TContraLoss 17 | fairseq: 18 | dataset: 19 | batch_size: 128 20 | optimization: 21 | max_epoch: 5 22 | checkpoint: 23 | save_dir: runs/task/vttqa 24 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/vttqa_videoclip.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/vttqa.yaml 2 | model: 3 | model_cls: MMFusionSeparate 4 | mm_encoder_cls: 5 | video_encoder_cls: MMBertForEncoder 6 | text_encoder_cls: BertModel 7 | num_hidden_video_layers: 6 8 | 9 | # model_cls: MMFusionShare 10 | # mm_encoder_cls: MMBertForEncoder 11 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/youcook.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/ft.yaml 2 | dataset: 3 | meta_processor: YoucookMetaProcessor 4 | train_path: data/youcook/youcook_train.pkl 5 | val_path: data/youcook/youcook_val.pkl 6 | trainval_annotation: data/youcook/youcookii_annotations_trainval.json 7 | use_annotation_text: True 8 | video_processor: YoucookVideoProcessor 9 | vfeat_dir: data/feat/feat_youcook_s3d # /checkpoint/huxu/feat/youcook_vmz # /checkpoint/prarora/berniehuang/feat_youcook_vmz 10 | text_processor: TextProcessor 11 | aligner: DSAligner 12 | num_iso_layer: 12 13 | model: 14 | model_cls: MMFusionJoint 15 | mm_encoder_cls: MMBertForJoint 16 | loss: 17 | loss_cls: T2VContraLoss 18 | fairseq: 19 | dataset: 20 | batch_size: 128 21 | optimization: 22 | max_epoch: 10 23 | checkpoint: 24 | save_dir: runs/task/youcook 25 | 26 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/youcook_videoclip.yaml: -------------------------------------------------------------------------------- 1 | includes: projects/task/youcook.yaml 2 | model: 3 | model_cls: MMFusionSeparate 4 | mm_encoder_cls: 5 | video_encoder_cls: MMBertForEncoder 6 | text_encoder_cls: BertModel 7 | num_hidden_video_layers: 6 8 | # model_cls: MMFusionShare 9 | # mm_encoder_cls: MMBertForEncoder 10 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/projects/task/youcookcap.yaml: -------------------------------------------------------------------------------- 1 | # finetuning for youcook captioning. 2 | includes: projects/task/ft.yaml 3 | dataset: 4 | meta_processor: YoucookNLGMetaProcessor 5 | train_path: data/youcook/train_list.txt 6 | val_path: data/youcook/val_list.txt 7 | trainval_annotation: data/youcook/youcookii_annotations_trainval.json 8 | video_processor: YoucookVideoProcessor 9 | vfeat_dir: data/feat/feat_youcook_s3d 10 | text_processor: NLGTextProcessor 11 | aligner: DSNLGAligner 12 | model: 13 | model_cls: MMFusionNLG 14 | mm_encoder_cls: MMBertForNLG 15 | loss: 16 | loss_cls: NLGLoss 17 | fairseq: 18 | dataset: 19 | batch_size: 128 20 | optimization: 21 | max_epoch: 10 22 | checkpoint: 23 | save_dir: runs/task/youcookcap 24 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/scripts/text_token_extractor/configs/bert-base-uncased.yaml: -------------------------------------------------------------------------------- 1 | dataset: 2 | bert_name: bert-base-uncased 3 | caption_pkl_path: data/how2/raw_caption_dedup.pkl 4 | use_fast: true 5 | target_dir: data/feat/feat_how2_s3d_shard_small 6 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/scripts/video_feature_extractor/how2/s3d.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | python scripts/video_feature_extractor/extract.py \ 5 | --vdir \ 6 | --fdir data/feat/feat_how2_s3d \ 7 | --type=s3d --num_decoding_thread=4 \ 8 | --batch_size 32 --half_precision 1 9 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/setup.py: -------------------------------------------------------------------------------- 1 | import setuptools 2 | 3 | with open("README.md", "r") as fh: 4 | long_description = fh.read() 5 | 6 | setuptools.setup( 7 | name="mmpt", 8 | version="0.0.1", 9 | author="Hu Xu, Po-yao Huang", 10 | author_email="huxu@fb.com", 11 | description="A package for multimodal pretraining.", 12 | long_description=long_description, 13 | long_description_content_type="text/markdown", 14 | url="https://github.com/pytorch/fairseq/examples/MMPT", 15 | packages=setuptools.find_packages(), 16 | install_requires=[ 17 | ], 18 | classifiers=[ 19 | "Programming Language :: Python :: 3", 20 | "License :: CC-BY-NC", 21 | "Operating System :: OS Independent", 22 | ], 23 | python_requires='>=3.6', 24 | ) 25 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/videoclip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/MMPT/videoclip.png -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/MMPT/vlm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/MMPT/vlm.png -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | try: 7 | from fairseq.version import __version__ # noqa 8 | except ImportError: 9 | pass 10 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/adaptive_span/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import importlib 7 | import os 8 | 9 | # automatically import any Python files in the current directory 10 | cur_dir = os.path.dirname(__file__) 11 | for file in os.listdir(cur_dir): 12 | path = os.path.join(cur_dir, file) 13 | if ( 14 | not file.startswith("_") 15 | and not file.startswith(".") 16 | and (file.endswith(".py") or os.path.isdir(path)) 17 | ): 18 | mod_name = file[: file.find(".py")] if file.endswith(".py") else file 19 | module = importlib.import_module(__name__ + "." + mod_name) 20 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/adaptive_span/truncated_bptt_lm_task.py: -------------------------------------------------------------------------------- 1 | ../truncated_bptt/truncated_bptt_lm_task.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/attention_head_selection/src/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/attention_head_selection/src/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/attention_head_selection/src/data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/attention_head_selection/src/data/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/attention_head_selection/src/loss/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/attention_head_selection/src/loss/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/attention_head_selection/src/models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/attention_head_selection/src/models/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/attention_head_selection/src/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/attention_head_selection/src/modules/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/constrained_decoding/normalize.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) Facebook, Inc. and its affiliates. 4 | # 5 | # This source code is licensed under the MIT license found in the 6 | # LICENSE file in the root directory of this source tree. 7 | 8 | import sys 9 | 10 | from sacremoses.normalize import MosesPunctNormalizer 11 | 12 | 13 | def main(args): 14 | normalizer = MosesPunctNormalizer(lang=args.lang, penn=args.penn) 15 | for line in sys.stdin: 16 | print(normalizer.normalize(line.rstrip()), flush=True) 17 | 18 | 19 | if __name__ == "__main__": 20 | import argparse 21 | 22 | parser = argparse.ArgumentParser() 23 | parser.add_argument("--lang", "-l", default="en") 24 | parser.add_argument("--penn", "-p", action="store_true") 25 | args = parser.parse_args() 26 | 27 | main(args) 28 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/data2vec/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/config/audio/pretraining/run_config/local.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | hydra: 3 | sweep: 4 | dir: ${env:PWD}/tmp_dbg/${now:%H-%M-%S} 5 | 6 | distributed_training: 7 | distributed_world_size: 1 8 | nprocs_per_node: 1 9 | distributed_port: -1 10 | 11 | common: 12 | log_interval: 1 13 | 14 | dataset: 15 | num_workers: 0 16 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/config/text/pretraining/run_config/local.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | hydra: 3 | sweep: 4 | dir: ${env:PWD}/tmp_dbg/${now:%H-%M-%S} 5 | 6 | distributed_training: 7 | distributed_world_size: 1 8 | nprocs_per_node: 1 9 | distributed_port: -1 10 | 11 | common: 12 | log_interval: 1 13 | 14 | dataset: 15 | num_workers: 0 16 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/config/v2/run_config/local.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | hydra: 3 | sweep: 4 | dir: ${env:PWD}/tmp_dbg/${now:%H-%M-%S} 5 | 6 | distributed_training: 7 | distributed_world_size: 1 8 | nprocs_per_node: 1 9 | distributed_port: -1 10 | 11 | common: 12 | log_interval: 1 13 | 14 | dataset: 15 | num_workers: 0 16 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/config/v2/text_finetuning/run_config/local.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | hydra: 3 | sweep: 4 | dir: ${env:PWD}/tmp_dbg/${now:%H-%M-%S} 5 | 6 | distributed_training: 7 | distributed_world_size: 1 8 | nprocs_per_node: 1 9 | distributed_port: -1 10 | 11 | common: 12 | log_interval: 1 13 | 14 | dataset: 15 | num_workers: 0 16 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/config/vision/finetuning/run_config/local.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | hydra: 3 | sweep: 4 | dir: ${env:PWD}/tmp_dbg/${now:%H-%M-%S} 5 | 6 | distributed_training: 7 | distributed_world_size: 1 8 | nprocs_per_node: 1 9 | distributed_port: -1 10 | 11 | common: 12 | log_interval: 1 13 | 14 | dataset: 15 | num_workers: 0 16 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/config/vision/pretraining/run_config/local.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | hydra: 3 | sweep: 4 | dir: ${env:PWD}/tmp_dbg/${now:%H-%M-%S} 5 | 6 | distributed_training: 7 | distributed_world_size: 1 8 | nprocs_per_node: 1 9 | distributed_port: -1 10 | 11 | common: 12 | log_interval: 1 13 | 14 | dataset: 15 | num_workers: 0 16 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/data/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .image_dataset import ImageDataset 7 | from .path_dataset import PathDataset 8 | from .mae_image_dataset import MaeImageDataset 9 | from .mae_finetuning_image_dataset import MaeFinetuningImageDataset 10 | 11 | 12 | __all__ = [ 13 | "ImageDataset", 14 | "MaeImageDataset", 15 | "MaeFinetuningImageDataset", 16 | "PathDataset", 17 | ] -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/data/modality.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-present, Facebook, Inc. 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the license found in the LICENSE file in 5 | # the root directory of this source tree. An additional grant of patent rights 6 | # can be found in the PATENTS file in the same directory. 7 | 8 | from enum import Enum, auto 9 | 10 | 11 | class Modality(Enum): 12 | AUDIO = auto() 13 | IMAGE = auto() 14 | TEXT = auto() 15 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/data2vec/models/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/models/modalities/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/data2vec/models/modalities/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/scripts/multi/finetune_all_fair_aws_local_lr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | job_id="$1" 6 | task_id="$2" 7 | dir="$3" 8 | 9 | echo "job_id: $job_id, task_id: $task_id, dir: $dir" 10 | 11 | mkdir -p "$dir/log" 12 | sbatch_args="-p wav2vec --nodes=1 --ntasks-per-node=1" 13 | sbatch_args="$sbatch_args --gpus-per-node=1 --cpus-per-task=8 --mem=0 --time=24:00:00" 14 | sbatch_args="$sbatch_args -d afterok:$job_id -o $dir/log/decode_sweep_%A.out" 15 | sbatch_args="$sbatch_args -e $dir/log/decode_sweep_%A.err" 16 | 17 | sbatch $sbatch_args examples/data2vec/scripts/multi/finetune_all_fair_local_lr.sh $dir 18 | 19 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/scripts/multi/finetune_all_fair_aws_local_lr_nodep.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | dir="$1" 6 | 7 | echo "dir: $dir" 8 | 9 | mkdir -p "$dir/log" 10 | sbatch_args="-p wav2vec --nodes=1 --ntasks-per-node=1" 11 | sbatch_args="$sbatch_args --gpus-per-node=1 --cpus-per-task=8 --mem=0 --time=24:00:00" 12 | sbatch_args="$sbatch_args -o $dir/log/decode_sweep_%A.out" 13 | sbatch_args="$sbatch_args -e $dir/log/decode_sweep_%A.err" 14 | 15 | sbatch $sbatch_args examples/data2vec/scripts/multi/finetune_all_fair_local_lr.sh $dir 16 | 17 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/scripts/text/finetune_all_char_fair_aws_local_lr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | job_id="$1" 6 | task_id="$2" 7 | dir="$3" 8 | 9 | echo "job_id: $job_id, task_id: $task_id, dir: $dir" 10 | 11 | mkdir -p "$dir/log" 12 | sbatch_args="-p wav2vec --nodes=1 --ntasks-per-node=1" 13 | sbatch_args="$sbatch_args --gpus-per-node=1 --cpus-per-task=8 --mem=0 --time=24:00:00" 14 | sbatch_args="$sbatch_args -d afterok:$job_id -o $dir/log/ft_%A.out" 15 | sbatch_args="$sbatch_args -e $dir/log/ft_%A.err" 16 | 17 | sbatch $sbatch_args examples/data2vec/scripts/text/finetune_all_char_fair_local_lr.sh $dir 18 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/scripts/text/finetune_all_fair_aws_local_lr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | job_id="$1" 6 | task_id="$2" 7 | dir="$3" 8 | 9 | echo "job_id: $job_id, task_id: $task_id, dir: $dir" 10 | 11 | mkdir -p "$dir/log" 12 | sbatch_args="-p wav2vec --nodes=1 --ntasks-per-node=1" 13 | sbatch_args="$sbatch_args --gpus-per-node=1 --cpus-per-task=8 --mem=0 --time=24:00:00" 14 | sbatch_args="$sbatch_args -d afterok:$job_id -o $dir/log/decode_sweep_%A.out" 15 | sbatch_args="$sbatch_args -e $dir/log/decode_sweep_%A.err" 16 | 17 | sbatch $sbatch_args examples/data2vec/scripts/text/finetune_all_fair_local_lr.sh $dir 18 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/scripts/text/finetune_all_fair_nodep.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | dir="$1" 4 | cp="$dir/checkpoints/checkpoint_last.pt" 5 | 6 | echo "dir: $dir" 7 | 8 | declare -A tasks 9 | tasks[cola]="/private/home/jgu/data/GLUE/CoLA-bin" 10 | tasks[qnli]="/private/home/jgu/data/GLUE/QNLI-bin" 11 | tasks[mrpc]="/private/home/jgu/data/GLUE/MRPC-bin" 12 | tasks[rte]="/private/home/jgu/data/GLUE/RTE-bin" 13 | tasks[sst_2]="/private/home/jgu/data/GLUE/SST-2-bin" 14 | 15 | for task data_path in ${(kv)tasks}; do 16 | PYTHONPATH=. PREFIX="${PREFIX}" SUFFIX="" nohup python fairseq_cli/hydra_train.py -m --config-dir examples/roberta/config/finetuning \ 17 | --config-name $task hydra/launcher=submitit_slurm +run_config=slurm_1g task.data="$data_path" hydra.launcher.name=finetune_${task}_${PREFIX} \ 18 | checkpoint.restore_file="$cp" hydra.sweep.dir="$dir/finetune/$task" & 19 | done 20 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/scripts/text/finetune_all_fair_nodep_aws.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | dir="$1" 4 | cp="$dir/checkpoints/checkpoint_last.pt" 5 | 6 | echo "dir: $dir" 7 | 8 | declare -A tasks 9 | tasks[cola]="/fsx-wav2vec/abaevski/data/nlp/GLUE/CoLA-bin" 10 | tasks[qnli]="/fsx-wav2vec/abaevski/data/nlp/GLUE/QNLI-bin" 11 | tasks[mrpc]="/fsx-wav2vec/abaevski/data/nlp/GLUE/MRPC-bin" 12 | tasks[rte]="/fsx-wav2vec/abaevski/data/nlp/GLUE/RTE-bin" 13 | tasks[sst_2]="/fsx-wav2vec/abaevski/data/nlp/GLUE/SST-2-bin" 14 | 15 | for task data_path in ${(kv)tasks}; do 16 | PYTHONPATH=. PREFIX="${PREFIX}" SUFFIX="" nohup python fairseq_cli/hydra_train.py -m --config-dir examples/roberta/config/finetuning \ 17 | --config-name $task hydra/launcher=submitit_slurm +run_config=slurm_1g_aws task.data="$data_path" hydra.launcher.name=finetune_${task}_${PREFIX} \ 18 | checkpoint.restore_file="$cp" hydra.sweep.dir="$dir/finetune/$task" & 19 | done 20 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/scripts/text/finetune_all_fair_nodep_aws_local_lr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | dir="$1" 6 | 7 | echo "dir: $dir" 8 | 9 | mkdir -p "$dir/log" 10 | sbatch_args="-p wav2vec --nodes=1 --ntasks-per-node=1" 11 | sbatch_args="$sbatch_args --gpus-per-node=1 --cpus-per-task=8 --mem=0 --time=24:00:00" 12 | sbatch_args="$sbatch_args -o $dir/log/decode_sweep_%A.out" 13 | sbatch_args="$sbatch_args -e $dir/log/decode_sweep_%A.err" 14 | 15 | sbatch $sbatch_args examples/data2vec/scripts/text/finetune_all_fair_local_lr.sh $dir 16 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/scripts/text/finetune_all_large_fair_aws_local_lr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | job_id="$1" 6 | task_id="$2" 7 | dir="$3" 8 | 9 | echo "job_id: $job_id, task_id: $task_id, dir: $dir" 10 | 11 | mkdir -p "$dir/log" 12 | sbatch_args="-p wav2vec --nodes=1 --ntasks-per-node=1" 13 | sbatch_args="$sbatch_args --gpus-per-node=1 --cpus-per-task=8 --mem=0 --time=24:00:00" 14 | sbatch_args="$sbatch_args -d afterok:$job_id -o $dir/log/decode_sweep_%A.out" 15 | sbatch_args="$sbatch_args -e $dir/log/decode_sweep_%A.err" 16 | 17 | sbatch $sbatch_args examples/data2vec/scripts/text/finetune_all_large_fair_local_lr.sh $dir 18 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/scripts/text/finetune_all_large_fair_nodep_aws_local_lr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | dir="$1" 6 | 7 | echo "dir: $dir" 8 | 9 | mkdir -p "$dir/log" 10 | sbatch_args="-p wav2vec --nodes=1 --ntasks-per-node=1" 11 | sbatch_args="$sbatch_args --gpus-per-node=1 --cpus-per-task=8 --mem=0 --time=24:00:00" 12 | sbatch_args="$sbatch_args -o $dir/log/decode_sweep_%A.out" 13 | sbatch_args="$sbatch_args -e $dir/log/decode_sweep_%A.err" 14 | 15 | sbatch $sbatch_args examples/data2vec/scripts/text/finetune_all_large_fair_local_lr.sh $dir 16 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/scripts/text/finetune_sst2_qnli_sweep_fair_nodep.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | dir="$1" 4 | cp="$dir/checkpoints/checkpoint_last.pt" 5 | 6 | echo "dir: $dir" 7 | 8 | declare -A tasks 9 | tasks[qnli]="/private/home/jgu/data/GLUE/QNLI-bin" 10 | tasks[sst_2]="/private/home/jgu/data/GLUE/SST-2-bin" 11 | 12 | lrs="5e-6 1e-5 2e-5 5e-5 1e-4 2e-4 5e-4 1e-3" 13 | 14 | for task data_path in ${(kv)tasks}; do 15 | for lr in $(echo "$lrs"); do 16 | PYTHONPATH=. PREFIX="${PREFIX}" SUFFIX="" nohup python fairseq_cli/hydra_train.py -m --config-dir examples/roberta/config/finetuning \ 17 | --config-name $task hydra/launcher=submitit_slurm +run_config=slurm_1g task.data="$data_path" hydra.launcher.name=finetune_${task}_${PREFIX} \ 18 | checkpoint.restore_file="$cp" hydra.sweep.dir="$dir/finetune_sweep/$task/lr_$lr" "optimization.lr=[${lr}]" & 19 | done 20 | done 21 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/data2vec/tasks/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .image_pretraining import ImagePretrainingTask, ImagePretrainingConfig 7 | from .image_classification import ImageClassificationTask, ImageClassificationConfig 8 | from .mae_image_pretraining import MaeImagePretrainingTask, MaeImagePretrainingConfig 9 | 10 | 11 | __all__ = [ 12 | "ImageClassificationTask", 13 | "ImageClassificationConfig", 14 | "ImagePretrainingTask", 15 | "ImagePretrainingConfig", 16 | "MaeImagePretrainingTask", 17 | "MaeImagePretrainingConfig", 18 | ] -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/discriminative_reranking_nmt/__init__.py: -------------------------------------------------------------------------------- 1 | from . import criterions, models, tasks # noqa 2 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/discriminative_reranking_nmt/criterions/__init__.py: -------------------------------------------------------------------------------- 1 | from .discriminative_reranking_criterion import KLDivergenceRerankingCriterion 2 | 3 | 4 | __all__ = [ 5 | "KLDivergenceRerankingCriterion", 6 | ] 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/discriminative_reranking_nmt/models/__init__.py: -------------------------------------------------------------------------------- 1 | from .discriminative_reranking_model import DiscriminativeNMTReranker 2 | 3 | 4 | __all__ = [ 5 | "DiscriminativeNMTReranker", 6 | ] 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/discriminative_reranking_nmt/tasks/__init__.py: -------------------------------------------------------------------------------- 1 | from .discriminative_reranking_task import DiscriminativeRerankingNMTTask 2 | 3 | 4 | __all__ = [ 5 | "DiscriminativeRerankingNMTTask", 6 | ] 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/emotion_conversion/emotion_models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/emotion_conversion/emotion_models/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/emotion_conversion/preprocess/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/emotion_conversion/preprocess/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/emotion_conversion/requirements.txt: -------------------------------------------------------------------------------- 1 | scipy 2 | einops 3 | amfm_decompy 4 | joblib 5 | numba 6 | decorator 7 | requests 8 | appdirs 9 | packaging 10 | six 11 | sklearn 12 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/fast_noisy_channel/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from . import noisy_channel_translation # noqa 7 | from . import noisy_channel_sequence_generator # noqa 8 | from . import noisy_channel_beam_search # noqa 9 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/flores101/flores_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/flores101/flores_logo.png -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/hubert/config/decode/infer_viterbi.yaml: -------------------------------------------------------------------------------- 1 | # @package _group_ 2 | 3 | defaults: 4 | - model: null 5 | 6 | hydra: 7 | run: 8 | dir: ${common_eval.results_path}/viterbi 9 | sweep: 10 | dir: ${common_eval.results_path} 11 | subdir: viterbi 12 | 13 | task: 14 | _name: hubert_pretraining 15 | single_target: true 16 | fine_tuning: true 17 | data: ??? 18 | normalize: ??? 19 | 20 | decoding: 21 | type: viterbi 22 | unique_wer_file: true 23 | common_eval: 24 | results_path: ??? 25 | path: ??? 26 | post_process: letter 27 | dataset: 28 | max_tokens: 1100000 29 | gen_subset: ??? 30 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/hubert/config/decode/run/submitit_slurm.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | hydra: 3 | launcher: 4 | cpus_per_task: ${distributed_training.distributed_world_size} 5 | gpus_per_node: ${distributed_training.distributed_world_size} 6 | tasks_per_node: ${hydra.launcher.gpus_per_node} 7 | nodes: 1 8 | mem_gb: 200 9 | timeout_min: 4320 10 | max_num_timeout: 50 11 | name: ${hydra.job.config_name} 12 | submitit_folder: ${hydra.sweep.dir}/submitit 13 | 14 | distributed_training: 15 | distributed_world_size: 1 16 | distributed_no_spawn: true 17 | distributed_port: 29761 18 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/hubert/config/decode/run/submitit_slurm_8gpu.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | hydra: 3 | launcher: 4 | cpus_per_task: ${distributed_training.distributed_world_size} 5 | gpus_per_node: ${distributed_training.distributed_world_size} 6 | tasks_per_node: ${hydra.launcher.gpus_per_node} 7 | nodes: 1 8 | mem_gb: 200 9 | timeout_min: 4320 10 | max_num_timeout: 50 11 | name: ${hydra.job.config_name} 12 | submitit_folder: ${hydra.sweep.dir}/submitit 13 | 14 | distributed_training: 15 | distributed_world_size: 8 16 | distributed_no_spawn: true 17 | distributed_port: 29761 18 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/hubert/config/finetune/ckpt/it1.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | 3 | task: 4 | normalize: false 5 | 6 | model: 7 | w2v_path: /checkpoint/wnhsu/w2v/hubert_final/iter1/hubert.km.randcrop.pmw1_0.puw0_0.grpnorm.ml10.mp0_8.untie.mxsz250000.ufreq1.maxtok1400000.MU400k.s1337.ngpu32/checkpoint_last.pt 8 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/hubert/config/finetune/lm/ls_4gram.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | 3 | criterion: 4 | wer_kenlm_model: /checkpoint/abdo/old_checkpoint02/datasets/librispeech/4-gram.bin 5 | wer_lexicon: /checkpoint/abdo/old_checkpoint02/datasets/librispeech/10h/raw/lexicon_ltr.lst 6 | wer_lm_weight: 2.0 7 | wer_word_score: -1.0 8 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/hubert/config/finetune/run/submitit_reg.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | 3 | hydra: 4 | launcher: 5 | cpus_per_task: 8 6 | gpus_per_node: 8 7 | tasks_per_node: ${hydra.launcher.gpus_per_node} 8 | nodes: 1 9 | comment: null 10 | mem_gb: 384 11 | timeout_min: 4320 12 | max_num_timeout: 100 13 | constraint: volta32gb 14 | name: ${hydra.job.config_name}/${hydra.job.override_dirname} 15 | submitit_folder: ${hydra.sweep.dir}/submitit/%j 16 | 17 | distributed_training: 18 | distributed_world_size: 8 19 | distributed_port: 29671 20 | nprocs_per_node: 8 21 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/hubert/config/pretrain/data/iter1.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | 3 | task: 4 | label_dir: ??? 5 | labels: ["km"] 6 | 7 | model: 8 | label_rate: 100 9 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/hubert/config/pretrain/data/iter2.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | 3 | task: 4 | label_dir: ??? 5 | labels: ["km"] 6 | 7 | model: 8 | label_rate: 50 9 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/hubert/config/pretrain/run/submitit_reg.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | 3 | hydra: 4 | launcher: 5 | cpus_per_task: 8 6 | gpus_per_node: 8 7 | tasks_per_node: ${hydra.launcher.gpus_per_node} 8 | nodes: 4 9 | comment: null 10 | mem_gb: 384 11 | timeout_min: 4320 12 | max_num_timeout: 100 13 | constraint: volta32gb 14 | name: ${hydra.job.config_name}/${hydra.job.override_dirname} 15 | submitit_folder: ${hydra.sweep.dir}/submitit/%j 16 | 17 | distributed_training: 18 | distributed_world_size: 32 19 | distributed_port: 29671 20 | nprocs_per_node: 8 21 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/hubert/tests/6313-76958-0021.flac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/hubert/tests/6313-76958-0021.flac -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/hubert/tests/sample.base.L9.len: -------------------------------------------------------------------------------- 1 | 596 2 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/hubert/tests/sample.base.L9.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/hubert/tests/sample.base.L9.npy -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/hubert/tests/sample.large.L20.len: -------------------------------------------------------------------------------- 1 | 596 2 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/hubert/tests/sample.large.L20.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/hubert/tests/sample.large.L20.npy -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/hubert/tests/sample.large.hypo.word: -------------------------------------------------------------------------------- 1 | KEEP A GOING AN IF YOU'RE LUCKY YOU'LL RUN PLUMB INTO THEM WAS THE JEERING ANSWER AS THE SLEEPY COWMEN SPURRED THEIR PONIES ON TOWARD CAMP MUTTERING THEIR DISAPPROVAL OF TAKING ALONG A BUNCH OF BOYS ON A CATTLE DRIVE (None-0) 2 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/hubert/tests/sample.xlarge.L30.len: -------------------------------------------------------------------------------- 1 | 596 2 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/hubert/tests/sample.xlarge.L30.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/hubert/tests/sample.xlarge.L30.npy -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/hubert/tests/sample.xlarge.hypo.word: -------------------------------------------------------------------------------- 1 | KEEP A GOIN AND IF YOU'RE LUCKY YOU'LL RUN PLUMB INTO THEM WAS THE JEERING ANSWER AS THE SLEEPY COWMEN SPURRED THEIR PONIES ON TOWARD CAMP MUTTERING THEIR DISAPPROVAL OF TAKING ALONG A BUNCH OF BOYS ON A CATTLE DRIVE (None-0) 2 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/laser/laser_src/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .laser_task import * # noqa 7 | from .laser_lstm import * # noqa 8 | from .laser_transformer import * # noqa 9 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/latent_depth/latent_depth_src/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from . import multilingual_translation_latent_depth # noqa 7 | from .loss import latent_depth # noqa 8 | from .models import latent_multilingual_transformer # noqa 9 | from .modules import latent_layers # noqa 10 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/latent_depth/latent_depth_src/loss/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/latent_depth/latent_depth_src/loss/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/latent_depth/latent_depth_src/models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/latent_depth/latent_depth_src/models/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/latent_depth/latent_depth_src/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/latent_depth/latent_depth_src/modules/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/linformer/README.md: -------------------------------------------------------------------------------- 1 | # Linformer: Self-Attention with Linear Complexity (Wang et al., 2020) 2 | 3 | This example contains code to train Linformer models as described in our paper 4 | [Linformer: Self-Attention with Linear Complexity](https://arxiv.org/abs/2006.04768). 5 | 6 | ## Training a new Linformer RoBERTa model 7 | 8 | You can mostly follow the [RoBERTa pretraining README](/examples/roberta/README.pretraining.md), 9 | updating your training command with `--user-dir examples/linformer/linformer_src --arch linformer_roberta_base`. 10 | 11 | ## Citation 12 | 13 | If you use our work, please cite: 14 | 15 | ```bibtex 16 | @article{wang2020linformer, 17 | title={Linformer: Self-Attention with Linear Complexity}, 18 | author={Wang, Sinong and Li, Belinda and Khabsa, Madian and Fang, Han and Ma, Hao}, 19 | journal={arXiv preprint arXiv:2006.04768}, 20 | year={2020} 21 | } 22 | ``` 23 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/linformer/linformer_src/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .models import linformer_roberta # noqa 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/linformer/linformer_src/models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/linformer/linformer_src/models/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/linformer/linformer_src/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/linformer/linformer_src/modules/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/m2m_100/tokenizers/README.md: -------------------------------------------------------------------------------- 1 | # M2M-100 Tokenization 2 | 3 | We apply different tokenization strategies for different languages following the existing literature. Here we provide tok.sh a tokenizer that can be used to reproduce our results. 4 | 5 | To reproduce the results, follow these steps: 6 | 7 | ``` 8 | tgt_lang=... 9 | reference_translation=... 10 | cat generation_output | grep -P "^H" | sort -V | cut -f 3- | sh tok.sh $tgt_lang > hyp 11 | cat $reference_translation |sh tok.sh $tgt_lang > ref 12 | sacrebleu -tok 'none' ref < hyp 13 | ``` 14 | 15 | ## Installation 16 | 17 | Tools needed for all the languages except Arabic can be installed by running install_dependencies.sh 18 | If you want to evaluate Arabic models, please follow the instructions provided here: http://alt.qcri.org/tools/arabic-normalizer/ to install 19 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/m2m_100/tokenizers/seg_ja.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | SCRIPT=`realpath $0` 7 | KYTEA=`dirname $SCRIPT`/thirdparty/kytea 8 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$KYTEA/lib:/usr/local/lib 9 | export PATH=$PATH:"$KYTEA/bin" 10 | 11 | cat - | tr -d "[:blank:]" | kytea -notags 12 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/m2m_100/tokenizers/seg_ko.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | SCRIPT=`realpath $0` 7 | MECAB=`dirname $SCRIPT`/thirdparty/mecab-0.996-ko-0.9.2 8 | 9 | export PATH=$PATH:"$MECAB/bin":"$MECAB/lib" 10 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$MECAB/lib" 11 | 12 | cat - | mecab -O wakati 13 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/m2m_100/tokenizers/thirdparty/.gitignore: -------------------------------------------------------------------------------- 1 | seg_my.py 2 | indic_nlp_library/ 3 | indic_nlp_resources/ 4 | kytea/ 5 | mecab-0.996-ko-0.9.2.tar.gz 6 | mecab-0.996-ko-0.9.2/ 7 | mosesdecoder/ 8 | wat2020.my-en.zip 9 | wat2020.my-en/ 10 | wmt16-scripts/ 11 | mecab-ko-dic-2.1.1-20180720/ 12 | mecab-ko-dic-2.1.1-20180720.tar.gz -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/m2m_100/tokenizers/tokenize_indic.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # Use: echo {text} | python tokenize_indic.py {language} 8 | 9 | import sys 10 | 11 | from indicnlp.normalize.indic_normalize import IndicNormalizerFactory 12 | from indicnlp.tokenize.indic_tokenize import trivial_tokenize 13 | 14 | 15 | factory = IndicNormalizerFactory() 16 | normalizer = factory.get_normalizer( 17 | sys.argv[1], remove_nuktas=False, nasals_mode="do_nothing" 18 | ) 19 | 20 | for line in sys.stdin: 21 | normalized_line = normalizer.normalize(line.strip()) 22 | tokenized_line = " ".join(trivial_tokenize(normalized_line, sys.argv[1])) 23 | print(tokenized_line) 24 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/m2m_100/tokenizers/tokenize_thai.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | import sys 8 | 9 | from pythainlp import word_tokenize 10 | 11 | 12 | for line in sys.stdin: 13 | print(" ".join(word_tokenize(line.strip()))) 14 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/m2m_100/tokenizers/tokenize_zh.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | 8 | import fileinput 9 | 10 | import sacrebleu 11 | 12 | 13 | for line in fileinput.input(): 14 | print(sacrebleu.tokenize_zh(line)) 15 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/m2m_100/tokenizers/tokenizer_ar.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | # 7 | # Please follow the instructions here http://alt.qcri.org/tools/arabic-normalizer/ 8 | # to install tools needed for Arabic 9 | 10 | echo "Please install Arabic tools: http://alt.qcri.org/tools/arabic-normalizer/" 11 | echo "Then update environment variables in tokenizer_ar.sh" 12 | exit 1 13 | 14 | SVMTOOL=... 15 | GOMOSESGO=... 16 | QCRI_ARABIC_NORMALIZER=... 17 | 18 | export PERL5LIB="$SVMTOOL/lib":"$GOMOSESGO/bin/MADA-3.2":$PERL5LIB 19 | 20 | 21 | tempfile=$(mktemp) 22 | cat - > $tempfile 23 | 24 | cd $QCRI_ARABIC_NORMALIZER 25 | 26 | bash qcri_normalizer_mada3.2_aramorph1.2.1.sh $tempfile 27 | cat $tempfile.mada_norm-aramorph.europarl_tok 28 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/mms/asr/config/infer_common.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | # defaults: 3 | # - hydra/launcher: submitit_slurm 4 | 5 | # @package _group_ 6 | 7 | task: 8 | _name: audio_finetuning 9 | data: null 10 | labels: ltr 11 | common_eval: 12 | path: null 13 | post_process: letter 14 | # model_overrides: "{'task':{'multi_corpus_keys':None}}" 15 | decoding: 16 | type: viterbi 17 | lexicon: null 18 | unique_wer_file: false 19 | results_path: null 20 | distributed_training: 21 | ddp_backend: legacy_ddp 22 | distributed_world_size: 1 23 | hydra: 24 | run: 25 | dir: ${common_eval.results_path}/${dataset.gen_subset} 26 | sweep: 27 | dir: /checkpoint/${env:USER}/${env:PREFIX}/${common_eval.results_path} 28 | subdir: ${dataset.gen_subset} 29 | dataset: 30 | max_tokens: 2_000_000 31 | gen_subset: dev 32 | required_batch_size_multiple: 1 33 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/mms/asr/infer/example_infer_adapter.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | lang="$1" 3 | PYTHONPATH=. PREFIX=INFER HYDRA_FULL_ERROR=1 python examples/speech_recognition/new/infer.py -m --config-dir examples/mms/asr/config/ --config-name infer_common decoding.type=viterbi dataset.max_tokens=4000000 distributed_training.distributed_world_size=1 "common_eval.path='/fsx-wav2vec/androstj/exps/wav2vec/mms/v4/finetune/xl1b_d5_dfls_0_0.3_u300k__ft_on_d5_127_dbeta1/ft_smax_adp_common.seed:1__dataset.max_tokens:2880000__optimization.lr:[0.001]__optimization.max_update:4000__merged_ckpt/checkpoints/checkpoint_last.pt'" task.data=/fsx-wav2vec/androstj/dataset/v4/fl/fseq dataset.gen_subset="${lang}:${lang}/dev" common_eval.post_process=none 4 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/mms/lid_rerank/cer_langs.txt: -------------------------------------------------------------------------------- 1 | adx 2 | bod 3 | cmn 4 | dzo 5 | jpn 6 | khg 7 | khm 8 | lao 9 | mya 10 | tha 11 | yue 12 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/mms/lid_rerank/mms/make_parallel_single_runs.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import json 3 | from collections import defaultdict 4 | import os 5 | from tqdm import tqdm 6 | import sys 7 | import subprocess 8 | import re 9 | 10 | if __name__ == "__main__": 11 | parser = argparse.ArgumentParser(description='Example argument parser') 12 | parser.add_argument('--dump', type=str) 13 | parser.add_argument('--model', type=str) 14 | parser.add_argument('--dst', type=str) 15 | parser.add_argument('--fairseq_dir', type=str) 16 | args = parser.parse_args() 17 | 18 | langs = [d for d in os.listdir(args.dump) if os.path.isdir(os.path.join(args.dump, d))] 19 | 20 | for lang in langs: 21 | print(f"python mms/run_single_lang.py --dump {os.path.abspath(args.dump)} --lang {lang} --model {os.path.abspath(args.model)} --dst {os.path.abspath(args.dst)} --fairseq_dir {os.path.abspath(args.fairseq_dir)}") 22 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/mms/lid_rerank/mms/prep_wav_list.py: -------------------------------------------------------------------------------- 1 | import soundfile as sf 2 | import argparse 3 | 4 | if __name__ == "__main__": 5 | parser = argparse.ArgumentParser(description='Example argument parser') 6 | parser.add_argument('--src', type=str) 7 | parser.add_argument('--dst', type=str) 8 | args = parser.parse_args() 9 | 10 | wavs = [x.strip() for x in open(args.src, "r").readlines()] 11 | 12 | new_lines = ["/"] 13 | for wav in wavs: 14 | # Read the wav file 15 | data, sample_rate = sf.read(wav) 16 | 17 | # Number of samples is the length of the data array 18 | num_samples = len(data) 19 | 20 | new_lines.append(wav+"\t"+str(num_samples)) 21 | 22 | with open(args.dst, "w") as f: 23 | f.writelines([x+"\n" for x in new_lines]) 24 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/mms/lid_rerank/requirements.txt: -------------------------------------------------------------------------------- 1 | transformers 2 | peft 3 | protobuf 4 | blobfile 5 | sentencepiece 6 | fasttext 7 | numpy<=1.26.4 8 | librosa 9 | ninja 10 | editdistance -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/mr_hubert/config/decode/infer.yaml: -------------------------------------------------------------------------------- 1 | # @package _group_ 2 | 3 | defaults: 4 | - model: null 5 | 6 | hydra: 7 | run: 8 | dir: ${common_eval.results_path}/viterbi 9 | sweep: 10 | dir: ${common_eval.results_path} 11 | subdir: viterbi 12 | 13 | task: 14 | _name: multires_hubert_pretraining 15 | single_target: true 16 | fine_tuning: true 17 | label_rate_ratios: ??? 18 | data: ??? 19 | normalize: false 20 | 21 | decoding: 22 | type: viterbi 23 | unique_wer_file: true 24 | common_eval: 25 | results_path: ??? 26 | path: ??? 27 | post_process: letter 28 | dataset: 29 | max_tokens: 1100000 30 | gen_subset: ??? 31 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/mr_hubert/config/decode/run/submitit_slurm.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | hydra: 3 | launcher: 4 | cpus_per_task: ${distributed_training.distributed_world_size} 5 | gpus_per_node: ${distributed_training.distributed_world_size} 6 | tasks_per_node: ${hydra.launcher.gpus_per_node} 7 | nodes: 1 8 | mem_gb: 200 9 | timeout_min: 4320 10 | max_num_timeout: 50 11 | name: ${hydra.job.config_name} 12 | submitit_folder: ${hydra.sweep.dir}/submitit 13 | 14 | distributed_training: 15 | distributed_world_size: 1 16 | distributed_no_spawn: true 17 | distributed_port: 29761 18 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/mr_hubert/config/decode/run/submitit_slurm_8gpu.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | hydra: 3 | launcher: 4 | cpus_per_task: ${distributed_training.distributed_world_size} 5 | gpus_per_node: ${distributed_training.distributed_world_size} 6 | tasks_per_node: ${hydra.launcher.gpus_per_node} 7 | nodes: 1 8 | mem_gb: 200 9 | timeout_min: 4320 10 | max_num_timeout: 50 11 | name: ${hydra.job.config_name} 12 | submitit_folder: ${hydra.sweep.dir}/submitit 13 | 14 | distributed_training: 15 | distributed_world_size: 8 16 | distributed_no_spawn: true 17 | distributed_port: 29761 18 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/mr_hubert/config/pretrain/run/submitit_reg.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | 3 | hydra: 4 | launcher: 5 | cpus_per_task: 8 6 | gpus_per_node: 8 7 | tasks_per_node: ${hydra.launcher.gpus_per_node} 8 | nodes: 4 9 | comment: null 10 | mem_gb: 384 11 | timeout_min: 4320 12 | max_num_timeout: 100 13 | constraint: volta32gb 14 | name: ${hydra.job.config_name}/${hydra.job.override_dirname} 15 | submitit_folder: ${hydra.sweep.dir}/submitit/%j 16 | 17 | distributed_training: 18 | distributed_world_size: 32 19 | distributed_port: 29671 20 | nprocs_per_node: 8 21 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/mr_hubert/simple_kmeans: -------------------------------------------------------------------------------- 1 | ../hubert/simple_kmeans -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/multilingual/ML50_langs.txt: -------------------------------------------------------------------------------- 1 | ar_AR 2 | cs_CZ 3 | de_DE 4 | en_XX 5 | es_XX 6 | et_EE 7 | fi_FI 8 | fr_XX 9 | gu_IN 10 | hi_IN 11 | it_IT 12 | ja_XX 13 | kk_KZ 14 | ko_KR 15 | lt_LT 16 | lv_LV 17 | my_MM 18 | ne_NP 19 | nl_XX 20 | ro_RO 21 | ru_RU 22 | si_LK 23 | tr_TR 24 | vi_VN 25 | zh_CN 26 | af_ZA 27 | az_AZ 28 | bn_IN 29 | fa_IR 30 | he_IL 31 | hr_HR 32 | id_ID 33 | ka_GE 34 | km_KH 35 | mk_MK 36 | ml_IN 37 | mn_MN 38 | mr_IN 39 | pl_PL 40 | ps_AF 41 | pt_XX 42 | sv_SE 43 | sw_KE 44 | ta_IN 45 | te_IN 46 | th_TH 47 | tl_XX 48 | uk_UA 49 | ur_PK 50 | xh_ZA 51 | gl_ES 52 | sl_SI -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/multilingual/data_scripts/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Install dependency 3 | ```bash 4 | pip install -r requirement.txt 5 | ``` 6 | 7 | # Download the data set 8 | ```bash 9 | export WORKDIR_ROOT= 10 | 11 | ``` 12 | The downloaded data will be at $WORKDIR_ROOT/ML50 13 | 14 | # preprocess the data 15 | Install SPM [here](https://github.com/google/sentencepiece) 16 | ```bash 17 | export WORKDIR_ROOT= 18 | export SPM_PATH= 19 | ``` 20 | * $WORKDIR_ROOT/ML50/raw: extracted raw data 21 | * $WORKDIR_ROOT/ML50/dedup: dedup data 22 | * $WORKDIR_ROOT/ML50/clean: data with valid and test sentences removed from the dedup data 23 | 24 | 25 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/multilingual/data_scripts/requirement.txt: -------------------------------------------------------------------------------- 1 | wget 2 | pandas -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/multilingual/data_scripts/utils/strip_sgm.sh: -------------------------------------------------------------------------------- 1 | grep "seg id" | sed 's///g' | sed 's/<\/seg>//g' 2 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/multilingual/multilingual_fairseq_gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # All rights reserved. 4 | # 5 | # This source code is licensed under the license found in the 6 | # LICENSE file in the root directory of this source tree. 7 | 8 | lang_pairs="en-fr,en-cs,fr-en,cs-en" 9 | path_2_data=$1 # 10 | lang_list=$2 # 11 | model=$3 # 12 | source_lang=cs 13 | target_lang=en 14 | 15 | fairseq-generate "$path_2_data" \ 16 | --path "$model" \ 17 | --task translation_multi_simple_epoch \ 18 | --gen-subset test \ 19 | --source-lang "$source_lang" \ 20 | --target-lang "$target_lang" \ 21 | --sacrebleu --remove-bpe 'sentencepiece'\ 22 | --batch-size 32 \ 23 | --encoder-langtok "src" \ 24 | --decoder-langtok \ 25 | --lang-dict "$lang_list" \ 26 | --lang-pairs "$lang_pairs" 27 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/noisychannel/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .rerank_options import * # noqa 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/operators/alignment_train_cuda.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #include "alignment_train_cuda.h" 10 | #include "utils.h" 11 | 12 | namespace { 13 | 14 | void alignmentTrainCUDA( 15 | const torch::Tensor& p_choose, 16 | torch::Tensor& alpha, 17 | float eps) { 18 | CHECK_INPUT(p_choose); 19 | CHECK_INPUT(alpha); 20 | 21 | alignmentTrainCUDAWrapper(p_choose, alpha, eps); 22 | } 23 | 24 | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { 25 | m.def( 26 | "alignment_train_cuda", 27 | &alignmentTrainCUDA, 28 | "expected_alignment_from_p_choose (CUDA)"); 29 | } 30 | 31 | } // namespace 32 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/operators/alignment_train_cuda.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include // @manual=//caffe2:torch_extension 12 | 13 | void alignmentTrainCUDAWrapper( 14 | const torch::Tensor& p_choose, 15 | torch::Tensor& alpha, 16 | float eps); 17 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/operators/utils.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include // @manual=//caffe2:torch_extension 12 | 13 | #define CHECK_CUDA(x) \ 14 | TORCH_CHECK(x.type().is_cuda(), #x " must be a CUDA tensor") 15 | #define CHECK_CONTIGUOUS(x) \ 16 | TORCH_CHECK(x.is_contiguous(), #x " must be contiguous") 17 | #define CHECK_INPUT(x) \ 18 | CHECK_CUDA(x); \ 19 | CHECK_CONTIGUOUS(x) 20 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/pointer_generator/pointer_generator_src/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from . import transformer_pg # noqa 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/roberta/commonsense_qa/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from . import commonsense_qa_task # noqa 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/roberta/commonsense_qa/download_cqa_data.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | OUTDIR=data/CommonsenseQA 8 | 9 | mkdir -p $OUTDIR 10 | 11 | wget -O $OUTDIR/train.jsonl https://s3.amazonaws.com/commensenseqa/train_rand_split.jsonl 12 | wget -O $OUTDIR/valid.jsonl https://s3.amazonaws.com/commensenseqa/dev_rand_split.jsonl 13 | wget -O $OUTDIR/test.jsonl https://s3.amazonaws.com/commensenseqa/test_rand_split_no_answers.jsonl 14 | wget -O $OUTDIR/dict.txt https://dl.fbaipublicfiles.com/fairseq/gpt2_bpe/dict.txt 15 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/roberta/config/finetuning/run_config/local.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | hydra: 3 | sweep: 4 | dir: ${env:PWD}/tmp_dbg/${now:%H-%M-%S} 5 | 6 | distributed_training: 7 | distributed_world_size: 1 8 | nprocs_per_node: 1 9 | distributed_port: -1 10 | 11 | common: 12 | log_interval: 1 13 | 14 | dataset: 15 | num_workers: 0 16 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/roberta/config/finetuning/run_config/slurm_1g.yaml: -------------------------------------------------------------------------------- 1 | 2 | # @package _global_ 3 | 4 | hydra: 5 | job: 6 | config: 7 | override_dirname: 8 | kv_sep: '_' 9 | item_sep: '/' 10 | exclude_keys: 11 | - run_config 12 | - distributed_training.distributed_port 13 | sweep: 14 | dir: /checkpoint/${env:USER}/roberta_ft/${env:PREFIX}/${hydra.job.config_name}/${env:SUFFIX} 15 | subdir: ${hydra.job.num} 16 | launcher: 17 | submitit_folder: ${hydra.sweep.dir}/submitit 18 | timeout_min: 1000 19 | cpus_per_task: 8 20 | gpus_per_node: 1 21 | tasks_per_node: 1 22 | mem_gb: 60 23 | nodes: 1 24 | name: ${env:PREFIX}_${hydra.job.config_name} 25 | partition: devlab,learnlab,learnfair,scavenge 26 | constraint: volta32gb 27 | max_num_timeout: 30 28 | exclude: learnfair1381,learnfair5192,learnfair2304 29 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/roberta/config/finetuning/run_config/slurm_1g_aws.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | 3 | hydra: 4 | job: 5 | config: 6 | override_dirname: 7 | kv_sep: '_' 8 | item_sep: '/' 9 | exclude_keys: 10 | - run_config 11 | - distributed_training.distributed_port 12 | sweep: 13 | dir: /fsx-wav2vec/${env:USER}/roberta_ft/${env:PREFIX}/${hydra.job.config_name}/${env:SUFFIX} 14 | subdir: ${hydra.job.num} 15 | launcher: 16 | submitit_folder: ${hydra.sweep.dir}/submitit 17 | timeout_min: 1000 18 | cpus_per_task: 8 19 | gpus_per_node: 1 20 | tasks_per_node: 1 21 | mem_gb: 0 22 | nodes: 1 23 | name: ${env:PREFIX}_${hydra.job.config_name} 24 | partition: learnfair,wav2vec 25 | max_num_timeout: 30 26 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/roberta/config/pretraining/base.yaml: -------------------------------------------------------------------------------- 1 | # @package _group_ 2 | common: 3 | fp16: true 4 | log_format: json 5 | log_interval: 200 6 | 7 | checkpoint: 8 | no_epoch_checkpoints: true 9 | 10 | task: 11 | _name: masked_lm 12 | data: ??? 13 | sample_break_mode: complete 14 | tokens_per_sample: 512 15 | 16 | criterion: masked_lm 17 | 18 | dataset: 19 | batch_size: 16 20 | ignore_unused_valid_subsets: true 21 | 22 | optimizer: 23 | _name: adam 24 | weight_decay: 0.01 25 | adam_betas: (0.9,0.98) 26 | adam_eps: 1e-06 27 | 28 | lr_scheduler: 29 | _name: polynomial_decay 30 | warmup_updates: 10000 31 | 32 | optimization: 33 | clip_norm: 0 34 | lr: [0.0005] 35 | max_update: 125000 36 | update_freq: [16] 37 | 38 | model: 39 | _name: roberta 40 | max_positions: 512 41 | dropout: 0.1 42 | attention_dropout: 0.1 43 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/roberta/config/pretraining/run_config/local.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | hydra: 3 | sweep: 4 | dir: ${env:PWD}/tmp_dbg/${now:%H-%M-%S} 5 | 6 | distributed_training: 7 | distributed_world_size: 1 8 | nprocs_per_node: 1 9 | distributed_port: -1 10 | 11 | common: 12 | log_interval: 1 13 | 14 | dataset: 15 | num_workers: 0 16 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/roberta/fb_multilingual/README.multilingual.pretraining.md: -------------------------------------------------------------------------------- 1 | # Multilingual pretraining RoBERTa 2 | 3 | This tutorial will walk you through pretraining multilingual RoBERTa. 4 | 5 | ### 1) Preprocess the data 6 | 7 | ```bash 8 | DICTIONARY="/private/home/namangoyal/dataset/XLM/wiki/17/175k/vocab" 9 | DATA_LOCATION="/private/home/namangoyal/dataset/XLM/wiki/17/175k" 10 | 11 | for LANG in en es it 12 | do 13 | fairseq-preprocess \ 14 | --only-source \ 15 | --srcdict $DICTIONARY \ 16 | --trainpref "$DATA_LOCATION/train.$LANG" \ 17 | --validpref "$DATA_LOCATION/valid.$LANG" \ 18 | --testpref "$DATA_LOCATION/test.$LANG" \ 19 | --destdir "wiki_17-bin/$LANG" \ 20 | --workers 60; 21 | done 22 | ``` 23 | 24 | ### 2) Train RoBERTa base 25 | 26 | [COMING UP...] 27 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/roberta/wsc/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from . import wsc_criterion # noqa 7 | from . import wsc_task # noqa 8 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/rxf/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from . import rxf_src # noqa 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/rxf/rxf_src/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from . import label_smoothed_cross_entropy_r3f, sentence_prediction_r3f # noqa 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/simultaneous_translation/README.md: -------------------------------------------------------------------------------- 1 | # Simultaneous Translation 2 | Examples of simultaneous translation in fairseq 3 | - [English-to-Japanese text-to-text wait-k model](docs/enja-waitk.md) 4 | - [English-to-Germen text-to-text monotonic multihead attention model](docs/ende-mma.md) 5 | - [English-to-Germen speech-to-text simultaneous translation model](../speech_to_text/docs/simulst_mustc_example.md) 6 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/simultaneous_translation/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from . import models # noqa 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/simultaneous_translation/models/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import importlib 7 | import os 8 | 9 | 10 | for file in sorted(os.listdir(os.path.dirname(__file__))): 11 | if file.endswith(".py") and not file.startswith("_"): 12 | model_name = file[: file.find(".py")] 13 | importlib.import_module( 14 | "examples.simultaneous_translation.models." + model_name 15 | ) 16 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/simultaneous_translation/modules/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | 7 | import os 8 | import importlib 9 | from fairseq import registry 10 | 11 | ( 12 | build_monotonic_attention, 13 | register_monotonic_attention, 14 | MONOTONIC_ATTENTION_REGISTRY, 15 | _, 16 | ) = registry.setup_registry("--simul-type") 17 | 18 | for file in sorted(os.listdir(os.path.dirname(__file__))): 19 | if file.endswith(".py") and not file.startswith("_"): 20 | model_name = file[: file.find(".py")] 21 | importlib.import_module( 22 | "examples.simultaneous_translation.modules." + model_name 23 | ) 24 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/simultaneous_translation/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import importlib 7 | import os 8 | 9 | 10 | # automatically import any Python files in the criterions/ directory 11 | for file in sorted(os.listdir(os.path.dirname(__file__))): 12 | if file.endswith(".py") and not file.startswith("_"): 13 | module = file[: file.find(".py")] 14 | importlib.import_module("examples.simultaneous_translation.utils." + module) 15 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_recognition/__init__.py: -------------------------------------------------------------------------------- 1 | from . import criterions, models, tasks # noqa 2 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_recognition/criterions/__init__.py: -------------------------------------------------------------------------------- 1 | import importlib 2 | import os 3 | 4 | 5 | # ASG loss requires flashlight bindings 6 | files_to_skip = set() 7 | try: 8 | import flashlight.lib.sequence.criterion 9 | except ImportError: 10 | files_to_skip.add("ASG_loss.py") 11 | 12 | for file in sorted(os.listdir(os.path.dirname(__file__))): 13 | if file.endswith(".py") and not file.startswith("_") and file not in files_to_skip: 14 | criterion_name = file[: file.find(".py")] 15 | importlib.import_module( 16 | "examples.speech_recognition.criterions." + criterion_name 17 | ) 18 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_recognition/data/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .asr_dataset import AsrDataset 7 | 8 | 9 | __all__ = [ 10 | "AsrDataset", 11 | ] 12 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_recognition/kaldi/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/speech_recognition/kaldi/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_recognition/kaldi/config/kaldi_initializer.yaml: -------------------------------------------------------------------------------- 1 | # @package _group_ 2 | 3 | data_dir: ??? 4 | fst_dir: ??? 5 | in_labels: ??? 6 | kaldi_root: ??? 7 | lm_arpa: ??? 8 | blank_symbol: 9 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_recognition/models/__init__.py: -------------------------------------------------------------------------------- 1 | import importlib 2 | import os 3 | 4 | 5 | for file in sorted(os.listdir(os.path.dirname(__file__))): 6 | if file.endswith(".py") and not file.startswith("_"): 7 | model_name = file[: file.find(".py")] 8 | importlib.import_module("examples.speech_recognition.models." + model_name) 9 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_recognition/new/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/speech_recognition/new/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_recognition/new/conf/hydra/sweeper/ax.yaml: -------------------------------------------------------------------------------- 1 | # @package hydra.sweeper 2 | _target_: hydra_plugins.hydra_ax_sweeper.ax_sweeper.AxSweeper 3 | max_batch_size: null 4 | ax_config: 5 | max_trials: 128 6 | early_stop: 7 | minimize: true 8 | max_epochs_without_improvement: 10 9 | epsilon: 0.025 10 | experiment: 11 | name: ${dataset.gen_subset} 12 | objective_name: wer 13 | minimize: true 14 | parameter_constraints: null 15 | outcome_constraints: null 16 | status_quo: null 17 | client: 18 | verbose_logging: false 19 | random_seed: null 20 | params: 21 | decoding.lmweight: 22 | type: range 23 | bounds: [0.0, 5.0] 24 | decoding.wordscore: 25 | type: range 26 | bounds: [-5.0, 5.0] 27 | decoding.silweight: 28 | type: range 29 | bounds: [ -8.0, 0.0 ] 30 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_recognition/new/conf/hydra/sweeper/ax_sil.yaml: -------------------------------------------------------------------------------- 1 | # @package hydra.sweeper 2 | _target_: hydra_plugins.hydra_ax_sweeper.ax_sweeper.AxSweeper 3 | max_batch_size: null 4 | ax_config: 5 | max_trials: 64 6 | early_stop: 7 | minimize: true 8 | max_epochs_without_improvement: 10 9 | epsilon: 0.025 10 | experiment: 11 | name: ${dataset.gen_subset} 12 | objective_name: wer 13 | minimize: true 14 | parameter_constraints: null 15 | outcome_constraints: null 16 | status_quo: null 17 | client: 18 | verbose_logging: false 19 | random_seed: null 20 | params: 21 | decoding.lmweight: 22 | type: range 23 | bounds: [0.0, 10.0] 24 | decoding.wordscore: 25 | type: range 26 | bounds: [-10.0, 10.0] 27 | decoding.silweight: 28 | type: range 29 | bounds: [ -10.0, 0.0 ] 30 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_recognition/new/conf/infer.yaml: -------------------------------------------------------------------------------- 1 | # @package _group_ 2 | 3 | defaults: 4 | - task: null 5 | - model: null 6 | 7 | hydra: 8 | run: 9 | dir: ${common_eval.results_path}/${dataset.gen_subset} 10 | sweep: 11 | dir: /checkpoint/${env:USER}/${env:PREFIX}/${common_eval.results_path} 12 | subdir: ${dataset.gen_subset} 13 | common: 14 | user_dir: /private/home/abaevski/fairseq-py/examples/data2vec 15 | common_eval: 16 | results_path: null 17 | path: null 18 | post_process: letter 19 | quiet: true 20 | dataset: 21 | max_tokens: 3000000 22 | gen_subset: test 23 | distributed_training: 24 | distributed_world_size: 1 25 | decoding: 26 | beam: 5 27 | type: viterbi 28 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_recognition/new/conf/run_config/fb_slurm_1.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | 3 | hydra: 4 | job: 5 | config: 6 | override_dirname: 7 | kv_sep: ':' 8 | item_sep: '/' 9 | exclude_keys: 10 | - run_config 11 | - distributed_training.distributed_port 12 | - common_eval.path 13 | sweep: 14 | dir: /checkpoint/abaevski/asr/d2v2/decoding/${env:PREFIX}/${hydra.job.config_name}_${hydra.launcher.gpus_per_node}/${hydra.job.override_dirname} 15 | # subdir: ${hydra.job.override_dirname} 16 | launcher: 17 | cpus_per_task: 16 18 | gpus_per_node: 1 19 | tasks_per_node: 1 20 | nodes: 1 21 | partition: devlab,learnlab 22 | mem_gb: 100 23 | timeout_min: 2000 24 | max_num_timeout: 10 25 | name: ${env:PREFIX}_${hydra.job.config_name} 26 | submitit_folder: ${hydra.sweep.dir}/%j 27 | constraint: volta32gb 28 | exclude: learnfair7598 -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_recognition/new/conf/run_config/fb_slurm_2g.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | 3 | hydra: 4 | job: 5 | config: 6 | override_dirname: 7 | kv_sep: ':' 8 | item_sep: '/' 9 | exclude_keys: 10 | - run_config 11 | - distributed_training.distributed_port 12 | - common_eval.path 13 | sweep: 14 | dir: /checkpoint/abaevski/asr/d2v2/decoding/${env:PREFIX}/${hydra.job.config_name}_${hydra.launcher.gpus_per_node}/${hydra.job.override_dirname} 15 | # subdir: ${hydra.job.override_dirname} 16 | launcher: 17 | cpus_per_task: 16 18 | gpus_per_node: 2 19 | tasks_per_node: 2 20 | nodes: 1 21 | partition: devlab,learnlab 22 | mem_gb: 100 23 | timeout_min: 2000 24 | max_num_timeout: 10 25 | name: ${env:PREFIX}_${hydra.job.config_name} 26 | submitit_folder: ${hydra.sweep.dir}/%j 27 | constraint: volta32gb -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_recognition/new/decoders/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/speech_recognition/new/decoders/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_recognition/new/decoders/viterbi_decoder.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Copyright (c) Facebook, Inc. and its affiliates. 4 | # 5 | # This source code is licensed under the MIT license found in the 6 | # LICENSE file in the root directory of this source tree. 7 | 8 | import torch 9 | 10 | from typing import List, Dict 11 | 12 | from .base_decoder import BaseDecoder 13 | 14 | 15 | class ViterbiDecoder(BaseDecoder): 16 | def decode( 17 | self, 18 | emissions: torch.FloatTensor, 19 | ) -> List[List[Dict[str, torch.LongTensor]]]: 20 | def get_pred(e): 21 | score = e.log_softmax(dim=-1).max(dim=-1)[0].sum() 22 | toks = e.argmax(dim=-1).unique_consecutive() 23 | return {"tokens":toks[toks != self.blank], "score":score} 24 | return [[get_pred(x)] for x in emissions] 25 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_recognition/tasks/__init__.py: -------------------------------------------------------------------------------- 1 | import importlib 2 | import os 3 | 4 | 5 | for file in sorted(os.listdir(os.path.dirname(__file__))): 6 | if file.endswith(".py") and not file.startswith("_"): 7 | task_name = file[: file.find(".py")] 8 | importlib.import_module("examples.speech_recognition.tasks." + task_name) 9 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_synthesis/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_synthesis/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_synthesis/preprocessing/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_synthesis/preprocessing/denoiser/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_text_joint_to_text/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from . import tasks, criterions, models # noqa 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_text_joint_to_text/criterions/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import importlib 7 | import os 8 | 9 | 10 | for file in os.listdir(os.path.dirname(__file__)): 11 | if file.endswith(".py") and not file.startswith("_"): 12 | criterion_name = file[: file.find(".py")] 13 | importlib.import_module( 14 | "examples.speech_text_joint_to_text.criterions." + criterion_name 15 | ) 16 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_text_joint_to_text/models/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import importlib 7 | import os 8 | 9 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_text_joint_to_text/tasks/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import importlib 7 | import os 8 | 9 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_to_speech/README.md: -------------------------------------------------------------------------------- 1 | # Speech to speech translation (S2ST) 2 | 3 | We provide the implementation and resources for the following work on speech-to-speech translation (S2ST): 4 | 5 | * [Direct speech-to-speech translation with discrete units (Lee et al. 2021)](docs/direct_s2st_discrete_units.md) 6 | * [Textless Speech-to-Speech Translation on Real Data (Lee et al. 2021)](docs/textless_s2st_real_data.md) 7 | * [Enhanced Direct Speech-to-Speech Translation Using Self-supervised Pre-training and Data Augmentation](docs/enhanced_direct_s2st_discrete_units.md) 8 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_to_speech/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from . import unity # noqa 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_to_speech/asr_bleu/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/speech_to_speech/asr_bleu/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_to_speech/asr_bleu/requirements.txt: -------------------------------------------------------------------------------- 1 | fairseq==0.12.2 2 | pandas==1.4.3 3 | sacrebleu==2.2.0 4 | torch==1.12.1 5 | torchaudio==0.12.1 6 | tqdm==4.64.0 7 | transformers==4.21.1 8 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_to_speech/benchmarking/configs/2StageS2ST.yaml: -------------------------------------------------------------------------------- 1 | general: 2 | dataset_path: $npy_dataset 3 | cpu: True 4 | model_type: 2StageS2ST 5 | dataset_size: 1 6 | 7 | stage1: 8 | data: $data_bin_stage1 9 | task: speech_to_text 10 | path: $checkpoint_stage1 11 | config_yaml: config.yaml 12 | max_len_a: 2 13 | max_len_b: 500 14 | 15 | stage2: 16 | data: $data_bin_stage2 17 | task: text_to_speech 18 | path: $checkpoint_stage2 19 | config_yaml: config.yaml 20 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_to_speech/benchmarking/configs/3StageS2ST.yaml: -------------------------------------------------------------------------------- 1 | general: 2 | dataset_path: $npy_dataset 3 | cpu: True 4 | model_type: 3StageS2ST 5 | max_len_a: 2 6 | max_len_b: 500 7 | dataset_size: 1 8 | 9 | stage1: 10 | data: $data_bin_stage1 11 | task: speech_to_text 12 | path: $checkpoint_stage1 13 | config_yaml: config.yaml 14 | max_len_a: 2 15 | max_len_b: 500 16 | 17 | stage2: 18 | data: $data_bin_stage2 19 | task: translation 20 | path: $checkpoint_stage2 21 | config_yaml: config.yaml 22 | 23 | 24 | stage2: 25 | data: $data_bin_stage3 26 | task: text_to_speech 27 | path: $checkpoint_stage3 28 | config_yaml: config.yaml 29 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_to_speech/benchmarking/configs/DirectS2U.yaml: -------------------------------------------------------------------------------- 1 | general: 2 | dataset_path: $npy_dataset_path 3 | cpu: True 4 | model_type: S2UT 5 | dataset_size: 5 6 | dump_speech_waveforms_dir: $dump_waveforms_dir_path 7 | 8 | stage1: 9 | data: $data_bin 10 | task: speech_to_speech 11 | path: $checkpoint 12 | config_yaml: config.yaml 13 | max_len_b: 100000 14 | beam: 10 15 | target_is_code: True 16 | max_target_positions: 3000 17 | target_code_size: 100 18 | 19 | stage2: 20 | vocoder: $vocoder_path 21 | vocoder_cfg: $vocoder_cfg_json 22 | dur_prediction: True 23 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_to_speech/benchmarking/configs/S2T.yaml: -------------------------------------------------------------------------------- 1 | general: 2 | dataset_path: $npy_dataset 3 | cpu: True 4 | model_type: S2T 5 | dataset_size: 1 6 | 7 | stage1: 8 | data: $data_bin 9 | task: speech_to_text 10 | path: $checkpoint 11 | config_yaml: config.yaml 12 | max_len_a: 2 13 | max_len_b: 500 14 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_to_speech/preprocessing/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/speech_to_speech/unity/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from . import sequence_generator # noqa 7 | from . import sequence_generator_multi_decoder # noqa 8 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/textless_nlp/gslm/metrics/README.md: -------------------------------------------------------------------------------- 1 | # GSLM Metrics 2 | 3 | ## ASR Metrics 4 | The suite of metrics here uses an ASR model to transcribe the synthesized speech into text, and then uses text-based metrics. We also use word error rate from ASR transcription itself as one of the metrics. [More details](asr_metrics) 5 | 6 | ## ABX Metrics 7 | We use [ABX](https://www.semanticscholar.org/paper/ABX-Discriminability-Measures-and-Applications-Schatz/13d3537228f728c1063cc83743cb118bba3367a0) to evaluate how well-separated phonetic categories are with quantized representations. [More details](abx_metrics) 8 | 9 | ## sWUGGY and sBLIMP 10 | We refer to [ZeroSpeech challenge](https://www.zerospeech.com/2021/track_s.html#scoring-based-metrics) for details on the sWUGGY and sBLIMP metrics. 11 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/textless_nlp/gslm/metrics/asr_metrics/misc/dict.ltr.txt: -------------------------------------------------------------------------------- 1 | | 94802 2 | E 51860 3 | T 38431 4 | A 33152 5 | O 31495 6 | N 28855 7 | I 28794 8 | H 27187 9 | S 26071 10 | R 23546 11 | D 18289 12 | L 16308 13 | U 12400 14 | M 10685 15 | W 10317 16 | C 9844 17 | F 9062 18 | G 8924 19 | Y 8226 20 | P 6890 21 | B 6339 22 | V 3936 23 | K 3456 24 | ' 1023 25 | X 636 26 | J 598 27 | Q 437 28 | Z 213 29 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/textless_nlp/gslm/speech2unit/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/textless_nlp/gslm/speech2unit/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/textless_nlp/gslm/speech2unit/clustering/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/textless_nlp/gslm/speech2unit/clustering/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/textless_nlp/gslm/speech2unit/clustering/utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from typing import List, Tuple 7 | 8 | 9 | def get_audio_files(manifest_path: str) -> Tuple[str, List[str], List[int]]: 10 | fnames, sizes = [], [] 11 | with open(manifest_path, "r") as f: 12 | root_dir = f.readline().strip() 13 | for line in f: 14 | items = line.strip().split("\t") 15 | assert ( 16 | len(items) == 2 17 | ), f"File must have two columns separated by tab. Got {line}" 18 | fnames.append(items[0]) 19 | sizes.append(int(items[1])) 20 | return root_dir, fnames, sizes 21 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/textless_nlp/gslm/unit2speech/multiproc.py: -------------------------------------------------------------------------------- 1 | import os 2 | import time 3 | import torch 4 | import sys 5 | import subprocess 6 | 7 | argslist = list(sys.argv)[1:] 8 | log_dir = argslist[-1] 9 | num_gpus = torch.cuda.device_count() 10 | argslist.append('--n_gpus={}'.format(num_gpus)) 11 | workers = [] 12 | job_id = time.strftime("%Y_%m_%d-%H%M%S") 13 | argslist.append("--group_name=group_{}".format(job_id)) 14 | 15 | print("GPU log directory is {}".format(log_dir)) 16 | os.makedirs(log_dir, exist_ok=True) 17 | for i in range(num_gpus): 18 | argslist.append('--rank={}'.format(i)) 19 | stdout = None if i == 0 else open("{}/{}_GPU_{}.log".format(log_dir, job_id, i), 20 | "w") 21 | print(argslist) 22 | p = subprocess.Popen([str(sys.executable)]+argslist, stdout=stdout) 23 | workers.append(p) 24 | argslist = argslist[:-1] 25 | 26 | for p in workers: 27 | p.wait() 28 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/textless_nlp/gslm/unit2speech/tacotron2/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/textless_nlp/gslm/unit2speech/tacotron2/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/textless_nlp/gslm/unit2speech/tacotron2/symbols.py: -------------------------------------------------------------------------------- 1 | """ from https://github.com/keithito/tacotron """ 2 | 3 | ''' 4 | Defines the set of symbols used in text input to the model. 5 | 6 | The default is a set of ASCII characters that works well for English or text that has been run through Unidecode. For other data, you can modify _characters. See TRAINING_DATA.md for details. ''' 7 | from . import cmudict 8 | 9 | _pad = '_' 10 | _punctuation = '!\'(),.:;? ' 11 | _special = '-' 12 | _letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' 13 | 14 | # Prepend "@" to ARPAbet symbols to ensure uniqueness (some are the same as uppercase letters): 15 | _arpabet = ['@' + s for s in cmudict.valid_symbols] 16 | 17 | # Export all symbols: 18 | symbols = [_pad] + list(_special) + list(_punctuation) + list(_letters) + _arpabet 19 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/textless_nlp/pgslm/eval/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/textless_nlp/pgslm/sample/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/textless_nlp/speech-resynth/img/fig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/textless_nlp/speech-resynth/img/fig.png -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/translation_moe/translation_moe_src/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from . import translation_moe # noqa 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/truncated_bptt/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from . import transformer_xl_model, truncated_bptt_lm_task # noqa 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/wav2vec/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/config/finetuning/run_config/slurm_1.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | 3 | hydra: 4 | job: 5 | config: 6 | override_dirname: 7 | kv_sep: ':' 8 | item_sep: '__' 9 | exclude_keys: 10 | - run_config 11 | - distributed_training.distributed_port 12 | sweep: 13 | dir: /checkpoint/${env:USER}/${env:PREFIX}/${hydra.job.config_name}_${hydra.launcher.gpus_per_node}/${hydra.job.override_dirname} 14 | subdir: ${hydra.job.num} 15 | launcher: 16 | submitit_folder: ${hydra.sweep.dir} 17 | timeout_min: 4320 18 | cpus_per_task: 10 19 | gpus_per_node: 8 20 | tasks_per_node: 8 21 | mem_gb: 450 22 | nodes: 1 23 | name: ${env:PREFIX}_${hydra.job.config_name} 24 | partition: devlab,learnlab,learnfair,scavenge 25 | constraint: volta32gb 26 | max_num_timeout: 30 -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/config/finetuning/run_config/slurm_16.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | 3 | hydra: 4 | job: 5 | config: 6 | override_dirname: 7 | kv_sep: ':' 8 | item_sep: '__' 9 | exclude_keys: 10 | - run_config 11 | - distributed_training.distributed_port 12 | sweep: 13 | dir: /checkpoint/${env:USER}/${env:PREFIX}/${hydra.job.config_name}_${hydra.launcher.gpus_per_node}/${hydra.job.override_dirname} 14 | subdir: ${hydra.job.num} 15 | launcher: 16 | submitit_folder: ${hydra.sweep.dir} 17 | timeout_min: 4320 18 | cpus_per_task: 80 19 | gpus_per_node: 8 20 | tasks_per_node: 1 21 | mem_gb: 450 22 | nodes: 16 23 | name: ${env:PREFIX}_${hydra.job.config_name} 24 | partition: learnlab,learnfair,scavenge 25 | constraint: volta32gb 26 | max_num_timeout: 30 27 | exclude: learnfair1381,learnfair5192,learnfair2304 -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/config/finetuning/run_config/slurm_1_old.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | 3 | hydra: 4 | job: 5 | config: 6 | override_dirname: 7 | kv_sep: ':' 8 | item_sep: '__' 9 | exclude_keys: 10 | - run_config 11 | - distributed_training.distributed_port 12 | sweep: 13 | dir: /checkpoint/${env:USER}/${env:PREFIX}/${hydra.job.config_name}_${hydra.launcher.gpus_per_node}/${hydra.job.override_dirname} 14 | subdir: ${hydra.job.num} 15 | launcher: 16 | submitit_folder: ${hydra.sweep.dir} 17 | timeout_min: 4320 18 | cpus_per_task: 80 19 | gpus_per_node: 8 20 | tasks_per_node: 1 21 | mem_gb: 450 22 | nodes: 1 23 | name: ${env:PREFIX}_wav2vec3_small_librispeech 24 | partition: devlab,learnlab,learnfair,scavenge 25 | constraint: volta32gb 26 | max_num_timeout: 30 27 | exclude: learnfair1381 -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/config/finetuning/run_config/slurm_2.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | 3 | hydra: 4 | job: 5 | config: 6 | override_dirname: 7 | kv_sep: ':' 8 | item_sep: '__' 9 | exclude_keys: 10 | - run_config 11 | - distributed_training.distributed_port 12 | sweep: 13 | dir: /checkpoint/${env:USER}/${env:PREFIX}/${hydra.job.config_name}_${hydra.launcher.gpus_per_node}/${hydra.job.override_dirname} 14 | subdir: ${hydra.job.num} 15 | launcher: 16 | submitit_folder: ${hydra.sweep.dir} 17 | timeout_min: 4320 18 | cpus_per_task: 10 19 | gpus_per_node: 8 20 | tasks_per_node: 8 21 | mem_gb: 450 22 | nodes: 2 23 | name: ${env:PREFIX}_${hydra.job.config_name} 24 | partition: devlab,learnlab,learnfair,scavenge 25 | constraint: volta32gb 26 | max_num_timeout: 30 27 | exclude: learnfair7491,learnfair7477,learnfair7487 -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/config/finetuning/run_config/slurm_2g.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | 3 | hydra: 4 | job: 5 | config: 6 | override_dirname: 7 | kv_sep: ':' 8 | item_sep: '__' 9 | exclude_keys: 10 | - run_config 11 | - distributed_training.distributed_port 12 | sweep: 13 | dir: /checkpoint/${env:USER}/${env:PREFIX}/${hydra.job.config_name}_${hydra.launcher.gpus_per_node}/${hydra.job.override_dirname} 14 | subdir: ${hydra.job.num} 15 | launcher: 16 | submitit_folder: ${hydra.sweep.dir} 17 | timeout_min: 4320 18 | cpus_per_task: 10 19 | gpus_per_node: 2 20 | tasks_per_node: 2 21 | mem_gb: 200 22 | nodes: 1 23 | name: ${env:PREFIX}_${hydra.job.config_name} 24 | partition: devlab,learnlab,learnfair,scavenge 25 | constraint: volta32gb 26 | max_num_timeout: 30 27 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/config/finetuning/run_config/slurm_3.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | 3 | hydra: 4 | job: 5 | config: 6 | override_dirname: 7 | kv_sep: ':' 8 | item_sep: '__' 9 | exclude_keys: 10 | - run_config 11 | - distributed_training.distributed_port 12 | sweep: 13 | dir: /checkpoint/${env:USER}/${env:PREFIX}/${hydra.job.config_name}_${hydra.launcher.gpus_per_node}/${hydra.job.override_dirname} 14 | subdir: ${hydra.job.num} 15 | launcher: 16 | submitit_folder: ${hydra.sweep.dir} 17 | timeout_min: 4320 18 | cpus_per_task: 10 19 | gpus_per_node: 8 20 | tasks_per_node: 8 21 | mem_gb: 450 22 | nodes: 3 23 | name: ${env:PREFIX}_${hydra.job.config_name} 24 | partition: devlab,learnlab,learnfair,scavenge 25 | constraint: volta32gb 26 | max_num_timeout: 30 27 | exclude: learnfair7491,learnfair7477,learnfair7487 -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/config/finetuning/run_config/slurm_4g.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | 3 | hydra: 4 | job: 5 | config: 6 | override_dirname: 7 | kv_sep: ':' 8 | item_sep: '__' 9 | exclude_keys: 10 | - run_config 11 | - distributed_training.distributed_port 12 | sweep: 13 | dir: /checkpoint/${env:USER}/${env:PREFIX}/${hydra.job.config_name}_${hydra.launcher.gpus_per_node}/${hydra.job.override_dirname} 14 | subdir: ${hydra.job.num} 15 | launcher: 16 | submitit_folder: ${hydra.sweep.dir} 17 | timeout_min: 4320 18 | cpus_per_task: 10 19 | gpus_per_node: 4 20 | tasks_per_node: 4 21 | mem_gb: 200 22 | nodes: 1 23 | name: ${env:PREFIX}_${hydra.job.config_name} 24 | partition: devlab,learnlab,learnfair,scavenge 25 | constraint: volta32gb 26 | max_num_timeout: 30 27 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/config/finetuning/run_config/slurm_8.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | 3 | hydra: 4 | job: 5 | config: 6 | override_dirname: 7 | kv_sep: ':' 8 | item_sep: '__' 9 | exclude_keys: 10 | - run_config 11 | - distributed_training.distributed_port 12 | sweep: 13 | dir: /checkpoint/${env:USER}/${env:PREFIX}/${hydra.job.config_name}_${hydra.launcher.gpus_per_node}/${hydra.job.override_dirname} 14 | subdir: ${hydra.job.num} 15 | launcher: 16 | submitit_folder: ${hydra.sweep.dir} 17 | timeout_min: 4320 18 | cpus_per_task: 10 19 | gpus_per_node: 8 20 | tasks_per_node: 8 21 | mem_gb: 400 22 | nodes: 8 23 | name: ${env:PREFIX}_${hydra.job.config_name} 24 | partition: devlab,learnlab,learnfair,scavenge 25 | constraint: volta32gb 26 | max_num_timeout: 30 27 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/unsupervised/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/examples/wav2vec/unsupervised/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/unsupervised/config/generate/viterbi.yaml: -------------------------------------------------------------------------------- 1 | # @package _group_ 2 | 3 | fairseq: 4 | task: 5 | _name: unpaired_audio_text 6 | labels: phn 7 | data: ??? 8 | sort_by_length: false 9 | shuffle: false 10 | text_data: '' 11 | 12 | common_eval: 13 | path: ??? 14 | quiet: true 15 | 16 | dataset: 17 | gen_subset: valid 18 | batch_size: 1 19 | 20 | w2l_decoder: VITERBI 21 | post_process: silence 22 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/unsupervised/data/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .extracted_features_dataset import ExtractedFeaturesDataset 7 | from .random_input_dataset import RandomInputDataset 8 | 9 | 10 | __all__ = [ 11 | "ExtractedFeaturesDataset", 12 | "RandomInputDataset", 13 | ] 14 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/unsupervised/kaldi_self_train/st/local/copy_aligned_text.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | for idx, line in enumerate(sys.stdin): 4 | print(f"utt{idx:010d} {line}", end='') -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/unsupervised/kaldi_self_train/st/local/decode.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -u 4 | 5 | val_sets="dev_other" 6 | graph_name=graph 7 | decode_suffix="" 8 | decode_script="steps/decode_fmllr.sh" 9 | decode_args="" 10 | nj=60 11 | 12 | . ./cmd.sh 13 | . ./path.sh 14 | . parse_options.sh 15 | 16 | set -x 17 | exp_dir=$1 18 | data_root=$2 19 | lang_test=$3 20 | 21 | graph=$exp_dir/$graph_name 22 | 23 | if [ ! -d $graph ]; then 24 | utils/mkgraph.sh $lang_test $exp_dir $graph 25 | fi 26 | 27 | for part in $val_sets; do 28 | dec_dir=$exp_dir/decode${decode_suffix}_${part} 29 | if [ ! -d $dec_dir ]; then 30 | echo "decoding $part for $exp_dir" 31 | $decode_script --nj $nj --cmd "$decode_cmd" $decode_args \ 32 | $graph $data_root/$part $dec_dir & 33 | else 34 | echo "$dec_dir exists. skip" 35 | fi 36 | done 37 | 38 | wait 39 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/unsupervised/kaldi_self_train/st/local/prepare_lm.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | langdir="" 4 | lmdir="" 5 | 6 | . ./cmd.sh 7 | . ./path.sh 8 | . parse_options.sh 9 | 10 | arpa_lm=$1 11 | data=$2 12 | 13 | if [ -z $langdir ]; then 14 | langdir=$data/lang 15 | fi 16 | if [ -z $lmdir ]; then 17 | lmdir=$data/lang_test 18 | fi 19 | 20 | if [ ! -d $langdir ]; then 21 | echo "$langdir not found. run local/prepare_lang.sh first" && exit 1 22 | fi 23 | 24 | mkdir -p $lmdir 25 | cp -r $langdir/* $lmdir 26 | 27 | if [[ "$arpa_lm" == *.gz ]]; then 28 | gunzip -c $arpa_lm | arpa2fst --disambig-symbol=#0 --read-symbol-table=$lmdir/words.txt - $lmdir/G.fst 29 | else 30 | arpa2fst --disambig-symbol=#0 --read-symbol-table=$lmdir/words.txt $arpa_lm $lmdir/G.fst 31 | fi 32 | fstisstochastic $lmdir/G.fst 33 | utils/validate_lang.pl $lmdir || exit 1 34 | 35 | echo "done preparing lm ($lmdir)" 36 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/unsupervised/kaldi_self_train/st/path.sh: -------------------------------------------------------------------------------- 1 | export KALDI_ROOT=`pwd`/../../.. 2 | export PATH=$PWD/utils/:$KALDI_ROOT/tools/openfst/bin:$PWD:$PATH 3 | [ ! -f $KALDI_ROOT/tools/config/common_path.sh ] && echo >&2 "The standard file $KALDI_ROOT/tools/config/common_path.sh is not present -> Exit!" && exit 1 4 | . $KALDI_ROOT/tools/config/common_path.sh 5 | export LC_ALL=C 6 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/unsupervised/kaldi_self_train/st/steps: -------------------------------------------------------------------------------- 1 | ../../wsj/s5/steps -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/unsupervised/kaldi_self_train/st/utils: -------------------------------------------------------------------------------- 1 | ../../wsj/s5/utils -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/unsupervised/models/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .wav2vec_u import Wav2vec_U 7 | 8 | 9 | __all__ = [ 10 | "Wav2vec_U", 11 | ] 12 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/unsupervised/scripts/copy_labels.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 -u 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | import sys 8 | 9 | for idx, line in enumerate(sys.stdin): 10 | print(f"utt{idx:010d} {line}", end="") 11 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/unsupervised/scripts/ltr_to_wrd.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 -u 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | import sys 8 | 9 | 10 | def main(): 11 | for line in sys.stdin: 12 | print(line.replace(" ", "").replace("|", " ").strip()) 13 | 14 | 15 | if __name__ == "__main__": 16 | main() 17 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/unsupervised/scripts/normalize_text.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | import regex 8 | import sys 9 | 10 | 11 | def main(): 12 | filter_r = regex.compile(r"[^\p{L}\p{N}\p{M}\' \-]") 13 | 14 | for line in sys.stdin: 15 | line = line.strip() 16 | line = filter_r.sub(" ", line) 17 | line = " ".join(line.split()) 18 | print(line) 19 | 20 | 21 | if __name__ == "__main__": 22 | main() 23 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/unsupervised/scripts/wrd_to_ltr.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 -u 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | import sys 8 | 9 | 10 | def main(): 11 | for line in sys.stdin: 12 | print(" ".join(list(line.strip().replace(" ", "|"))) + " |") 13 | 14 | 15 | if __name__ == "__main__": 16 | main() 17 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wav2vec/unsupervised/tasks/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .unpaired_audio_text import UnpairedAudioText 7 | 8 | 9 | __all__ = [ 10 | "UnpairedAudioText", 11 | ] 12 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/examples/wmt21/README.md: -------------------------------------------------------------------------------- 1 | # WMT 21 2 | 3 | This page provides pointers to the models of Facebook AI's WMT'21 news translation task submission [(Tran et al., 2021)](https://arxiv.org/abs/2108.03265). 4 | 5 | ## Single best dense models 6 | 7 | Model | Description | Download 8 | ---|---|--- 9 | `wmt21.dense-24-wide.X-En` | X-En | [download (.tar.gz)](https://dl.fbaipublicfiles.com/fairseq/models/wmt21.dense-24-wide.X-En.tar.gz) 10 | `wmt21.dense-24-wide.En-X` | En-X | [download (.tar.gz)](https://dl.fbaipublicfiles.com/fairseq/models/wmt21.dense-24-wide.En-X.tar.gz) 11 | 12 | ## Example usage 13 | 14 | See eval.sh 15 | 16 | 17 | ## Citation 18 | ```bibtex 19 | @inproceedings{tran2021facebook 20 | title={Facebook AI’s WMT21 News Translation Task Submission}, 21 | author={Chau Tran and Shruti Bhosale and James Cross and Philipp Koehn and Sergey Edunov and Angela Fan}, 22 | booktitle={Proc. of WMT}, 23 | year={2021}, 24 | } 25 | ``` 26 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/benchmark/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | # import models/tasks to register them 7 | from . import dummy_dataset, dummy_lm, dummy_masked_lm, dummy_model, dummy_mt # noqa 8 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/clib/libnat_cuda/edit_dist.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | 13 | torch::Tensor LevenshteinDistanceCuda( 14 | torch::Tensor source, 15 | torch::Tensor target, 16 | torch::Tensor source_length, 17 | torch::Tensor target_length); 18 | 19 | torch::Tensor GenerateDeletionLabelCuda( 20 | torch::Tensor source, 21 | torch::Tensor operations); 22 | 23 | std::pair GenerateInsertionLabelCuda( 24 | torch::Tensor source, 25 | torch::Tensor operations); 26 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/config/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/config/config.yaml: -------------------------------------------------------------------------------- 1 | # @package _group_ 2 | 3 | hydra: 4 | run: 5 | dir: . 6 | 7 | defaults: 8 | - _self_ 9 | - task: null 10 | - model: null 11 | - criterion: cross_entropy 12 | - optimizer: null 13 | - lr_scheduler: fixed 14 | - bpe: null 15 | - tokenizer: null 16 | - scoring: null 17 | - generation: null 18 | - common_eval: null 19 | - eval_lm: null 20 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/config/fb_run_config/slurm.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | 3 | hydra: 4 | job: 5 | config: 6 | override_dirname: 7 | kv_sep: ':' 8 | item_sep: '__' 9 | exclude_keys: 10 | - fb_run_config 11 | - distributed_training.distributed_port 12 | sweep: 13 | dir: /checkpoint/${env:USER}/${env:PREFIX}/${hydra.job.config_name}_${hydra.launcher.gpus_per_node}/${hydra.job.override_dirname} 14 | launcher: 15 | cpus_per_task: 60 16 | gpus_per_node: ??? 17 | tasks_per_node: 1 18 | nodes: 1 19 | partition: learnfair 20 | mem_gb: 400 21 | timeout_min: 4320 22 | max_num_timeout: 10 23 | name: ${env:PREFIX}_${hydra.job.config_name} 24 | submitit_folder: ${hydra.sweep.dir} 25 | 26 | distributed_training: 27 | ddp_backend: c10d 28 | distributed_world_size: ??? 29 | distributed_port: ??? 30 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/config/model/wav2vec/vq_wav2vec_gumbel.yaml: -------------------------------------------------------------------------------- 1 | # @package _group_ 2 | activation: gelu 3 | vq_type: gumbel 4 | vq_depth: 2 5 | combine_groups: true 6 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/config/model/wav2vec2/wav2vec2_base.yaml: -------------------------------------------------------------------------------- 1 | # @package _group_ 2 | 3 | quantize_targets: true 4 | final_dim: 256 5 | encoder_layerdrop: 0.05 6 | dropout_input: 0.1 7 | dropout_features: 0.1 8 | feature_grad_mult: 0.1 9 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/config/model/wav2vec2/wav2vec2_large.yaml: -------------------------------------------------------------------------------- 1 | # @package _group_ 2 | 3 | quantize_targets: true 4 | extractor_mode: layer_norm 5 | layer_norm_first: true 6 | final_dim: 768 7 | latent_temp: [2.0,0.1,0.999995] 8 | encoder_layerdrop: 0.0 9 | dropout_input: 0.0 10 | dropout_features: 0.0 11 | dropout: 0.0 12 | attention_dropout: 0.0 13 | conv_bias: true 14 | 15 | encoder_layers: 24 16 | encoder_embed_dim: 1024 17 | encoder_ffn_embed_dim: 4096 18 | encoder_attention_heads: 16 19 | 20 | feature_grad_mult: 1.0 21 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/data/encoders/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | 7 | import importlib 8 | import os 9 | 10 | from fairseq import registry 11 | 12 | 13 | build_tokenizer, register_tokenizer, TOKENIZER_REGISTRY, _ = registry.setup_registry( 14 | "--tokenizer", 15 | default=None, 16 | ) 17 | 18 | 19 | build_bpe, register_bpe, BPE_REGISTRY, _ = registry.setup_registry( 20 | "--bpe", 21 | default=None, 22 | ) 23 | 24 | 25 | # automatically import any Python files in the encoders/ directory 26 | for file in sorted(os.listdir(os.path.dirname(__file__))): 27 | if file.endswith(".py") and not file.startswith("_"): 28 | module = file[: file.find(".py")] 29 | importlib.import_module("fairseq.data.encoders." + module) 30 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/data/encoders/characters.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | 7 | from fairseq.data.encoders import register_bpe 8 | 9 | 10 | SPACE = chr(32) 11 | SPACE_ESCAPE = chr(9601) 12 | 13 | 14 | @register_bpe("characters") 15 | class Characters(object): 16 | def __init__(self, *unused): 17 | pass 18 | 19 | @staticmethod 20 | def add_args(parser): 21 | pass 22 | 23 | @staticmethod 24 | def encode(x: str) -> str: 25 | escaped = x.replace(SPACE, SPACE_ESCAPE) 26 | return SPACE.join(list(escaped)) 27 | 28 | @staticmethod 29 | def decode(x: str) -> str: 30 | return x.replace(SPACE, "").replace(SPACE_ESCAPE, SPACE) 31 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/data/encoders/nltk_tokenizer.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from fairseq.data.encoders import register_tokenizer 7 | from fairseq.dataclass import FairseqDataclass 8 | 9 | 10 | @register_tokenizer("nltk", dataclass=FairseqDataclass) 11 | class NLTKTokenizer(object): 12 | def __init__(self, *unused): 13 | try: 14 | from nltk.tokenize import word_tokenize 15 | 16 | self.word_tokenize = word_tokenize 17 | except ImportError: 18 | raise ImportError("Please install nltk with: pip install nltk") 19 | 20 | def encode(self, x: str) -> str: 21 | return " ".join(self.word_tokenize(x)) 22 | 23 | def decode(self, x: str) -> str: 24 | return x 25 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/data/encoders/space_tokenizer.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import re 7 | 8 | from fairseq.data.encoders import register_tokenizer 9 | from fairseq.dataclass import FairseqDataclass 10 | 11 | 12 | @register_tokenizer("space", dataclass=FairseqDataclass) 13 | class SpaceTokenizer(object): 14 | def __init__(self, *unused): 15 | self.space_tok = re.compile(r"\s+") 16 | 17 | def encode(self, x: str) -> str: 18 | return self.space_tok.sub(" ", x) 19 | 20 | def decode(self, x: str) -> str: 21 | return x 22 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/data/huffman/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .huffman_coder import HuffmanCodeBuilder, HuffmanCoder 7 | from .huffman_mmap_indexed_dataset import ( 8 | HuffmanMMapIndex, 9 | HuffmanMMapIndexedDataset, 10 | HuffmanMMapIndexedDatasetBuilder, 11 | vocab_file_path, 12 | ) 13 | 14 | __all__ = [ 15 | "HuffmanCoder", 16 | "HuffmanCodeBuilder", 17 | "HuffmanMMapIndexedDatasetBuilder", 18 | "HuffmanMMapIndexedDataset", 19 | "HuffmanMMapIndex", 20 | "vocab_file_path", 21 | ] 22 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/data/id_dataset.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import torch 7 | 8 | from . import FairseqDataset 9 | 10 | 11 | class IdDataset(FairseqDataset): 12 | def __getitem__(self, index): 13 | return index 14 | 15 | def __len__(self): 16 | return 0 17 | 18 | def collater(self, samples): 19 | return torch.tensor(samples) 20 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/data/legacy/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .block_pair_dataset import BlockPairDataset 7 | from .masked_lm_dataset import MaskedLMDataset 8 | from .masked_lm_dictionary import BertDictionary, MaskedLMDictionary 9 | 10 | 11 | __all__ = [ 12 | "BertDictionary", 13 | "BlockPairDataset", 14 | "MaskedLMDataset", 15 | "MaskedLMDictionary", 16 | ] 17 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/data/list_dataset.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from . import BaseWrapperDataset 7 | 8 | 9 | class ListDataset(BaseWrapperDataset): 10 | def __init__(self, dataset, sizes=None): 11 | super().__init__(dataset) 12 | self._sizes = sizes 13 | 14 | def __iter__(self): 15 | for x in self.dataset: 16 | yield x 17 | 18 | def collater(self, samples): 19 | return samples 20 | 21 | @property 22 | def sizes(self): 23 | return self._sizes 24 | 25 | def num_tokens(self, index): 26 | return self.sizes[index] 27 | 28 | def size(self, index): 29 | return self.sizes[index] 30 | 31 | def set_epoch(self, epoch): 32 | pass 33 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/data/lru_cache_dataset.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from functools import lru_cache 7 | 8 | from . import BaseWrapperDataset 9 | 10 | 11 | class LRUCacheDataset(BaseWrapperDataset): 12 | def __init__(self, dataset, token=None): 13 | super().__init__(dataset) 14 | 15 | @lru_cache(maxsize=8) 16 | def __getitem__(self, index): 17 | return self.dataset[index] 18 | 19 | @lru_cache(maxsize=8) 20 | def collater(self, samples): 21 | return self.dataset.collater(samples) 22 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/data/multilingual/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/data/num_samples_dataset.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from . import FairseqDataset 7 | 8 | 9 | class NumSamplesDataset(FairseqDataset): 10 | def __getitem__(self, index): 11 | return 1 12 | 13 | def __len__(self): 14 | return 0 15 | 16 | def collater(self, samples): 17 | return sum(samples) 18 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/data/numel_dataset.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import numpy as np 7 | import torch 8 | 9 | from . import BaseWrapperDataset 10 | 11 | 12 | class NumelDataset(BaseWrapperDataset): 13 | def __init__(self, dataset, reduce=False): 14 | super().__init__(dataset) 15 | self.reduce = reduce 16 | 17 | def __getitem__(self, index): 18 | item = self.dataset[index] 19 | if torch.is_tensor(item): 20 | return torch.numel(item) 21 | else: 22 | return np.size(item) 23 | 24 | def __len__(self): 25 | return len(self.dataset) 26 | 27 | def collater(self, samples): 28 | if self.reduce: 29 | return sum(samples) 30 | else: 31 | return torch.tensor(samples) 32 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/data/offset_tokens_dataset.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from . import BaseWrapperDataset 7 | 8 | 9 | class OffsetTokensDataset(BaseWrapperDataset): 10 | def __init__(self, dataset, offset): 11 | super().__init__(dataset) 12 | self.offset = offset 13 | 14 | def __getitem__(self, idx): 15 | return self.dataset[idx] + self.offset 16 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/data/raw_label_dataset.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import torch 7 | 8 | from . import FairseqDataset 9 | 10 | 11 | class RawLabelDataset(FairseqDataset): 12 | def __init__(self, labels): 13 | super().__init__() 14 | self.labels = labels 15 | 16 | def __getitem__(self, index): 17 | return self.labels[index] 18 | 19 | def __len__(self): 20 | return len(self.labels) 21 | 22 | def collater(self, samples): 23 | return torch.tensor(samples) 24 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/data/roll_dataset.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import torch 7 | 8 | from . import BaseWrapperDataset 9 | 10 | 11 | class RollDataset(BaseWrapperDataset): 12 | def __init__(self, dataset, shifts): 13 | super().__init__(dataset) 14 | self.shifts = shifts 15 | 16 | def __getitem__(self, index): 17 | item = self.dataset[index] 18 | return torch.roll(item, self.shifts) 19 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/data/sort_dataset.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import numpy as np 7 | 8 | from . import BaseWrapperDataset 9 | 10 | 11 | class SortDataset(BaseWrapperDataset): 12 | def __init__(self, dataset, sort_order): 13 | super().__init__(dataset) 14 | if not isinstance(sort_order, (list, tuple)): 15 | sort_order = [sort_order] 16 | self.sort_order = sort_order 17 | 18 | assert all(len(so) == len(dataset) for so in sort_order) 19 | 20 | def ordered_indices(self): 21 | return np.lexsort(self.sort_order) 22 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/data/strip_token_dataset.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from . import BaseWrapperDataset 7 | 8 | 9 | class StripTokenDataset(BaseWrapperDataset): 10 | def __init__(self, dataset, id_to_strip): 11 | super().__init__(dataset) 12 | self.id_to_strip = id_to_strip 13 | 14 | def __getitem__(self, index): 15 | item = self.dataset[index] 16 | while len(item) > 0 and item[-1] == self.id_to_strip: 17 | item = item[:-1] 18 | while len(item) > 0 and item[0] == self.id_to_strip: 19 | item = item[1:] 20 | return item 21 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/dataclass/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .configs import FairseqDataclass 7 | from .constants import ChoiceEnum 8 | 9 | 10 | __all__ = [ 11 | "FairseqDataclass", 12 | "ChoiceEnum", 13 | ] 14 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/distributed/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .distributed_timeout_wrapper import DistributedTimeoutWrapper 7 | from .fully_sharded_data_parallel import ( 8 | fsdp_enable_wrap, 9 | fsdp_wrap, 10 | FullyShardedDataParallel, 11 | ) 12 | from .legacy_distributed_data_parallel import LegacyDistributedDataParallel 13 | from .module_proxy_wrapper import ModuleProxyWrapper 14 | from .tpu_distributed_data_parallel import TPUDistributedDataParallel 15 | 16 | 17 | __all__ = [ 18 | "DistributedTimeoutWrapper", 19 | "fsdp_enable_wrap", 20 | "fsdp_wrap", 21 | "FullyShardedDataParallel", 22 | "LegacyDistributedDataParallel", 23 | "ModuleProxyWrapper", 24 | "TPUDistributedDataParallel", 25 | ] 26 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/logging/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/fairseq/logging/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/model_parallel/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from . import criterions, models, modules # noqa 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/model_parallel/criterions/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import importlib 7 | import os 8 | 9 | 10 | # automatically import any Python files in the criterions/ directory 11 | for file in sorted(os.listdir(os.path.dirname(__file__))): 12 | if file.endswith(".py") and not file.startswith("_"): 13 | module = file[: file.find(".py")] 14 | importlib.import_module("fairseq.model_parallel.criterions." + module) 15 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/model_parallel/models/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import importlib 7 | import os 8 | 9 | 10 | # automatically import any Python files in the models/ directory 11 | models_dir = os.path.dirname(__file__) 12 | for file in os.listdir(models_dir): 13 | path = os.path.join(models_dir, file) 14 | if ( 15 | not file.startswith("_") 16 | and not file.startswith(".") 17 | and (file.endswith(".py") or os.path.isdir(path)) 18 | ): 19 | model_name = file[: file.find(".py")] if file.endswith(".py") else file 20 | module = importlib.import_module("fairseq.model_parallel.models." + model_name) 21 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/model_parallel/models/pipeline_parallel_transformer/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .model import * # noqa 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/model_parallel/models/roberta/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .model import * # noqa 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/model_parallel/modules/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | """isort:skip_file""" 6 | 7 | from .multihead_attention import ModelParallelMultiheadAttention 8 | from .transformer_layer import ( 9 | ModelParallelTransformerEncoderLayer, 10 | ModelParallelTransformerDecoderLayer, 11 | ) 12 | 13 | __all__ = [ 14 | "ModelParallelMultiheadAttention", 15 | "ModelParallelTransformerEncoderLayer", 16 | "ModelParallelTransformerDecoderLayer", 17 | ] 18 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/models/bart/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .hub_interface import * # noqa 7 | from .model import * # noqa 8 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/models/ema/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import importlib 7 | import os 8 | 9 | from .ema import EMA 10 | 11 | 12 | def build_ema(model, cfg, device): 13 | return EMA(model, cfg, device) 14 | 15 | 16 | # automatically import any Python files in the models/ema/ directory 17 | for file in sorted(os.listdir(os.path.dirname(__file__))): 18 | if file.endswith(".py") and not file.startswith("_"): 19 | file_name = file[: file.find(".py")] 20 | importlib.import_module("fairseq.models.ema." + file_name) 21 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/models/hubert/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .hubert import * # noqa 7 | from .hubert_asr import * # noqa 8 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/models/huggingface/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import importlib 7 | import os 8 | 9 | 10 | # automatically import any Python files in the models/huggingface/ directory 11 | models_dir = os.path.dirname(__file__) 12 | for file in os.listdir(models_dir): 13 | path = os.path.join(models_dir, file) 14 | if ( 15 | not file.startswith("_") 16 | and not file.startswith(".") 17 | and (file.endswith(".py") or os.path.isdir(path)) 18 | ): 19 | model_name = file[: file.find(".py")] if file.endswith(".py") else file 20 | module = importlib.import_module("fairseq.models.huggingface." + model_name) 21 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/models/multires_hubert/__init__.py: -------------------------------------------------------------------------------- 1 | from .multires_hubert import * # noqa 2 | from .multires_hubert_asr import * # noqa 3 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/models/nat/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | """isort:skip_file""" 6 | 7 | from .fairseq_nat_model import * 8 | from .nonautoregressive_transformer import * 9 | from .nat_crf_transformer import * 10 | from .iterative_nonautoregressive_transformer import * 11 | from .cmlm_transformer import * 12 | from .levenshtein_transformer import * 13 | from .insertion_transformer import * 14 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/models/roberta/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .hub_interface import * # noqa 7 | from .model import * # noqa 8 | from .enc_dec import * # noqa 9 | from .model_camembert import * # noqa 10 | from .model_gottbert import * # noqa 11 | from .model_xlmr import * # noqa 12 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/models/speech_dlm/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .speech_dlm import * # noqa 7 | from .hub_interface import * # noqa 8 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/models/speech_dlm/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/fairseq/models/speech_dlm/modules/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/models/speech_dlm/sequence_generator/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .multichannel_sequence_generator import * # noqa 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/models/speech_to_speech/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .s2s_conformer import * # noqa 7 | from .s2s_conformer_translatotron2 import * # noqa 8 | from .s2s_conformer_unity import * # noqa 9 | from .s2s_transformer import * # noqa 10 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/models/speech_to_speech/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/fairseq/models/speech_to_speech/modules/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/models/speech_to_speech/modules/ctc_decoder.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from torch import nn 7 | 8 | from fairseq.models import FairseqEncoder 9 | 10 | 11 | class CTCDecoder(FairseqEncoder): 12 | def __init__(self, dictionary, in_dim): 13 | super().__init__(dictionary) 14 | self.proj = nn.Linear(in_dim, len(dictionary)) 15 | 16 | def forward(self, src_tokens, src_lengths=None, **kwargs): 17 | encoder_out = self.proj(src_tokens) 18 | return {"encoder_out": encoder_out} 19 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/models/speech_to_text/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .berard import * # noqa 7 | from .convtransformer import * # noqa 8 | from .multi_modality_model import * # noqa 9 | from .s2t_conformer import * # noqa 10 | from .s2t_transformer import * # noqa 11 | from .s2t_wav_transformer import * # noqa 12 | from .xm_transformer import * # noqa 13 | from .xm_transformer_unity import * # noqa 14 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/models/speech_to_text/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/fairseq/models/speech_to_text/modules/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/models/text_to_speech/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .tacotron2 import * # noqa 7 | from .tts_transformer import * # noqa 8 | from .fastspeech2 import * # noqa 9 | from .vocoder import * # noqa 10 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/models/wav2vec/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .wav2vec import * # noqa 7 | from .wav2vec2 import * # noqa 8 | from .wav2vec2_asr import * # noqa 9 | from .wav2vec2_laser import * # noqa 10 | from .wav2vec2_classification import * # noqa 11 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/models/wav2vec/utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import math 7 | import torch.nn.functional as F 8 | 9 | 10 | def pad_to_multiple(x, multiple, dim=-1, value=0): 11 | # Inspired from https://github.com/lucidrains/local-attention/blob/master/local_attention/local_attention.py#L41 12 | if x is None: 13 | return None, 0 14 | tsz = x.size(dim) 15 | m = tsz / multiple 16 | remainder = math.ceil(m) * multiple - tsz 17 | if m.is_integer(): 18 | return x, 0 19 | pad_offset = (0,) * (-1 - dim) * 2 20 | 21 | return F.pad(x, (*pad_offset, 0, remainder), value=value), remainder 22 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/models/xmod/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .model import * # noqa 7 | from .transformer_layer_xmod import * # noqa 8 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/modules/dynamicconv_layer/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .dynamicconv_layer import DynamicconvLayer # noqa 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/modules/dynamicconv_layer/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | from setuptools import setup 8 | from torch.utils.cpp_extension import BuildExtension, CUDAExtension 9 | 10 | 11 | setup( 12 | name="dynamicconv_layer", 13 | ext_modules=[ 14 | CUDAExtension( 15 | name="dynamicconv_cuda", 16 | sources=[ 17 | "dynamicconv_cuda.cpp", 18 | "dynamicconv_cuda_kernel.cu", 19 | ], 20 | ), 21 | ], 22 | cmdclass={"build_ext": BuildExtension}, 23 | ) 24 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/modules/fp32_group_norm.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | """ 6 | Layer norm done in fp32 (for fp16 training) 7 | """ 8 | 9 | import torch.nn as nn 10 | import torch.nn.functional as F 11 | 12 | 13 | class Fp32GroupNorm(nn.GroupNorm): 14 | def __init__(self, *args, **kwargs): 15 | super().__init__(*args, **kwargs) 16 | 17 | def forward(self, input): 18 | output = F.group_norm( 19 | input.float(), 20 | self.num_groups, 21 | self.weight.float() if self.weight is not None else None, 22 | self.bias.float() if self.bias is not None else None, 23 | self.eps, 24 | ) 25 | return output.type_as(input) 26 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/modules/gelu.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | """ 6 | See "Gaussian Error Linear Units (GELUs)" by Dan Hendrycks and Kevin Gimpel with 7 | the corresponding GitHub repo: https://github.com/hendrycks/GELUs 8 | """ 9 | 10 | import math 11 | 12 | import torch 13 | import torch.nn as nn 14 | 15 | 16 | def gelu_accurate(x): 17 | if not hasattr(gelu_accurate, "_a"): 18 | gelu_accurate._a = math.sqrt(2 / math.pi) 19 | return ( 20 | 0.5 * x * (1 + torch.tanh(gelu_accurate._a * (x + 0.044715 * torch.pow(x, 3)))) 21 | ) 22 | 23 | 24 | def gelu(x: torch.Tensor) -> torch.Tensor: 25 | return torch.nn.functional.gelu(x.float()).type_as(x) 26 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/modules/grad_multiply.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import torch 7 | 8 | 9 | class GradMultiply(torch.autograd.Function): 10 | @staticmethod 11 | def forward(ctx, x, scale): 12 | ctx.scale = scale 13 | res = x.new(x) 14 | return res 15 | 16 | @staticmethod 17 | def backward(ctx, grad): 18 | return grad * ctx.scale, None 19 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/modules/lightconv_layer/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .lightconv_layer import LightconvLayer # noqa 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/modules/lightconv_layer/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | from setuptools import setup 8 | from torch.utils.cpp_extension import BuildExtension, CUDAExtension 9 | 10 | 11 | setup( 12 | name="lightconv_layer", 13 | ext_modules=[ 14 | CUDAExtension( 15 | "lightconv_cuda", 16 | [ 17 | "lightconv_cuda.cpp", 18 | "lightconv_cuda_kernel.cu", 19 | ], 20 | ), 21 | ], 22 | cmdclass={"build_ext": BuildExtension}, 23 | ) 24 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/modules/quantization/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/fairseq/modules/quantization/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/modules/quantization/pq/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .utils import SizeTracker, get_param, attrsetter, quantize_model_ # NOQA 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/modules/quantization/pq/modules/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .qconv import PQConv2d # NOQA 7 | from .qemb import PQEmbedding # NOQA 8 | from .qlinear import PQLinear # NOQA 9 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/modules/quantization/scalar/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .utils import quantize_model_ # NOQA 7 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/modules/quantization/scalar/modules/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .qact import ActivationQuantizer # NOQA 7 | from .qconv import IntConv2d # NOQA 8 | from .qemb import IntEmbedding # NOQA 9 | from .qlinear import IntLinear # NOQA 10 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/modules/transpose_last.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | """ 6 | transpose last 2 dimensions of the input 7 | """ 8 | 9 | import torch.nn as nn 10 | 11 | 12 | class TransposeLast(nn.Module): 13 | def __init__(self, deconstruct_idx=None, tranpose_dim=-2): 14 | super().__init__() 15 | self.deconstruct_idx = deconstruct_idx 16 | self.tranpose_dim = tranpose_dim 17 | 18 | def forward(self, x): 19 | if self.deconstruct_idx is not None: 20 | x = x[self.deconstruct_idx] 21 | return x.transpose(self.tranpose_dim, -1) 22 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/modules/unfold.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import torch.nn.functional as F 7 | 8 | 9 | def unfold1d(x, kernel_size: int, padding_l: int, pad_value: float = 0): 10 | """unfold T x B x C to T x B x C x K""" 11 | if kernel_size > 1: 12 | T, B, C = x.size() 13 | x = F.pad( 14 | x, (0, 0, 0, 0, padding_l, kernel_size - 1 - padding_l), value=pad_value 15 | ) 16 | x = x.as_strided((T, B, C, kernel_size), (B * C, C, 1, B * C)) 17 | else: 18 | x = x.unsqueeze(3) 19 | return x 20 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/tokenizer.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import re 7 | 8 | 9 | SPACE_NORMALIZER = re.compile(r"\s+") 10 | 11 | 12 | def tokenize_line(line): 13 | line = SPACE_NORMALIZER.sub(" ", line) 14 | line = line.strip() 15 | return line.split() 16 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq/version.txt: -------------------------------------------------------------------------------- 1 | 0.12.2 2 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/fairseq_cli/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/fairseq_cli/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/hydra_plugins/dependency_submitit_launcher/hydra_plugins/dependency_submitit_launcher/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | __version__ = "0.1" 4 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/hydra_plugins/dependency_submitit_launcher/hydra_plugins/dependency_submitit_launcher/config.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from dataclasses import dataclass, field 3 | 4 | from hydra.core.config_store import ConfigStore 5 | 6 | from hydra_plugins.hydra_submitit_launcher.config import SlurmQueueConf 7 | 8 | 9 | @dataclass 10 | class DependencySubmititConf(SlurmQueueConf): 11 | """Slurm configuration overrides and specific parameters""" 12 | 13 | _target_: str = ( 14 | "hydra_plugins.dependency_submitit_launcher.launcher.DependencySubmititLauncher" 15 | ) 16 | 17 | 18 | ConfigStore.instance().store( 19 | group="hydra/launcher", 20 | name="dependency_submitit_slurm", 21 | node=DependencySubmititConf(), 22 | provider="dependency_submitit_slurm", 23 | ) 24 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/scripts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/scripts/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/scripts/compound_split_bleu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -ne 1 ]; then 4 | echo "usage: $0 GENERATE_PY_OUTPUT" 5 | exit 1 6 | fi 7 | 8 | GEN=$1 9 | 10 | SYS=$GEN.sys 11 | REF=$GEN.ref 12 | 13 | if [ $(tail -n 1 $GEN | grep BLEU | wc -l) -ne 1 ]; then 14 | echo "not done generating" 15 | exit 16 | fi 17 | 18 | grep ^H $GEN | awk -F '\t' '{print $NF}' | perl -ple 's{(\S)-(\S)}{$1 ##AT##-##AT## $2}g' > $SYS 19 | grep ^T $GEN | cut -f2- | perl -ple 's{(\S)-(\S)}{$1 ##AT##-##AT## $2}g' > $REF 20 | fairseq-score --sys $SYS --ref $REF 21 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/scripts/sacrebleu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -ne 4 ]; then 4 | echo "usage: $0 TESTSET SRCLANG TGTLANG GEN" 5 | exit 1 6 | fi 7 | 8 | TESTSET=$1 9 | SRCLANG=$2 10 | TGTLANG=$3 11 | 12 | GEN=$4 13 | 14 | if ! command -v sacremoses &> /dev/null 15 | then 16 | echo "sacremoses could not be found, please install with: pip install sacremoses" 17 | exit 18 | fi 19 | 20 | grep ^H $GEN \ 21 | | sed 's/^H\-//' \ 22 | | sort -n -k 1 \ 23 | | cut -f 3 \ 24 | | sacremoses detokenize \ 25 | > $GEN.sorted.detok 26 | 27 | sacrebleu --test-set $TESTSET --language-pair "${SRCLANG}-${TGTLANG}" < $GEN.sorted.detok 28 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/scripts/spm_train.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # All rights reserved. 4 | # 5 | # This source code is licensed under the license found in the 6 | # LICENSE file in the root directory of this source tree. 7 | 8 | from __future__ import absolute_import, division, print_function, unicode_literals 9 | 10 | import sys 11 | 12 | import sentencepiece as spm 13 | 14 | 15 | if __name__ == "__main__": 16 | spm.SentencePieceTrainer.Train(" ".join(sys.argv[1:])) 17 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/setup.cfg: -------------------------------------------------------------------------------- 1 | [flake8] 2 | max-line-length = 127 3 | extend-ignore = E203, W503 4 | extend-exclude = fairseq/model_parallel/megatron 5 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/tests/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/tests/distributed/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/tests/distributed/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/tests/gpu/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/tests/gpu/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/tests/gpu/transformer_quantization_config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | # This file defines example configuration arguments for quantizing 7 | # a transformer model with product quantization 8 | 9 | n_centroids: 10 | Linear: 11 | key: in_features 12 | value: {"*": 8} 13 | Embedding: 14 | key: embedding_dim 15 | value: {"*": 8} 16 | 17 | block_sizes: 18 | Linear: 19 | key: fuzzy_name 20 | value: {fc: 8, attn: 4, emb: 4} 21 | Embedding: 22 | key: fuzzy_name 23 | value: {emb: 8} 24 | 25 | layers_to_quantize: 26 | - decoder\\.layers\\.\d+\\.fc[12] 27 | - decoder\\.embed_tokens\\.embeddings\\.[012]\\.[01] 28 | - decoder\\.layers\\.\d+\\.self_attn\\.(k_proj|v_proj|q_proj|out_proj) 29 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/tests/speech/test_s2t_conformer.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import unittest 7 | from tests.speech import TestFairseqSpeech 8 | 9 | 10 | class TestS2TConformer(TestFairseqSpeech): 11 | def setUp(self): 12 | self.set_up_librispeech() 13 | 14 | def test_librispeech_s2t_conformer_s_checkpoint(self): 15 | self.base_test( 16 | ckpt_name="librispeech_conformer_rel_pos_s.pt", 17 | reference_score=12, 18 | arg_overrides={"config_yaml": "cfg_librispeech.yaml"}, 19 | ) 20 | 21 | 22 | if __name__ == "__main__": 23 | unittest.main() 24 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/tests/speech/test_s2t_transformer.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import unittest 7 | from tests.speech import TestFairseqSpeech 8 | 9 | 10 | class TestS2TTransformer(TestFairseqSpeech): 11 | def setUp(self): 12 | self.set_up_librispeech() 13 | 14 | def test_librispeech_s2t_transformer_s_checkpoint(self): 15 | self.base_test( 16 | ckpt_name="librispeech_transformer_s.pt", 17 | reference_score=9, 18 | arg_overrides={"config_yaml": "cfg_librispeech.yaml"}, 19 | ) 20 | 21 | 22 | if __name__ == "__main__": 23 | unittest.main() 24 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/tests/speech_recognition/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Keqi/mtla/ecd4e823c0380acf539484f58822dbfffbb059ea/experiments/tools/fairseq/tests/speech_recognition/__init__.py -------------------------------------------------------------------------------- /experiments/tools/fairseq/tests/test_hf_hub.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | import unittest 8 | 9 | import torch 10 | 11 | try: 12 | import huggingface_hub 13 | except ImportError: 14 | huggingface_hub = None 15 | 16 | from fairseq.checkpoint_utils import load_model_ensemble_and_task_from_hf_hub 17 | 18 | 19 | @unittest.skipIf(not huggingface_hub, "Requires huggingface_hub install") 20 | class TestHuggingFaceHub(unittest.TestCase): 21 | @torch.no_grad() 22 | def test_hf_fastspeech2(self): 23 | hf_model_id = "facebook/fastspeech2-en-ljspeech" 24 | models, cfg, task = load_model_ensemble_and_task_from_hf_hub(hf_model_id) 25 | self.assertTrue(len(models) > 0) 26 | 27 | 28 | if __name__ == "__main__": 29 | unittest.main() 30 | -------------------------------------------------------------------------------- /experiments/tools/fairseq/train.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 -u 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | """ 7 | Legacy entry point. Use fairseq_cli/train.py or fairseq-train instead. 8 | """ 9 | 10 | from fairseq_cli.train import cli_main 11 | 12 | 13 | if __name__ == "__main__": 14 | cli_main() 15 | -------------------------------------------------------------------------------- /experiments/tools/pyscripts/README.md: -------------------------------------------------------------------------------- 1 | # Python command line utilities developed in ESPnet2 2 | -------------------------------------------------------------------------------- /experiments/tools/pyscripts/audio/trim_silence.py: -------------------------------------------------------------------------------- 1 | ../../../../../utils/trim_silence.py -------------------------------------------------------------------------------- /experiments/tools/pyscripts/feats/feat-to-shape.py: -------------------------------------------------------------------------------- 1 | ../../../../../utils/feat-to-shape.py -------------------------------------------------------------------------------- /experiments/tools/pyscripts/utils/calculate_rtf.py: -------------------------------------------------------------------------------- 1 | ../../../../../utils/calculate_rtf.py -------------------------------------------------------------------------------- /experiments/tools/pyscripts/utils/get_model_names.py: -------------------------------------------------------------------------------- 1 | #!/usr/bine/env python3 2 | import sys 3 | 4 | from espnet_model_zoo.downloader import ModelDownloader 5 | 6 | model_name = sys.argv[1] 7 | d = ModelDownloader() 8 | model_path = d.download(sys.argv[1]) 9 | print(model_path) 10 | -------------------------------------------------------------------------------- /experiments/tools/pyscripts/utils/get_yaml.py: -------------------------------------------------------------------------------- 1 | ../../../../../utils/get_yaml.py -------------------------------------------------------------------------------- /experiments/tools/pyscripts/utils/make_token_list_from_config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import os 5 | 6 | import yaml 7 | 8 | 9 | def get_parser(): 10 | parser = argparse.ArgumentParser( 11 | description="get a specified attribute from a YAML file", 12 | formatter_class=argparse.ArgumentDefaultsHelpFormatter, 13 | ) 14 | parser.add_argument("inyaml") 15 | return parser 16 | 17 | 18 | def main(): 19 | args = get_parser().parse_args() 20 | with open(args.inyaml, "r") as f: 21 | indict = yaml.load(f, Loader=yaml.Loader) 22 | 23 | if "token_list" not in indict: 24 | raise AttributeError("token_list is not found in config.") 25 | 26 | token_list = os.path.dirname(args.inyaml) + "/tokens.txt" 27 | with open(token_list, "w") as f: 28 | for token in indict["token_list"]: 29 | f.write(f"{token}\n") 30 | 31 | 32 | if __name__ == "__main__": 33 | main() 34 | -------------------------------------------------------------------------------- /experiments/tools/pyscripts/utils/score_lang_id.py: -------------------------------------------------------------------------------- 1 | ../../../../../utils/score_lang_id.py -------------------------------------------------------------------------------- /experiments/tools/scripts/README.md: -------------------------------------------------------------------------------- 1 | # Shell scripts developed in ESPnet2 2 | 3 | See also [scripts/audio/format_wav_scp.sh](https://espnet.github.io/espnet/espnet2_format_wav_scp.html). 4 | -------------------------------------------------------------------------------- /experiments/tools/scripts/feats/make_fbank.sh: -------------------------------------------------------------------------------- 1 | ../../../../../utils/make_fbank.sh -------------------------------------------------------------------------------- /experiments/tools/scripts/feats/make_stft.sh: -------------------------------------------------------------------------------- 1 | ../../../../../utils/make_stft.sh -------------------------------------------------------------------------------- /experiments/tools/scripts/utils/download_from_google_drive.sh: -------------------------------------------------------------------------------- 1 | ../../../../../utils/download_from_google_drive.sh -------------------------------------------------------------------------------- /experiments/tools/scripts/utils/remove_punctuation.pl: -------------------------------------------------------------------------------- 1 | ../../../../../utils/remove_punctuation.pl -------------------------------------------------------------------------------- /experiments/tools/sentencepiece_commands/spm_train: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # All rights reserved. 4 | # 5 | # This source code is licensed under the license found in the 6 | # https://github.com/pytorch/fairseq/blob/master/LICENSE 7 | import sys 8 | 9 | import sentencepiece as spm 10 | 11 | if __name__ == "__main__": 12 | spm.SentencePieceTrainer.Train(" ".join(sys.argv[1:])) 13 | -------------------------------------------------------------------------------- /experiments/tools/utils/README.md: -------------------------------------------------------------------------------- 1 | The scripts in this directory were copied from Kaldi-ASR, https://github.com/kaldi-asr/kaldi, and their licenses follow the original license, https://github.com/kaldi-asr/kaldi/blob/master/COPYING, of Kaldi. 2 | -------------------------------------------------------------------------------- /experiments/tools/utils/data/get_segments_for_data.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # This script operates on a data directory, such as in data/train/, 4 | # and writes new segments to stdout. The file 'segments' maps from 5 | # utterance to time offsets into a recording, with the format: 6 | # 7 | # This script assumes utterance and recording ids are the same (i.e., that 8 | # wav.scp is indexed by utterance), and uses durations from 'utt2dur', 9 | # created if necessary by get_utt2dur.sh. 10 | 11 | . ./path.sh 12 | 13 | if [ $# != 1 ]; then 14 | echo "Usage: $0 [options] " 15 | echo "e.g.:" 16 | echo " $0 data/train > data/train/segments" 17 | exit 1 18 | fi 19 | 20 | data=$1 21 | 22 | if [ ! -s $data/utt2dur ]; then 23 | utils/data/get_utt2dur.sh $data 1>&2 || exit 1; 24 | fi 25 | 26 | # 0 27 | awk '{ print $1, $1, 0, $2 }' $data/utt2dur 28 | 29 | exit 0 30 | -------------------------------------------------------------------------------- /experiments/tools/utils/data/subset_data_dir.sh: -------------------------------------------------------------------------------- 1 | ../subset_data_dir.sh -------------------------------------------------------------------------------- /experiments/tools/utils/download_from_google_drive.sh: -------------------------------------------------------------------------------- 1 | ../../../../utils/download_from_google_drive.sh -------------------------------------------------------------------------------- /experiments/tools/utils/fix_data_dir.sh: -------------------------------------------------------------------------------- 1 | data/fix_data_dir.sh -------------------------------------------------------------------------------- /experiments/tools/utils/pbs.pl: -------------------------------------------------------------------------------- 1 | parallel/pbs.pl -------------------------------------------------------------------------------- /experiments/tools/utils/queue.pl: -------------------------------------------------------------------------------- 1 | parallel/queue.pl -------------------------------------------------------------------------------- /experiments/tools/utils/retry.pl: -------------------------------------------------------------------------------- 1 | parallel/retry.pl -------------------------------------------------------------------------------- /experiments/tools/utils/run.pl: -------------------------------------------------------------------------------- 1 | parallel/run.pl -------------------------------------------------------------------------------- /experiments/tools/utils/simple_dict.sh: -------------------------------------------------------------------------------- 1 | ../../../../utils/simple_dict.sh -------------------------------------------------------------------------------- /experiments/tools/utils/slurm.pl: -------------------------------------------------------------------------------- 1 | parallel/slurm.pl --------------------------------------------------------------------------------