Browse Source
Update Readme
Signed-off-by: Jael Gu <mengjia.gu@zilliz.com>
main
1 changed files with
12 additions and
8 deletions
-
README.md
|
|
@ -17,18 +17,24 @@ This operator is implemented with pre-trained models from [Huggingface Transform |
|
|
|
Use the pre-trained model 'distilbert-base-cased' |
|
|
|
to generate a text embedding for the sentence "Hello, world.". |
|
|
|
|
|
|
|
*Write the pipeline*: |
|
|
|
*Write a same pipeline with explicit inputs/outputs name specifications:* |
|
|
|
|
|
|
|
- **option 1 (towhee>=0.9.0):** |
|
|
|
```python |
|
|
|
import towhee |
|
|
|
from towhee.dc2 import pipe, ops, DataCollection |
|
|
|
|
|
|
|
( |
|
|
|
towhee.dc(["Hello, world."]) |
|
|
|
.text_embedding.transformers(model_name="distilbert-base-cased") |
|
|
|
p = ( |
|
|
|
pipe.input('text') |
|
|
|
.map('text', 'vec', ops.text_embedding.transformers(model_name='distilbert-base-cased')) |
|
|
|
.output('text', 'vec') |
|
|
|
) |
|
|
|
|
|
|
|
DataCollection(p('Hello, world.')).show() |
|
|
|
``` |
|
|
|
|
|
|
|
*Write a same pipeline with explicit inputs/outputs name specifications:* |
|
|
|
<img src="./result.png" width="800px"/> |
|
|
|
|
|
|
|
- **option 2:** |
|
|
|
|
|
|
|
```python |
|
|
|
import towhee |
|
|
@ -40,8 +46,6 @@ import towhee |
|
|
|
) |
|
|
|
``` |
|
|
|
|
|
|
|
<img src="./result.png" width="800px"/> |
|
|
|
|
|
|
|
<br /> |
|
|
|
|
|
|
|
## Factory Constructor |
|
|
|