camenduru commited on
Commit
99b9a45
1 Parent(s): 7bd1feb

thanks to facebook ❤

Browse files
Files changed (3) hide show
  1. README.md +117 -0
  2. multitask_unity_large.pt +3 -0
  3. tokenizer.model +3 -0
README.md ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ inference: false
3
+ tags:
4
+ - SeamlessM4T
5
+ license: cc-by-nc-4.0
6
+ ---
7
+
8
+ # SeamlessM4T Large
9
+
10
+ SeamlessM4T is a collection of models designed to provide high quality translation, allowing people from different
11
+ linguistic communities to communicate effortlessly through speech and text.
12
+
13
+ SeamlessM4T covers:
14
+ - 📥 101 languages for speech input
15
+ - ⌨️ 96 Languages for text input/output
16
+ - 🗣️ 35 languages for speech output.
17
+
18
+ This is the "large" variant of the unified model, which enables multiple tasks without relying on multiple separate models:
19
+ - Speech-to-speech translation (S2ST)
20
+ - Speech-to-text translation (S2TT)
21
+ - Text-to-speech translation (T2ST)
22
+ - Text-to-text translation (T2TT)
23
+ - Automatic speech recognition (ASR)
24
+
25
+ ## SeamlessM4T models
26
+
27
+ The SeamlessM4T models come in two checkpoints of different size:
28
+
29
+ | Model Name | #params | checkpoint | metrics |
30
+ | - | - | - | - |
31
+ | [SeamlessM4T-Medium]((https://huggingface.co/facebook/seamless-m4t-medium) | 1.2B | [checkpoint](https://huggingface.co/facebook/seamless-m4t-medium/resolve/main/multitask_unity_medium.pt) | [metrics]() |
32
+ | [SeamlessM4T-Large](https://huggingface.co/facebook/seamless-m4t-large) | 2.3B | [checkpoint](https://huggingface.co/facebook/seamless-m4t-large/resolve/main/multitask_unity_large.pt) | [metrics]() |
33
+
34
+ We provide extensive evaluation results of SeamlessM4T-Medium and SeamlessM4T-Large in the SeamlessM4T paper (as averages) in the `metrics` files above.
35
+
36
+ ## Instructions to run inference with SeamlessM4T models
37
+
38
+ The SeamlessM4T models are currently available through the `seamless_communication` package. The `seamless_communication`
39
+ package can be installed by following the instructions outlined here: [Installation](https://github.com/fairinternal/seamless_communication/tree/main#installation).
40
+
41
+ Once installed, a [`Translator`](https://github.com/fairinternal/seamless_communication/blob/590547965b343b590d15847a0aa25a6779fc3753/src/seamless_communication/models/inference/translator.py#L47)
42
+ object can be instantiated to perform all five of the spoken langauge tasks. The `Translator` is instantiated with three arguments:
43
+ 1. **model_name_or_card**: SeamlessM4T checkpoint. Can be either `seamlessM4T_medium` for the medium model, or `seamlessM4T_large` for the large model
44
+ 2. **vocoder_name_or_card**: vocoder checkpoint (`vocoder_36langs`)
45
+ 3. **device**: Torch device
46
+
47
+ ```python
48
+ import torch
49
+ from seamless_communication.models.inference import Translator
50
+
51
+
52
+ # Initialize a Translator object with a multitask model, vocoder on the GPU.
53
+ translator = Translator("seamlessM4T_large", vocoder_name_or_card="vocoder_36langs", device=torch.device("cuda:0"))
54
+ ```
55
+
56
+ Once instantiated, the `predict()` method can be used to run inference as many times on any of the supported tasks.
57
+
58
+ Given an input audio with `<path_to_input_audio>` or an input text `<input_text>` in `<src_lang>`, we can translate
59
+ into `<tgt_lang>` as follows.
60
+
61
+ ### S2ST and T2ST:
62
+
63
+ ```python
64
+ # S2ST
65
+ translated_text, wav, sr = translator.predict(<path_to_input_audio>, "s2st", <tgt_lang>)
66
+
67
+ # T2ST
68
+ translated_text, wav, sr = translator.predict(<input_text>, "t2st", <tgt_lang>, src_lang=<src_lang>)
69
+ ```
70
+
71
+ Note that `<src_lang>` must be specified for T2ST.
72
+
73
+ The generated units are synthesized and the output audio file is saved with:
74
+
75
+ ```python
76
+ wav, sr = translator.synthesize_speech(<speech_units>, <tgt_lang>)
77
+
78
+ # Save the translated audio generation.
79
+ torchaudio.save(
80
+ <path_to_save_audio>,
81
+ wav[0].cpu(),
82
+ sample_rate=sr,
83
+ )
84
+ ```
85
+
86
+ ### S2TT, T2TT and ASR:
87
+
88
+ ```python
89
+ # S2TT
90
+ translated_text, _, _ = translator.predict(<path_to_input_audio>, "s2tt", <tgt_lang>)
91
+
92
+ # ASR
93
+ # This is equivalent to S2TT with `<tgt_lang>=<src_lang>`.
94
+ transcribed_text, _, _ = translator.predict(<path_to_input_audio>, "asr", <src_lang>)
95
+
96
+ # T2TT
97
+ translated_text, _, _ = translator.predict(<input_text>, "t2tt", <tgt_lang>, src_lang=<src_lang>)
98
+
99
+ ```
100
+ Note that `<src_lang>` must be specified for T2TT.
101
+
102
+ ## Citation
103
+
104
+ If you plan to use SeamlessM4T in your work or any models/datasets/artifacts published in SeamlessM4T, please cite:
105
+
106
+ ```bibtex
107
+ @article{seamlessm4t2023,
108
+ title={"SeamlessM4T—Massively Multilingual \& Multimodal Machine Translation"},
109
+ author={{Seamless Communication}, Lo\"{i}c Barrault, Yu-An Chung, Mariano Cora Meglioli, David Dale, Ning Dong, Paul-Ambroise Duquenne, Hady Elsahar, Hongyu Gong, Kevin Heffernan, John Hoffman, Christopher Klaiber, Pengwei Li, Daniel Licht, Jean Maillard, Alice Rakotoarison, Kaushik Ram Sadagopan, Guillaume Wenzek, Ethan Ye, Bapi Akula, Peng-Jen Chen, Naji El Hachem, Brian Ellis, Gabriel Mejia Gonzalez, Justin Haaheim, Prangthip Hansanti, Russ Howes, Bernie Huang, Min-Jae Hwang, Hirofumi Inaguma, Somya Jain, Elahe Kalbassi, Amanda Kallet, Ilia Kulikov, Janice Lam, Daniel Li, Xutai Ma, Ruslan Mavlyutov, Benjamin Peloquin, Mohamed Ramadan, Abinesh Ramakrishnan, Anna Sun, Kevin Tran, Tuan Tran, Igor Tufanov, Vish Vogeti, Carleigh Wood, Yilin Yang, Bokai Yu, Pierre Andrews, Can Balioglu, Marta R. Costa-juss\`{a} \footnotemark[3], Onur \,{C}elebi,Maha Elbayad,Cynthia Gao, Francisco Guzm\'an, Justine Kao, Ann Lee, Alexandre Mourachko, Juan Pino, Sravya Popuri, Christophe Ropers, Safiyyah Saleem, Holger Schwenk, Paden Tomasello, Changhan Wang, Jeff Wang, Skyler Wang},
110
+ journal={ArXiv},
111
+ year={2023}
112
+ }
113
+ ```
114
+
115
+ ## License
116
+
117
+ The Seamless Communication code and weights are CC-BY-NC 4.0 licensed.
multitask_unity_large.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e26cbd5ed1ac2e794fc8ae4a50023b1feb7a439f92812c142ed507ce04d9b5dc
3
+ size 11446315466
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:026a76827537db9f1348e4d5aaa127bb10a2f2ff633243f3a52d16be82d73f9d
3
+ size 5165809