From a498f87bbbd16a6b14405bbf06131c7299763e39 Mon Sep 17 00:00:00 2001 From: chenketing Date: Sun, 14 May 2023 23:28:35 +0800 Subject: [PATCH] feature:add markdown embedding --- pilot/source_embedding/search_milvus.py | 112 ++++++++++++------------ 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/pilot/source_embedding/search_milvus.py b/pilot/source_embedding/search_milvus.py index 09d4a4cb0..18f93d1d3 100644 --- a/pilot/source_embedding/search_milvus.py +++ b/pilot/source_embedding/search_milvus.py @@ -1,61 +1,61 @@ -from langchain.embeddings import HuggingFaceEmbeddings -from langchain.vectorstores import Milvus -from pymilvus import Collection,utility -from pymilvus import connections, DataType, FieldSchema, CollectionSchema - -# milvus = connections.connect( -# alias="default", -# host='localhost', -# port="19530" -# ) -# collection = Collection("book") - - -# Get an existing collection. -# collection.load() +# from langchain.embeddings import HuggingFaceEmbeddings +# from langchain.vectorstores import Milvus +# from pymilvus import Collection,utility +# from pymilvus import connections, DataType, FieldSchema, CollectionSchema # -# search_params = {"metric_type": "L2", "params": {}, "offset": 5} +# # milvus = connections.connect( +# # alias="default", +# # host='localhost', +# # port="19530" +# # ) +# # collection = Collection("book") # -# results = collection.search( -# data=[[0.1, 0.2]], -# anns_field="book_intro", -# param=search_params, -# limit=10, -# expr=None, -# output_fields=['book_id'], -# consistency_level="Strong" -# ) # -# # get the IDs of all returned hits -# results[0].ids +# # Get an existing collection. +# # collection.load() +# # +# # search_params = {"metric_type": "L2", "params": {}, "offset": 5} +# # +# # results = collection.search( +# # data=[[0.1, 0.2]], +# # anns_field="book_intro", +# # param=search_params, +# # limit=10, +# # expr=None, +# # output_fields=['book_id'], +# # consistency_level="Strong" +# # ) +# # +# # # get the IDs of all returned hits +# # results[0].ids +# # +# # # get the distances to the query vector from all returned hits +# # results[0].distances +# # +# # # get the value of an output field specified in the search request. +# # # vector fields are not supported yet. +# # hit = results[0][0] +# # hit.entity.get('title') # -# # get the distances to the query vector from all returned hits -# results[0].distances +# # milvus = connections.connect( +# # alias="default", +# # host='localhost', +# # port="19530" +# # ) +# from pilot.vector_store.milvus_store import MilvusStore # -# # get the value of an output field specified in the search request. -# # vector fields are not supported yet. -# hit = results[0][0] -# hit.entity.get('title') - -# milvus = connections.connect( -# alias="default", -# host='localhost', -# port="19530" -# ) -from pilot.vector_store.milvus_store import MilvusStore - -data = ["aaa", "bbb"] -model_name = "/Users/chenketing/Desktop/project/all-MiniLM-L6-v2" -embeddings = HuggingFaceEmbeddings(model_name=model_name) - -# text_embeddings = Text2Vectors() -mivuls = MilvusStore(cfg={"url": "127.0.0.1", "port": "19530", "alias": "default", "table_name": "test_k"}) - -mivuls.insert(["textc","tezt2"]) -print("success") - -# mivuls.from_texts(texts=data, embedding=embeddings) -# docs, -# embedding=embeddings, -# connection_args={"host": "127.0.0.1", "port": "19530", "alias": "default"} -# ) \ No newline at end of file +# data = ["aaa", "bbb"] +# model_name = "xx/all-MiniLM-L6-v2" +# embeddings = HuggingFaceEmbeddings(model_name=model_name) +# +# # text_embeddings = Text2Vectors() +# mivuls = MilvusStore(cfg={"url": "127.0.0.1", "port": "19530", "alias": "default", "table_name": "test_k"}) +# +# mivuls.insert(["textc","tezt2"]) +# print("success") +# ct +# # mivuls.from_texts(texts=data, embedding=embeddings) +# # docs, +# # embedding=embeddings, +# # connection_args={"host": "127.0.0.1", "port": "19530", "alias": "default"} +# # ) \ No newline at end of file