Browse Source
Remove dc2 for towhee1.0
Signed-off-by: Jael Gu <mengjia.gu@zilliz.com>
main
2 changed files with
5 additions and
3 deletions
-
README.md
-
s_bert.py
|
|
@ -20,7 +20,7 @@ to generate a text embedding for the sentence "This is a sentence.". |
|
|
|
*Write a pipeline with explicit inputs/outputs name specifications:* |
|
|
|
|
|
|
|
```python |
|
|
|
from towhee.dc2 import pipe, ops, DataCollection |
|
|
|
from towhee import pipe, ops, DataCollection |
|
|
|
|
|
|
|
p = ( |
|
|
|
pipe.input('sentence') |
|
|
|
|
|
@ -85,6 +85,8 @@ class STransformers(NNOperator): |
|
|
|
else: |
|
|
|
sentences = txt |
|
|
|
inputs = self.tokenize(sentences) |
|
|
|
for k, v in inputs.items(): |
|
|
|
inputs[k] = v.to(self.device) |
|
|
|
embs = self.model(**inputs).cpu().detach().numpy() |
|
|
|
if isinstance(txt, str): |
|
|
|
embs = embs.squeeze(0) |
|
|
|