Browse Source
Update README
Signed-off-by: Jael Gu <mengjia.gu@zilliz.com>
main
1 changed files with
12 additions and
9 deletions
-
README.md
|
@ -2,7 +2,7 @@ |
|
|
|
|
|
|
|
|
*author: Kyle He* |
|
|
*author: Kyle He* |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<br /> |
|
|
|
|
|
|
|
|
## Desription |
|
|
## Desription |
|
|
|
|
|
|
|
@ -23,12 +23,14 @@ where embeddings are learned from a small number of questions and passages by a |
|
|
|
|
|
|
|
|
[2].https://arxiv.org/abs/2004.04906 |
|
|
[2].https://arxiv.org/abs/2004.04906 |
|
|
|
|
|
|
|
|
|
|
|
<br /> |
|
|
|
|
|
|
|
|
## Code Example |
|
|
## Code Example |
|
|
|
|
|
|
|
|
Use the pretrained model "facebook/dpr-ctx_encoder-single-nq-base" |
|
|
Use the pretrained model "facebook/dpr-ctx_encoder-single-nq-base" |
|
|
to generate a text embedding for the sentence "Hello, world.". |
|
|
to generate a text embedding for the sentence "Hello, world.". |
|
|
|
|
|
|
|
|
*Write the pipeline*: |
|
|
|
|
|
|
|
|
*Write the pipeline*: |
|
|
|
|
|
|
|
|
```python |
|
|
```python |
|
|
from towhee import dc |
|
|
from towhee import dc |
|
@ -39,6 +41,7 @@ dc.stream(["Hello, world."]) \ |
|
|
.to_list() |
|
|
.to_list() |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
<br /> |
|
|
|
|
|
|
|
|
## Factory Constructor |
|
|
## Factory Constructor |
|
|
|
|
|
|
|
@ -48,12 +51,13 @@ Create the operator via the following factory method |
|
|
|
|
|
|
|
|
**Parameters:** |
|
|
**Parameters:** |
|
|
|
|
|
|
|
|
***model_name***: *str* |
|
|
|
|
|
|
|
|
***model_name***: *str* |
|
|
|
|
|
|
|
|
The model name in string. |
|
|
|
|
|
|
|
|
The model name in string. |
|
|
The default value is "facebook/dpr-ctx_encoder-single-nq-base". |
|
|
The default value is "facebook/dpr-ctx_encoder-single-nq-base". |
|
|
You can get the list of supported model names by calling `get_model_list` from [dpr.py](https://towhee.io/text-embedding/dpr/src/branch/main/dpr.py). |
|
|
You can get the list of supported model names by calling `get_model_list` from [dpr.py](https://towhee.io/text-embedding/dpr/src/branch/main/dpr.py). |
|
|
|
|
|
|
|
|
|
|
|
<br /> |
|
|
|
|
|
|
|
|
## Interface |
|
|
## Interface |
|
|
|
|
|
|
|
@ -63,14 +67,13 @@ and then return text embedding in ndarray. |
|
|
|
|
|
|
|
|
**Parameters:** |
|
|
**Parameters:** |
|
|
|
|
|
|
|
|
***text***: *str* |
|
|
|
|
|
|
|
|
|
|
|
The text in string. |
|
|
|
|
|
|
|
|
***text***: *str* |
|
|
|
|
|
|
|
|
|
|
|
The text in string. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
**Returns**: |
|
|
**Returns**: |
|
|
|
|
|
|
|
|
*numpy.ndarray* |
|
|
|
|
|
|
|
|
*numpy.ndarray* |
|
|
|
|
|
|
|
|
The text embedding extracted by model. |
|
|
|
|
|
|
|
|
The text embedding extracted by model. |