LalitMahale
commited on
Commit
·
7fa286a
1
Parent(s):
d7b8d59
changed embeddings
Browse files- all_answers.pkl +0 -0
- all_mix_embedding.pkl +0 -0
- answer.pkl +0 -0
- main.py +9 -3
- question_embedding_latest.pkl +0 -0
all_answers.pkl
ADDED
|
Binary file (53.3 kB). View file
|
|
|
all_mix_embedding.pkl
ADDED
|
Binary file (2 kB). View file
|
|
|
answer.pkl
DELETED
|
Binary file (47.1 kB)
|
|
|
main.py
CHANGED
|
@@ -24,16 +24,22 @@ import os
|
|
| 24 |
def process(user_query:str):
|
| 25 |
# dump_user_question(user_query)
|
| 26 |
user_embedding = GetEmbedding([user_query]).user_query_emb()
|
| 27 |
-
with open(r"
|
| 28 |
load_embedding = pickle.load(f)
|
| 29 |
|
| 30 |
-
with open(r"
|
| 31 |
ans = pickle.load(f)
|
| 32 |
similarity_scores = cosine_similarity(user_embedding, load_embedding)
|
| 33 |
index = np.argmax(similarity_scores)
|
| 34 |
answer = ans[index]
|
| 35 |
print(f"{index}:\t {user_query}")
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
|
| 39 |
|
|
|
|
| 24 |
def process(user_query:str):
|
| 25 |
# dump_user_question(user_query)
|
| 26 |
user_embedding = GetEmbedding([user_query]).user_query_emb()
|
| 27 |
+
with open(r"all_mix_embedding.pkl","rb") as f:
|
| 28 |
load_embedding = pickle.load(f)
|
| 29 |
|
| 30 |
+
with open(r"all_answers.pkl","rb") as f:
|
| 31 |
ans = pickle.load(f)
|
| 32 |
similarity_scores = cosine_similarity(user_embedding, load_embedding)
|
| 33 |
index = np.argmax(similarity_scores)
|
| 34 |
answer = ans[index]
|
| 35 |
print(f"{index}:\t {user_query}")
|
| 36 |
+
score = similarity_scores[0,index]
|
| 37 |
+
if score > 50 :
|
| 38 |
+
final_output = random.choice(answer)
|
| 39 |
+
else:
|
| 40 |
+
final_output = "Sorry, I didn't understand."
|
| 41 |
+
|
| 42 |
+
return final_output
|
| 43 |
|
| 44 |
|
| 45 |
|
question_embedding_latest.pkl
DELETED
|
Binary file (627 kB)
|
|
|