From 5b2d8831696272322a54a2a4a8e184eba1278e01 Mon Sep 17 00:00:00 2001 From: "junjie.jiang" Date: Tue, 17 Jan 2023 19:54:22 +0800 Subject: [PATCH] update readme --- README.md | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0cb13c8..69b4989 100644 --- a/README.md +++ b/README.md @@ -17,24 +17,32 @@ Search embedding in [Milvus](https://milvus.io/), **please make sure you have in ```python -from towhee.dc2 import pipe, ops +from towhee.dc2 import pipe, ops, DataCollection + +p = pipe.input('text') \ + .map('text', 'vec', ops.sentence_embedding.transformers(model_name='all-MiniLM-L12-v2')) \ + .flat_map('vec', 'rows', ops.ann_search.milvus_client(host='127.0.0.1', port='19530', collection_name='text_db2', **{'output_fields': ['text']})) \ + .map('rows', ('id', 'score', 'text'), lambda x: (x[0], x[1], x[2])) \ + .output('id', 'score', 'text') -p = pipe.input('vec') \ - .map('vec', ('id', 'score'), ops.ann_search.milvus_client(host='127.0.0.1', port='19530', collection_name='textdb')) \ - .output('id', 'score') +DataCollection(p('cat')).show() + +# result: -# call pipeline -p(vec_data) ``` ```python from towhee.dc2 import pipe, ops # search additional info url: +from towhee.dc2 import pipe, ops, DataCollection + +p = pipe.input('text') \ + .map('text', 'vec', ops.sentence_embedding.transformers(model_name='all-MiniLM-L12-v2')) \ + .map('vec', 'rows', ops.ann_search.milvus_client(host='127.0.0.1', port='19530', collection_name='text_db2', **{'output_fields': ['text']})) \ + .output('rows') -p = pipe.input('vec') \ - .map('vec', ('id', 'score', 'url'), ops.ann_search.milvus_client(host='127.0.0.1', port='19530', collection_name='textdb', output_fields=['url'])) \ - .output('id', 'score', 'url') +DataCollection(p('cat')).show() ```