logo
Browse Source

add English Russian model.

Signed-off-by: wxywb <xy.wang@zilliz.com>
main
wxywb 2 years ago
parent
commit
a1ac3ea635
  1. 28
      README.md
  2. 9
      opus_mt.py
  3. BIN
      result.png

28
README.md

@ -17,27 +17,19 @@ More detail can be found in [ Helsinki-NLP/Opus-MT ](https://github.com/Helsinki
Use the pre-trained model 'opus-mt-en-zh'
to generate the Chinese translation for the sentence "Hello, world.".
*Write the pipeline*:
*Write a pipeline with explicit inputs/outputs name specifications:*
```python
import towhee
from towhee.dc2 import pipe, ops, DataCollection
(
towhee.dc(["Hello, world."])
.machine_translation.opus_mt(model_name="opus-mt-en-zh")
p = (
pipe.input('text')
.map('text', 'translation', ops.machine_translation.opus_mt(model_name='opus-mt-en-zh'))
.output('text', 'translation')
)
```
*Write a same pipeline with explicit inputs/outputs name specifications:*
```python
import towhee
DataCollection(p('hello, world.')).show()
(
towhee.dc['text'](["Hello, world."])
.machine_translation.opus_mt['text', 'vec'](model_name="opus-mt-en-zh")
.show()
)
```
<img src="./result.png" width="800px"/>
@ -48,7 +40,7 @@ import towhee
Create the operator via the following factory method:
***machine_translatioin.opus_mt(model_name="opus-mt-en-zh")***
***machine_translation.opus_mt(model_name="opus-mt-en-zh")***
**Parameters:**
@ -60,6 +52,10 @@ The default model name is "opus-mt-en-zh".
Supported model names:
- opus-mt-en-zh
- opus-mt-zh-en
- opus-tatoeba-en-ja
- opus-tatoeba-ja-en
- opus-mt-ru-en
- opus-mt-en-ru
<br />

9
opus_mt.py

@ -64,4 +64,13 @@ class OpusMT(NNOperator):
configs['opus-tatoeba-ja-en'] = {}
configs['opus-tatoeba-ja-en']['tokenizer'] = 'Helsinki-NLP/opus-tatoeba-ja-en'
configs['opus-tatoeba-ja-en']['model'] = 'Helsinki-NLP/opus-tatoeba-ja-en'
configs['opus-mt-ru-en'] = {}
configs['opus-mt-ru-en']['tokenizer'] = 'Helsinki-NLP/opus-mt-ru-en'
configs['opus-mt-ru-en']['model'] = 'Helsinki-NLP/opus-mt-ru-en'
configs['opus-mt-en-ru'] = {}
configs['opus-mt-en-ru']['tokenizer'] = 'Helsinki-NLP/opus-mt-en-ru'
configs['opus-mt-en-ru']['model'] = 'Helsinki-NLP/opus-mt-en-ru'
return configs

BIN
result.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Loading…
Cancel
Save