Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -120,10 +120,10 @@ def answer_question(question):
|
|
| 120 |
|
| 121 |
# Compute cosine similarity with stored embeddings
|
| 122 |
cos_scores = util.cos_sim(question_embedding, embeddings)[0]
|
| 123 |
-
top_k = min(1, len(corpus)) # Get top
|
| 124 |
top_indices = np.argsort(-cos_scores)[:top_k]
|
| 125 |
|
| 126 |
-
# Retrieve context (top
|
| 127 |
contexts = [corpus[i] for i in top_indices]
|
| 128 |
context = " ".join(contexts) # Concatenate with space
|
| 129 |
sources = [sources_list[i] for i in top_indices]
|
|
|
|
| 120 |
|
| 121 |
# Compute cosine similarity with stored embeddings
|
| 122 |
cos_scores = util.cos_sim(question_embedding, embeddings)[0]
|
| 123 |
+
top_k = min(1, len(corpus)) # Get top paragraph to improve accuracy
|
| 124 |
top_indices = np.argsort(-cos_scores)[:top_k]
|
| 125 |
|
| 126 |
+
# Retrieve context (top paragraph)
|
| 127 |
contexts = [corpus[i] for i in top_indices]
|
| 128 |
context = " ".join(contexts) # Concatenate with space
|
| 129 |
sources = [sources_list[i] for i in top_indices]
|