Spaces:
Runtime error
Runtime error
fix
Browse files- app.py +1 -1
- backend/semantic_search.py +2 -1
app.py
CHANGED
@@ -34,7 +34,7 @@ def add_text(history, text):
|
|
34 |
return history, gr.Textbox(value="", interactive=False)
|
35 |
|
36 |
|
37 |
-
def bot(history, api_kind, with_cross_encoder):
|
38 |
query = history[-1][0]
|
39 |
|
40 |
if not query:
|
|
|
34 |
return history, gr.Textbox(value="", interactive=False)
|
35 |
|
36 |
|
37 |
+
def bot(history, api_kind, with_cross_encoder=False):
|
38 |
query = history[-1][0]
|
39 |
|
40 |
if not query:
|
backend/semantic_search.py
CHANGED
@@ -24,7 +24,8 @@ def retrieve(query, k, with_cross_encoder=False):
|
|
24 |
documents = [doc[TEXT_COLUMN] for doc in documents]
|
25 |
else:
|
26 |
documents = TABLE.search(query_vec, vector_column_name=VECTOR_COLUMN).limit(k * 2).to_list()
|
27 |
-
|
|
|
28 |
indexed_arr = [(elem, index) for index, elem in enumerate(scores)]
|
29 |
sorted_arr = sorted(indexed_arr, key=lambda x: x[0], reverse=True)
|
30 |
documents = [documents[index] for _, index in sorted_arr[:k]]
|
|
|
24 |
documents = [doc[TEXT_COLUMN] for doc in documents]
|
25 |
else:
|
26 |
documents = TABLE.search(query_vec, vector_column_name=VECTOR_COLUMN).limit(k * 2).to_list()
|
27 |
+
documents = [doc[TEXT_COLUMN] for doc in documents]
|
28 |
+
scores = cross_encoder.predict([(query, doc) for doc in documents])
|
29 |
indexed_arr = [(elem, index) for index, elem in enumerate(scores)]
|
30 |
sorted_arr = sorted(indexed_arr, key=lambda x: x[0], reverse=True)
|
31 |
documents = [documents[index] for _, index in sorted_arr[:k]]
|