Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -30,8 +30,8 @@ def reply(input):
|
|
30 |
|
31 |
input = input
|
32 |
input_vector = generate_embeddings(input, model_id,hf_token)
|
33 |
-
df["
|
34 |
-
data = df.sort_values("
|
35 |
data.to_csv("sorted.csv")
|
36 |
context = []
|
37 |
for i, row in data.iterrows():
|
@@ -40,7 +40,7 @@ def reply(input):
|
|
40 |
text = "\n".join(context)
|
41 |
context = text
|
42 |
prompt = f"""
|
43 |
-
Answer the following question If you don't know the answer for certain, say I don't know.
|
44 |
Context: {context}
|
45 |
|
46 |
Q: {input}
|
|
|
30 |
|
31 |
input = input
|
32 |
input_vector = generate_embeddings(input, model_id,hf_token)
|
33 |
+
df["similarities"]=df["embedding"].apply(lambda x: cosine_similarity([x],[input_vector])[0][0])
|
34 |
+
data = df.sort_values("similarities", ascending=False).head(10)
|
35 |
data.to_csv("sorted.csv")
|
36 |
context = []
|
37 |
for i, row in data.iterrows():
|
|
|
40 |
text = "\n".join(context)
|
41 |
context = text
|
42 |
prompt = f"""
|
43 |
+
Answer the following question using the context given below.If you don't know the answer for certain, say I don't know.
|
44 |
Context: {context}
|
45 |
|
46 |
Q: {input}
|