feature:add markdown embedding

This commit is contained in:
chenketing 2023-05-14 23:28:35 +08:00
parent 645530a31d
commit a498f87bbb

View File

@ -1,61 +1,61 @@
from langchain.embeddings import HuggingFaceEmbeddings # from langchain.embeddings import HuggingFaceEmbeddings
from langchain.vectorstores import Milvus # from langchain.vectorstores import Milvus
from pymilvus import Collection,utility # from pymilvus import Collection,utility
from pymilvus import connections, DataType, FieldSchema, CollectionSchema # 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()
# #
# 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 # # Get an existing collection.
# results[0].ids # # 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 # # milvus = connections.connect(
# results[0].distances # # 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. # data = ["aaa", "bbb"]
# # vector fields are not supported yet. # model_name = "xx/all-MiniLM-L6-v2"
# hit = results[0][0] # embeddings = HuggingFaceEmbeddings(model_name=model_name)
# hit.entity.get('title') #
# # text_embeddings = Text2Vectors()
# milvus = connections.connect( # mivuls = MilvusStore(cfg={"url": "127.0.0.1", "port": "19530", "alias": "default", "table_name": "test_k"})
# alias="default", #
# host='localhost', # mivuls.insert(["textc","tezt2"])
# port="19530" # print("success")
# ) # ct
from pilot.vector_store.milvus_store import MilvusStore # # mivuls.from_texts(texts=data, embedding=embeddings)
# # docs,
data = ["aaa", "bbb"] # # embedding=embeddings,
model_name = "/Users/chenketing/Desktop/project/all-MiniLM-L6-v2" # # connection_args={"host": "127.0.0.1", "port": "19530", "alias": "default"}
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"}
# )