Alvinn-aai commited on
Commit
cdb7426
·
2 Parent(s): 458cf5b e717fbe

Merge commit 'e717fbe44d50f3d613cefd3dd2c1b92cb74e6075' into alvinn/add_terms

Browse files
Files changed (2) hide show
  1. app.py +46 -34
  2. src/display/css_html_js.py +29 -4
app.py CHANGED
@@ -273,21 +273,24 @@ ACCURACY_PCT = {
273
 
274
 
275
  def build_accuracy_figure(tier: str):
276
- """Interactive scatter: x = release date, y = accuracy (%). Hover shows solved/total."""
277
  total = TIER_TOTALS[tier]
278
  fig = go.Figure()
279
 
280
  for model in MODELS_ORDER:
281
- date_str = MODEL_RELEASES[model]
282
- y = ACCURACY_PCT[tier][model]
283
  solved = round(y * total / 100)
 
284
  fig.add_trace(
285
  go.Scatter(
286
  x=[date_str],
287
  y=[y],
288
  mode="markers",
289
- name=model,
290
- marker=dict(size=12, line=dict(width=1)),
 
 
291
  hovertemplate=(
292
  f"<b>{model}</b><br>"
293
  "Release: %{x|%b %d, %Y}<br>"
@@ -298,25 +301,18 @@ def build_accuracy_figure(tier: str):
298
  )
299
  )
300
 
301
- # Comfortable y-range (dynamic ceiling for readability)
302
- max_y = max(ACCURACY_PCT[tier].values()) or 1
303
- upper = max(1, math.ceil(max_y * 1.25))
304
-
305
  fig.update_layout(
306
  template="plotly_white",
307
  height=420,
308
  margin=dict(l=30, r=120, t=10, b=40), # extra right room for legend
309
- xaxis=dict(
310
- title=None,
311
- type="date",
312
- tickformat="%b %Y",
313
- showgrid=True,
314
- ),
315
  yaxis=dict(
316
  title="Accuracy (%)",
317
- range=[0, upper],
318
- dtick=max(1, upper // 5),
 
319
  showgrid=True,
 
320
  ),
321
  legend=dict(title="Models", orientation="v", y=1, x=1.02, yanchor="top"),
322
  hovermode="closest",
@@ -324,28 +320,49 @@ def build_accuracy_figure(tier: str):
324
  return fig
325
 
326
 
327
- _initial_accuracy_fig = build_accuracy_figure("Warmup")
328
 
329
  # Force light theme even if HF user prefers dark
330
  blocks = gr.Blocks(
331
  css=custom_css,
332
  theme=get_theme(),
333
- js="() => { document.body.classList.remove('dark'); document.documentElement.setAttribute('data-theme','light'); document.documentElement.setAttribute('data-color-mode','light'); }",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
334
  )
335
  with blocks:
336
 
337
  with gr.Tabs(elem_classes="tab-buttons") as tabs:
338
  with gr.TabItem("FormulaOne", id=0, elem_id="landing-accuracy-tab"):
339
- gr.Markdown(
340
- "The chart below summarizes static (non-live) results for model performance on FormulaOne.",
341
- elem_classes="markdown-text",
342
  )
343
 
344
  # Pill-style selector aligned to the top-right
345
  with gr.Row(elem_id="f1-tier-select-row"):
346
  tier_selector = gr.Radio(
347
  choices=list(TIER_TOTALS.keys()),
348
- value="Warmup",
349
  label=None,
350
  show_label=False,
351
  elem_id="f1-tier-select",
@@ -363,23 +380,18 @@ with blocks:
363
  gr.Markdown(
364
  """
365
  <div class="f1-container">
366
- <p class="f1-p" style="font-size:0.95rem;color:var(--f1-subtle);">
367
- <em>Footnote.</em> All models were sampled with their highest available reasoning settings and a generous token budget.
368
- We also used a diverse few-shot prompt that is highly supportive for these problems, covering many of the subtle
369
- details inherent in the tasks (state design, invariants, and bag transformations).
370
- </p>
371
  </div>
372
- """,
373
  elem_classes="markdown-text",
374
  )
375
 
376
- # "Learn more" link to the explainer tab
377
- gr.Markdown(
378
- '<div class="f1-container"><p><a class="f1-a" href="#what-is-tab">Learn more about FormulaOne.</a></p></div>'
379
- )
380
  # Existing "What is FormulaOne" tab
381
  with gr.TabItem("What is FormulaOne", id=1, elem_id="what-is-tab"):
382
-
383
  gr.Image(
384
  "assets/banner.png",
385
  show_label=False,
 
273
 
274
 
275
  def build_accuracy_figure(tier: str):
276
+ """Interactive scatter: x = release date (ISO str), y = accuracy (%). Hover shows solved/total."""
277
  total = TIER_TOTALS[tier]
278
  fig = go.Figure()
279
 
280
  for model in MODELS_ORDER:
281
+ date_str = MODEL_RELEASES[model] # e.g., "2025-08-07"
282
+ y = ACCURACY_PCT[tier][model] # percent
283
  solved = round(y * total / 100)
284
+
285
  fig.add_trace(
286
  go.Scatter(
287
  x=[date_str],
288
  y=[y],
289
  mode="markers",
290
+ opacity=0.85,
291
+ name=model, # distinct legend entry & color per model
292
+ marker=dict(size=8, opacity=0.85, line=dict(width=0.5)),
293
+ cliponaxis=False, # let markers render over axes
294
  hovertemplate=(
295
  f"<b>{model}</b><br>"
296
  "Release: %{x|%b %d, %Y}<br>"
 
301
  )
302
  )
303
 
 
 
 
 
304
  fig.update_layout(
305
  template="plotly_white",
306
  height=420,
307
  margin=dict(l=30, r=120, t=10, b=40), # extra right room for legend
308
+ xaxis=dict(title=None, type="date", tickformat="%b %Y", showgrid=True),
 
 
 
 
 
309
  yaxis=dict(
310
  title="Accuracy (%)",
311
+ range=[0, 100], # fixed 0–100
312
+ tick0=0,
313
+ dtick=10,
314
  showgrid=True,
315
+ layer="below traces", # draw axis below points so dots aren't “cut”
316
  ),
317
  legend=dict(title="Models", orientation="v", y=1, x=1.02, yanchor="top"),
318
  hovermode="closest",
 
320
  return fig
321
 
322
 
323
+ _initial_accuracy_fig = build_accuracy_figure("Tier 1")
324
 
325
  # Force light theme even if HF user prefers dark
326
  blocks = gr.Blocks(
327
  css=custom_css,
328
  theme=get_theme(),
329
+ js="""
330
+ () => {
331
+ // Force light theme (your original)
332
+ document.body.classList.remove('dark');
333
+ document.documentElement.setAttribute('data-theme','light');
334
+ document.documentElement.setAttribute('data-color-mode','light');
335
+
336
+ // Handle <a data-tab-target="..."> to switch Gradio tabs by panel id
337
+ document.addEventListener('click', (e) => {
338
+ const a = e.target.closest('a[data-tab-target]');
339
+ if (!a) return;
340
+ e.preventDefault();
341
+ const id = a.getAttribute('data-tab-target'); // e.g., "what-is"
342
+ const panel = document.getElementById(id);
343
+ if (!panel) return;
344
+
345
+ // Find the tab header button that controls this panel and click it
346
+ const btn = document.querySelector(`[role="tab"][aria-controls="${panel.id}"]`);
347
+ if (btn) btn.click();
348
+ }, true);
349
+ }
350
+ """,
351
  )
352
  with blocks:
353
 
354
  with gr.Tabs(elem_classes="tab-buttons") as tabs:
355
  with gr.TabItem("FormulaOne", id=0, elem_id="landing-accuracy-tab"):
356
+
357
+ gr.HTML(
358
+ '<header class="text-center mb-12"><h1 class="text-4xl md:text-5xl font-bold text-gray-900 f1-h1">FormulaOne</h1></header>'
359
  )
360
 
361
  # Pill-style selector aligned to the top-right
362
  with gr.Row(elem_id="f1-tier-select-row"):
363
  tier_selector = gr.Radio(
364
  choices=list(TIER_TOTALS.keys()),
365
+ value="Tier 1",
366
  label=None,
367
  show_label=False,
368
  elem_id="f1-tier-select",
 
380
  gr.Markdown(
381
  """
382
  <div class="f1-container">
383
+ <p class="f1-p" style="font-size:0.95rem;color:var(--f1-subtle);">
384
+ All models were sampled with their highest available reasoning settings and a maximum token budget.
385
+ We also provided the models with a diverse few-shot prompt that is highly supportive for FormulaOne problems,
386
+ covering many of the subtle details of state design and maintenance, from a broad array of categories.
387
+ </p>
388
  </div>
389
+ """,
390
  elem_classes="markdown-text",
391
  )
392
 
 
 
 
 
393
  # Existing "What is FormulaOne" tab
394
  with gr.TabItem("What is FormulaOne", id=1, elem_id="what-is-tab"):
 
395
  gr.Image(
396
  "assets/banner.png",
397
  show_label=False,
src/display/css_html_js.py CHANGED
@@ -19,14 +19,24 @@ custom_css = """
19
  #f1-examples { max-width: 710px; margin: 0 auto; }
20
 
21
  /* NEW: landing tab width + tier selector alignment */
 
22
  #landing-accuracy-tab { max-width: 800px; margin-left: auto; margin-right: auto; }
23
- #f1-tier-select-row { justify-content: flex-end; margin-bottom: 6px; }
24
- #f1-tier-select-row { justify-content: flex-end; margin-bottom: 6px; }
 
 
 
 
 
 
 
 
 
25
  #f1-tier-select .wrap {
26
  display: inline-flex;
27
  gap: 6px;
28
  padding: 4px;
29
- background: #ffffff;
30
  border: 1px solid var(--f1-border);
31
  border-radius: 999px;
32
  }
@@ -39,12 +49,27 @@ custom_css = """
39
  cursor: pointer;
40
  }
41
  #f1-tier-select input[type="radio"]:checked + span {
42
- background: #eef2ff; /* subtle non-white for selected pill */
43
  border-radius: 999px;
44
  padding: 6px 12px;
45
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
46
  }
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  /* Text */
49
  .f1-p, .f1-li { line-height: 1.75; color: #374151; text-wrap: pretty; overflow-wrap: break-word; hyphens: auto; }
50
 
 
19
  #f1-examples { max-width: 710px; margin: 0 auto; }
20
 
21
  /* NEW: landing tab width + tier selector alignment */
22
+ /* Landing tab width + tier selector alignment */
23
  #landing-accuracy-tab { max-width: 800px; margin-left: auto; margin-right: auto; }
24
+
25
+ /* Right-align the switcher row; transparent background & border */
26
+ #f1-tier-select-row {
27
+ justify-content: flex-end;
28
+ margin-bottom: 6px;
29
+ background: white !important;
30
+ border: none !important;
31
+ }
32
+
33
+ /* Make the control look like "pills" and force RTL layout */
34
+ #f1-tier-select { direction: rtl; } /* RTL direction (equivalent effect to dir="rtl") */
35
  #f1-tier-select .wrap {
36
  display: inline-flex;
37
  gap: 6px;
38
  padding: 4px;
39
+ background: #ffffff; /* white background for the switcher itself */
40
  border: 1px solid var(--f1-border);
41
  border-radius: 999px;
42
  }
 
49
  cursor: pointer;
50
  }
51
  #f1-tier-select input[type="radio"]:checked + span {
52
+ background: #eef2ff; /* only selected pill is tinted */
53
  border-radius: 999px;
54
  padding: 6px 12px;
55
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
56
  }
57
 
58
+ #f1-tier-select-row div { border: none; }
59
+
60
+ #f1-tier-select { background: white; }
61
+
62
+ #learn-more-btn, #learn-more-btn button {
63
+ background: transparent !important;
64
+ border: none !important;
65
+ color: #2563eb !important;
66
+ font-weight: 700 !important;
67
+ font-size: 1.05rem !important;
68
+ padding: 0 !important;
69
+ box-shadow: none !important;
70
+ }
71
+ #learn-more-btn button:hover { text-decoration: underline !important; background: transparent !important; }
72
+
73
  /* Text */
74
  .f1-p, .f1-li { line-height: 1.75; color: #374151; text-wrap: pretty; overflow-wrap: break-word; hyphens: auto; }
75