Skip to content

Commit 688d42f

Browse files
authored
Merge pull request #3 from translatorswb/main
Update README.md
2 parents 2aad099 + a6e0fd3 commit 688d42f

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

README.md

+13-19
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ API for serving machine translation models.
44

55
It can run three types of translation systems:
66
- [ctranslate2](https://github.com/OpenNMT/CTranslate2) models
7-
- Certain transformer-based models models provided through [huggingface](https://huggingface.co/Helsinki-NLP).
8-
- OPUS
9-
- OPUS-big
10-
- NLLB (Multilingual)
11-
- M2M100 (Multilingual)
7+
- Certain transformer-based models models provided through [huggingface](https://huggingface.co/).
8+
- OPUS and OPUS-big models of [Helsinki-NLP](https://huggingface.co/Helsinki-NLP)
9+
- [NLLB](https://huggingface.co/docs/transformers/v4.28.1/en/model_doc/nllb) (Multilingual)
10+
- [M2M100](https://huggingface.co/docs/transformers/model_doc/m2m_100) (Multilingual)
1211
- Custom translators specified as a python module (Experimental)
1312

1413
Model specifications need to go in `config.json`.
@@ -43,11 +42,11 @@ API configuration file (`config.json`) is where we specify the models to load an
4342

4443
### Custom ctranslate2 model configuration
4544

46-
To load an English to Turkish model, place the following files under `model/entr`:
45+
To load an English to Turkish model, place the following files under `<MODELS_ROOT>/entr`:
4746

4847
- ctranslator2 model as `model.bin`
49-
- (Optional) BPE subword codes file (e.g. `bpe.en-tr.codes`)
50-
- (Optional) Sentencepiece model (To be implemented)
48+
- (Optional) Shared BPE subword codes file `bpe_file` (e.g. `bpe.en-tr.codes`)
49+
- (Optional) Sentencepiece model (`src_sentencepiece_model` and `tgt_sentencepiece_model`)
5150

5251
Add the following configuration under `models` in `config.json`:
5352

@@ -121,18 +120,15 @@ Example configuration supporting bidirectional English-Kanuri, English-French, E
121120
"supported_pairs": ["en-kr", "en-fr", "en-ff", "en-ha"],
122121
"pipeline": {
123122
"translate": true
124-
}
123+
},
124+
"lang_code_map": {"en": "eng_Latn", "tr": "tur_Latn", "fr": "fra_Latn",
125+
"kr": "knc_Latn", "ha": "hau_Latn", "ff": "fuv_Latn","rw": "kin_Latn"}
125126
}
126127
```
127128

128129
Depending on your server architecture, you can choose `checkpoint_id` from `nllb-200-distilled-1.3B`, `nllb-200-distilled-600M` or `nllb-200-3.3B`.
129130

130-
By convention, we use languages in two lettered ISO codes in the configuration file. `app/constants.py` contains the mappings from these codes into the codes used by the NLLB model. This mapping is currently incomplete, so, if you need to add a new language and want to use a language ID other than the one used by NLLB model, you add the mapping into this dictionary. If you prefer, you can use the NLLB id directly in the configuration file as well. The complete list of 200 languages and their respective codes can be viewed through [Flores200 README file](https://github.com/facebookresearch/flores/blob/main/flores200/README.md#languages-in-flores-200).
131-
132-
```
133-
NLLB_LANGS_DICT = {'en': 'eng_Latn', 'tr': 'tur_Latn', 'fr': 'fra_Latn',
134-
'kr': 'knc_Latn', 'ha': 'hau_Latn', 'ff': 'fuv_Latn'}
135-
```
131+
By convention, this API uses two lettered ISO language codes in the configuration file. Since NLLB model uses a different language code convention, you need to create a mapping in the configuration for the correct use of the model (`lang_code_map`). The complete list of 200 languages and their respective codes can be viewed through [Flores200 README file](https://github.com/facebookresearch/flores/blob/main/flores200/README.md#languages-in-flores-200). (If you prefer, you can use the NLLB id directly in the configuration file as well. )
136132

137133
### M2M100 model
138134

@@ -156,13 +152,11 @@ Example configuration supporting bidirectional English-Turkish and English-Spani
156152

157153
Depending on your server architecture, you can choose `checkpoint_id` from `m2m100_418M` and `m2m100_1.2B`.
158154

159-
### WARNING: An `alt` code must be assigned when loading multiple multilingual models.
160-
161155
## Advanced configuration features
162156

163157
### Alternative model loading
164158

165-
By default one model can be loaded to serve a language direction. Although if you'd like to have multiple models for a language pair or want to have multiple multilingual models, you can use the `alt` parameter in your model configuration. For example, let's load both `opus` and `opus-big` models for `en-fr` from huggingface:
159+
By default, one model can be loaded to serve a language direction. Although, if you'd like to have multiple models for a language pair or want to have multiple multilingual models, you can use the `alt` parameter in your model configuration. For example, let's load both `opus` and `opus-big` models for `en-fr` direction from huggingface:
166160

167161
```
168162
{
@@ -188,7 +182,7 @@ By default one model can be loaded to serve a language direction. Although if yo
188182
}
189183
```
190184

191-
To use the big model, you'll need to specify an `alt` parameter as `big`. (Example shown later below)
185+
To use the big model while inference request, you'll need to specify an `alt` parameter as `big`. Otherwise, it'll default to the first loaded model. (Example shown later below)
192186

193187
### Model chaining
194188

0 commit comments

Comments
 (0)