Spaces:
Build error
Build error
Tom Aarsen
commited on
Commit
·
6902d0c
1
Parent(s):
54a336d
Allow enter to work on the Textbox
Browse files
app.py
CHANGED
|
@@ -28,7 +28,7 @@ model = SentenceTransformer(
|
|
| 28 |
def search(query, top_k: int = 10, rerank_multiplier: int = 4):
|
| 29 |
# 1. Embed the query as float32
|
| 30 |
start_time = time.time()
|
| 31 |
-
query_embedding = model.encode(query)
|
| 32 |
embed_time = time.time() - start_time
|
| 33 |
|
| 34 |
# 2. Quantize the query to ubinary
|
|
@@ -76,10 +76,11 @@ with gr.Blocks(title="Quantized Retrieval") as demo:
|
|
| 76 |
|
| 77 |
with gr.Row():
|
| 78 |
with gr.Column(scale=4):
|
| 79 |
-
output = gr.Dataframe(
|
| 80 |
with gr.Column(scale=1):
|
| 81 |
json = gr.JSON()
|
| 82 |
|
|
|
|
| 83 |
search_button.click(search, inputs=[query], outputs=[output, json])
|
| 84 |
|
| 85 |
demo.queue()
|
|
|
|
| 28 |
def search(query, top_k: int = 10, rerank_multiplier: int = 4):
|
| 29 |
# 1. Embed the query as float32
|
| 30 |
start_time = time.time()
|
| 31 |
+
query_embedding = model.encode([query])
|
| 32 |
embed_time = time.time() - start_time
|
| 33 |
|
| 34 |
# 2. Quantize the query to ubinary
|
|
|
|
| 76 |
|
| 77 |
with gr.Row():
|
| 78 |
with gr.Column(scale=4):
|
| 79 |
+
output = gr.Dataframe(headers=["Score", "Title", "Text"])
|
| 80 |
with gr.Column(scale=1):
|
| 81 |
json = gr.JSON()
|
| 82 |
|
| 83 |
+
query.submit(search, inputs=[query], outputs=[output, json])
|
| 84 |
search_button.click(search, inputs=[query], outputs=[output, json])
|
| 85 |
|
| 86 |
demo.queue()
|