Spaces:
Sleeping
Sleeping
it works \(^-^)/
Browse files
app.py
CHANGED
@@ -85,8 +85,7 @@ def search(query, ds, k=3):
|
|
85 |
tokens = q_tokenizer(query, return_tensors="pt")
|
86 |
query_embed = q_encoder(**tokens)[0][0].detach().numpy()
|
87 |
scores, retrieved_examples = ds.get_nearest_examples("embeddings", query_embed, k=k)
|
88 |
-
out = f"""title : {retrieved_examples["title"][0]},\ncontent: {retrieved_examples["text"][0]}
|
89 |
-
similar resources: {retrieved_examples["title"]}
|
90 |
"""
|
91 |
except Exception as e:
|
92 |
out = f"error in search: {e}"
|
@@ -112,7 +111,7 @@ with gr.Blocks() as demo :
|
|
112 |
k = gr.Number(value=3,show_label=False,precision=0,minimum=1,container=False)
|
113 |
button = gr.Button("search")
|
114 |
with gr.Column():
|
115 |
-
output = gr.
|
116 |
button.click(predict, [query,files,k],outputs=output)
|
117 |
|
118 |
demo.launch()
|
|
|
85 |
tokens = q_tokenizer(query, return_tensors="pt")
|
86 |
query_embed = q_encoder(**tokens)[0][0].detach().numpy()
|
87 |
scores, retrieved_examples = ds.get_nearest_examples("embeddings", query_embed, k=k)
|
88 |
+
out = f"""**title** : {retrieved_examples["title"][0]},\ncontent: {retrieved_examples["text"][0]}\n\n\n**similar resources:** {retrieved_examples["title"]}
|
|
|
89 |
"""
|
90 |
except Exception as e:
|
91 |
out = f"error in search: {e}"
|
|
|
111 |
k = gr.Number(value=3,show_label=False,precision=0,minimum=1,container=False)
|
112 |
button = gr.Button("search")
|
113 |
with gr.Column():
|
114 |
+
output = gr.Markdown(label="output")
|
115 |
button.click(predict, [query,files,k],outputs=output)
|
116 |
|
117 |
demo.launch()
|