-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_embbeding.py
50 lines (39 loc) · 1.15 KB
/
test_embbeding.py
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
44
45
46
47
48
49
50
from langchain_community.embeddings import LocalAIEmbeddings
def embbeding_model(embeddings,text):
if embeddings == "multiqa":
emb = LocalAIEmbeddings(openai_api_base="http://IP_ADDRESS:8001/v1",
model="multi-qa-mpnet-base-dot-v",
openai_api_key="custom"
)
elif embeddings == "allmini_l12":
emb = LocalAIEmbeddings(
openai_api_base="http://IP_ADDRESS:8001/v1",
model="all-MiniLM-L12-v2",
openai_api_key="custom"
)
elif embeddings == "gtr":
emb = LocalAIEmbeddings(
openai_api_base="http://IP_ADDRESS:8001/v1",
model="gtr-t5-large",
openai_api_key="custom"
)
else:
print("Embbeding model eror")
text = text
query_result = emb.embed_query(text)
print(query_result)
# Example model 1
embbeding_model(
embeddings="multiqa",
text="Hallo testing model 1"
)
# Example model 2
embbeding_model(
embeddings="allmini_l12",
text="Hallo testing model 2"
)
# Example model 3
embbeding_model(
embeddings="gtr",
text="Hallo testing model 3"
)