logo
Browse Source

Update

Signed-off-by: Jael Gu <mengjia.gu@zilliz.com>
main
Jael Gu 2 years ago
parent
commit
12dc3791f1
  1. 13
      README.md
  2. 2
      dpr.py
  3. BIN
      result.png

13
README.md

@ -33,12 +33,19 @@ to generate a text embedding for the sentence "Hello, world.".
*Write the pipeline*:
```python
import towhee
from towhee.dc2 import pipe, ops, DataCollection
towhee.dc(["Hello, world."]) \
.text_embedding.dpr(model_name="facebook/dpr-ctx_encoder-single-nq-base")
p = (
pipe.input('text')
.map('text', 'vec', ops.text_embedding.dpr(model_name='facebook/dpr-ctx_encoder-single-nq-base'))
.output('text', 'vec')
)
DataCollection(p('Hello, world.')).show()
```
<img src="./result.png" width="800px"/>
<br />
## Factory Constructor

2
dpr.py

@ -50,7 +50,7 @@ class Dpr(NNOperator):
except Exception as e:
log.error(f'Invalid input for the model: {self.model_name}')
raise e
vec = embeddings.detach().numpy()
vec = embeddings.squeeze(0).detach().numpy()
return vec

BIN
result.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Loading…
Cancel
Save