Tom Aarsen commited on
Commit
d86454c
·
1 Parent(s): 09c7453

Update styles, padding, borders, etc.

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -114,7 +114,7 @@ def search(
114
  rank_str = str(i + 1)
115
  binary_rank_str = str(indices[i] + 1)
116
  card_html = f"""
117
- <div style=\"border: 1px solid var(--border-color-primary, #e0e0e0); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background-color: var(--block-background-fill, transparent); color: inherit;\">
118
  <div style=\"display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 4px;\">
119
  <div style=\"font-size: 16px; font-weight: 600; min-width: 0;\">
120
  <a href=\"{url}\" target=\"_blank\" style=\"text-decoration: none; color: var(--link-text-color, #1f6feb); padding-left: 0;\">{title}</a>
@@ -145,7 +145,7 @@ def search(
145
  search_mode = "Approximate (IVF)" if use_approx else "Exact"
146
 
147
  summary_md = f"""
148
- <div style=\"border: 1px solid var(--border-color-primary, #e0e0e0); border-radius: 10px; padding: 10px 12px; background-color: var(--block-background-fill, transparent);\">
149
  <h3 style=\"margin-top: 0;\">Search Summary</h3>
150
  <ul style=\"margin-top: 0; margin-bottom: 8px; padding-left: 18px;\">
151
  <li>Total docs in corpus: {TOTAL_NUM_DOCS:,}</li>
@@ -163,18 +163,24 @@ def search(
163
  <li>Sort: {sort_time:.4f}</li>
164
  <li>Load text: {load_text_time:.4f}</li>
165
  </ul>
166
- <strong>Total retrieval time: {total_retrieval_time:.4f} seconds</strong>
167
  </div>"""
168
 
169
  return cards_html, summary_md
170
 
171
 
 
 
 
 
 
 
172
  with gr.Blocks(title="Quantized Retrieval") as demo:
173
  with gr.Row():
174
  with gr.Column(scale=3):
175
  gr.Markdown(
176
  """
177
- <div style='border: 1px solid var(--border-color-primary, #e0e0e0); border-radius: 10px; padding: 12px 14px; background-color: var(--block-background-fill, transparent);'>
178
 
179
  <h1 style='margin-top: 0;'>Quantized Retrieval - Binary Search with Scalar (int8) Rescoring</h1>
180
 
@@ -212,7 +218,7 @@ Notes:
212
  placeholder="Enter a query to search for relevant texts from Wikipedia.",
213
  )
214
  search_button = gr.Button(value="Search", variant="secondary")
215
- with gr.Column(scale=1, min_width=0):
216
  top_k = gr.Slider(
217
  minimum=10,
218
  maximum=1000,
@@ -237,7 +243,7 @@ Notes:
237
 
238
  with gr.Row():
239
  with gr.Column(scale=3):
240
- cards = gr.HTML(label="Results")
241
  with gr.Column(scale=1):
242
  summary = gr.Markdown(label="Search Summary")
243
 
@@ -267,4 +273,4 @@ Notes:
267
  )
268
 
269
  demo.queue()
270
- demo.launch()
 
114
  rank_str = str(i + 1)
115
  binary_rank_str = str(indices[i] + 1)
116
  card_html = f"""
117
+ <div style=\"border: 1px solid var(--border-color-primary, #e0e0e0); border-radius: var(--block-radius); padding: 10px 12px; margin-bottom: 10px; background-color: var(--block-background-fill, transparent); color: inherit;\">
118
  <div style=\"display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 4px;\">
119
  <div style=\"font-size: 16px; font-weight: 600; min-width: 0;\">
120
  <a href=\"{url}\" target=\"_blank\" style=\"text-decoration: none; color: var(--link-text-color, #1f6feb); padding-left: 0;\">{title}</a>
 
145
  search_mode = "Approximate (IVF)" if use_approx else "Exact"
146
 
147
  summary_md = f"""
148
+ <div style=\"border: 1px solid var(--border-color-primary, #e0e0e0); border-radius: var(--block-radius); padding: 10px 12px; background-color: var(--block-background-fill, transparent);\">
149
  <h3 style=\"margin-top: 0;\">Search Summary</h3>
150
  <ul style=\"margin-top: 0; margin-bottom: 8px; padding-left: 18px;\">
151
  <li>Total docs in corpus: {TOTAL_NUM_DOCS:,}</li>
 
163
  <li>Sort: {sort_time:.4f}</li>
164
  <li>Load text: {load_text_time:.4f}</li>
165
  </ul>
166
+ <h5>Total retrieval time: {total_retrieval_time:.4f} seconds</h5>
167
  </div>"""
168
 
169
  return cards_html, summary_md
170
 
171
 
172
+ css = """
173
+ #cards-container {
174
+ --block-padding: 0px;
175
+ }
176
+ """
177
+
178
  with gr.Blocks(title="Quantized Retrieval") as demo:
179
  with gr.Row():
180
  with gr.Column(scale=3):
181
  gr.Markdown(
182
  """
183
+ <div style='border: 1px solid var(--border-color-primary, #e0e0e0); border-radius: var(--block-radius); padding: 12px 14px; background-color: var(--block-background-fill, transparent);'>
184
 
185
  <h1 style='margin-top: 0;'>Quantized Retrieval - Binary Search with Scalar (int8) Rescoring</h1>
186
 
 
218
  placeholder="Enter a query to search for relevant texts from Wikipedia.",
219
  )
220
  search_button = gr.Button(value="Search", variant="secondary")
221
+ with gr.Column(scale=1):
222
  top_k = gr.Slider(
223
  minimum=10,
224
  maximum=1000,
 
243
 
244
  with gr.Row():
245
  with gr.Column(scale=3):
246
+ cards = gr.HTML(label="Results", elem_id="cards-container")
247
  with gr.Column(scale=1):
248
  summary = gr.Markdown(label="Search Summary")
249
 
 
273
  )
274
 
275
  demo.queue()
276
+ demo.launch(theme=gr.themes.Base(), css=css)