Browse Source
Update
Signed-off-by: Jael Gu <mengjia.gu@zilliz.com>
main
2 changed files with
8 additions and
16 deletions
-
README.md
-
BIN
result.png
|
|
@ -19,27 +19,19 @@ Use the pre-trained model "huggingface/CodeBERTa-small-v1" |
|
|
|
to generate text embeddings for given |
|
|
|
text description "return max value" and code "def max(a,b): if a>b: return a else return b". |
|
|
|
|
|
|
|
*Write the pipeline*: |
|
|
|
*Write a pipeline with explicit inputs/outputs name specifications:* |
|
|
|
|
|
|
|
```python |
|
|
|
import towhee |
|
|
|
from towhee.dc2 import pipe, ops, DataCollection |
|
|
|
|
|
|
|
( |
|
|
|
towhee.dc(['find max value', 'def max(a,b): if a>b: return a else return b']) |
|
|
|
.code_search.codebert(model_name='huggingface/CodeBERTa-small-v1') |
|
|
|
p = ( |
|
|
|
pipe.input('text') |
|
|
|
.map('text', 'embedding', ops.code_search.codebert(model_name='huggingface/CodeBERTa-small-v1')) |
|
|
|
.output('text', 'embedding') |
|
|
|
) |
|
|
|
``` |
|
|
|
|
|
|
|
*Write a same pipeline with explicit inputs/outputs name specifications:* |
|
|
|
|
|
|
|
```python |
|
|
|
import towhee |
|
|
|
|
|
|
|
( |
|
|
|
towhee.dc['text'](['return max value', 'def max(a,b): if a>b: return a else return b']) |
|
|
|
.code_search.codebert['text', 'embedding']() |
|
|
|
.show() |
|
|
|
) |
|
|
|
DataCollection(p('find max value')).show() |
|
|
|
DataCollection(p('def max(a,b): if a>b: return a else return b')).show() |
|
|
|
``` |
|
|
|
|
|
|
|
<img src="./result.png" width="800px"/> |
|
|
|
Width:
|
Height:
|
Size: 13 KiB
Width:
|
Height:
|
Size: 14 KiB
|