logo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readme
Files and versions

1.5 KiB

ANN Search Operator: MilvusClient

author: junjie.jiangjjj


Desription

Search embedding in Milvus, please make sure you have inserted data to Milvus Collection.


Code Example

Please make sure you have inserted data into Milvus, refer to ann_insert.milvus_client and load the collection to memory.

from towhee 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')

DataCollection(p('cat')).show()

# result:

from towhee import pipe, ops

# search additional info url:
from towhee 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')

DataCollection(p('cat')).show()


Factory Constructor

Create the operator via the following factory method:

ann_search.milvus_client(host='127.0.0.1', port='19530', collection_name='textdb')


1.5 KiB

ANN Search Operator: MilvusClient

author: junjie.jiangjjj


Desription

Search embedding in Milvus, please make sure you have inserted data to Milvus Collection.


Code Example

Please make sure you have inserted data into Milvus, refer to ann_insert.milvus_client and load the collection to memory.

from towhee 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')

DataCollection(p('cat')).show()

# result:

from towhee import pipe, ops

# search additional info url:
from towhee 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')

DataCollection(p('cat')).show()


Factory Constructor

Create the operator via the following factory method:

ann_search.milvus_client(host='127.0.0.1', port='19530', collection_name='textdb')