Spaces:
Running
on
Zero
Running
on
Zero
Update main.py
Browse files
main.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import json # For stringifying a dict
|
|
|
2 |
|
3 |
import gradio # GUI framework
|
4 |
import datasets # Used to load publication dataset
|
@@ -33,6 +34,13 @@ index.add(vectors)
|
|
33 |
# Load the model for later use in embeddings
|
34 |
model = sentence_transformers.SentenceTransformer("allenai-specter")
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
# Define the search function
|
38 |
def search(query: str, k: int):
|
@@ -72,7 +80,7 @@ def search(query: str, k: int):
|
|
72 |
with gradio.Blocks() as demo:
|
73 |
with gradio.Group():
|
74 |
query = gradio.Textbox(
|
75 |
-
placeholder=
|
76 |
)
|
77 |
with gradio.Accordion("Settings", open=False):
|
78 |
k = gradio.Number(10.0, label="Number of results", precision=0)
|
|
|
1 |
import json # For stringifying a dict
|
2 |
+
impory random # For selecting a search hint
|
3 |
|
4 |
import gradio # GUI framework
|
5 |
import datasets # Used to load publication dataset
|
|
|
34 |
# Load the model for later use in embeddings
|
35 |
model = sentence_transformers.SentenceTransformer("allenai-specter")
|
36 |
|
37 |
+
# Choose random search placeholder
|
38 |
+
placeholder = random.choice([
|
39 |
+
"design for additive manufacturing",
|
40 |
+
"best practices for agent based modeling"
|
41 |
+
"arctic environmental science",
|
42 |
+
"analysis of student teamwork"
|
43 |
+
])
|
44 |
|
45 |
# Define the search function
|
46 |
def search(query: str, k: int):
|
|
|
80 |
with gradio.Blocks() as demo:
|
81 |
with gradio.Group():
|
82 |
query = gradio.Textbox(
|
83 |
+
placeholder=placeholder, show_label=False, lines=1, max_lines=1
|
84 |
)
|
85 |
with gradio.Accordion("Settings", open=False):
|
86 |
k = gradio.Number(10.0, label="Number of results", precision=0)
|