-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
43 lines (32 loc) · 1022 Bytes
/
app.py
File metadata and controls
43 lines (32 loc) · 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from langchain_community.vectorstores import Qdrant
from langchain_community.embeddings import HuggingFaceBgeEmbeddings
from qdrant_client import QdrantClient
#load the embeddings model
model_name = "BAAI/bge-large-en"
model_kwargs = {"device": 'cpu'}
encode_kwargs = {"normalize_embeddings": False}
embeddings = HuggingFaceBgeEmbeddings(
model_name=model_name,
model_kwargs=model_kwargs,
encode_kwargs=encode_kwargs
)
url = "http://127.0.0.1:6333"
collection_name = "gpt_db"
client = QdrantClient(
url=url,
prefer_grpc=False
)
print(client)
print('####################################')
db = Qdrant(
client=client,
collection_name=collection_name,
embeddings=embeddings
)
print(db)
print('###############################')
query = "What is saliency maps?"
docs = db.similarity_search_with_score(query=query, k=5)
for i in docs:
doc, score = i
print({"score": score, "content": doc.page_content, "metadata": doc.metadata})