|
@ -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' |
|
|
Use the pre-trained model 'opus-mt-en-zh' |
|
|
to generate the Chinese translation for the sentence "Hello, world.". |
|
|
to generate the Chinese translation for the sentence "Hello, world.". |
|
|
|
|
|
|
|
|
*Write the pipeline*: |
|
|
|
|
|
|
|
|
*Write a pipeline with explicit inputs/outputs name specifications:* |
|
|
|
|
|
|
|
|
```python |
|
|
```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"/> |
|
|
<img src="./result.png" width="800px"/> |
|
@ -48,7 +40,7 @@ import towhee |
|
|
|
|
|
|
|
|
Create the operator via the following factory method: |
|
|
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:** |
|
|
**Parameters:** |
|
|
|
|
|
|
|
@ -58,8 +50,12 @@ The model name in string. |
|
|
The default model name is "opus-mt-en-zh". |
|
|
The default model name is "opus-mt-en-zh". |
|
|
|
|
|
|
|
|
Supported model names: |
|
|
Supported model names: |
|
|
- opus-mt-en-zh |
|
|
|
|
|
|
|
|
- opus-mt-en-zh |
|
|
- opus-mt-zh-en |
|
|
- opus-mt-zh-en |
|
|
|
|
|
- opus-tatoeba-en-ja |
|
|
|
|
|
- opus-tatoeba-ja-en |
|
|
|
|
|
- opus-mt-ru-en |
|
|
|
|
|
- opus-mt-en-ru |
|
|
|
|
|
|
|
|
<br /> |
|
|
<br /> |
|
|
|
|
|
|
|
|