rzanoli commited on
Commit
a0702aa
·
1 Parent(s): ad05cd8

Refactor: Move inline styles from Python/HTML to CSS file

Browse files
Files changed (2) hide show
  1. app.py +12 -62
  2. src/display/css_html_js.py +63 -0
app.py CHANGED
@@ -415,23 +415,12 @@ def restart_space():
415
  def create_title_html():
416
  """Function for title HTML."""
417
  return """
418
- <div style="display: flex; align-items: center; position: relative; width: 100%; height: 60px; padding: 10px 0;">
419
- <h1 style="
420
- margin: 0 auto;
421
- font-weight: 900;
422
- font-size: 2.5em;
423
- letter-spacing: 2px;
424
- text-transform: uppercase;
425
- background: linear-gradient(90deg, #1f77b4, #00c6ff);
426
- -webkit-background-clip: text;
427
- -webkit-text-fill-color: transparent;
428
- text-shadow: 2px 2px 8px rgba(0,0,0,0.2);
429
- ">
430
  EVALITA-LLM Leaderboard
431
  </h1>
432
- <a href="https://huggingface.co/spaces/mii-llm/open_ita_llm_leaderboard" target="_blank"
433
- style="position: absolute; right: 0; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: #1f77b4; font-weight: 600;">
434
- <svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" fill="#1f77b4" viewBox="0 0 24 24">
435
  <path d="M3.9 12a5 5 0 0 1 7.07-7.07l1.41 1.41-1.41 1.41-1.42-1.42a3 3 0 1 0 4.24 4.24l3.54-3.54a5 5 0 0 1-7.07 7.07l-1.41-1.41 1.41-1.41 1.42 1.42z"/>
436
  <path d="M20.1 12a5 5 0 0 1-7.07 7.07l-1.41-1.41 1.41-1.41 1.42 1.42a3 3 0 1 0-4.24-4.24l-3.54 3.54a5 5 0 0 1 7.07-7.07l1.41 1.41-1.41 1.41-1.42-1.42z"/>
437
  </svg>
@@ -508,64 +497,25 @@ def create_gradio_interface():
508
  # Labels dei campi affiancate
509
 
510
  with gr.Row():
511
- # Labels dei campi affiancate
512
  gr.HTML(f"""
513
- <div style="
514
- display: flex; justify-content: flex-start; width: 100%; gap: 5px;
515
- ">
516
- <div style="
517
- border: 2px solid #1f77b4; border-radius: 8px; padding: 4px 8px;
518
- background-color: #f0f8ff; font-weight: bold; font-size: 12px;
519
- text-align: center;
520
- display: flex; align-items: center; justify-content: center;
521
- min-height: 28px; white-space: nowrap;
522
- " title="Total number of configurations (zero-shot and 5-few-shot) of the models evaluated in the leaderboard.">
523
  Models tested: {len(LEADERBOARD_DF)}
524
  </div>
525
- <div style="
526
- border: 2px solid #1f77b4; border-radius: 8px; padding: 4px 8px;
527
- background-color: #f0f8ff; font-weight: bold; font-size: 12px;
528
- text-align: center;
529
- display: flex; align-items: center; justify-content: center;
530
- min-height: 28px; white-space: nowrap;
531
- " title="Average accuracy of the evaluated model">
532
  Avg combined perf.: {LEADERBOARD_DF['Avg. Comb. Perf. ⬆️'].mean():.2f}
533
  </div>
534
- <div style="
535
- border: 2px solid #1f77b4; border-radius: 8px; padding: 4px 8px;
536
- background-color: #f0f8ff; font-weight: bold; font-size: 12px;
537
- text-align: center;
538
- display: flex; align-items: center; justify-content: center;
539
- min-height: 28px; white-space: nowrap;
540
- " title="Standard deviation of the evaluated models' performance.">
541
  Std. Dev. {LEADERBOARD_DF['Avg. Comb. Perf. ⬆️'].std():.2f}
542
  </div>
543
- <div style="
544
- border: 2px solid #1f77b4; border-radius: 8px; padding: 4px 8px;
545
- background-color: #f0f8ff; font-weight: bold; font-size: 12px;
546
- text-align: center;
547
- display: flex; align-items: center; justify-content: center;
548
- min-height: 28px; white-space: nowrap;
549
- " title="Best evaluated model.">
550
  Best model: {LEADERBOARD_DF.loc[LEADERBOARD_DF['Avg. Comb. Perf. ⬆️'].idxmax(), 'Model']}
551
  </div>
552
- <div style="
553
- border: 2px solid #1f77b4; border-radius: 8px; padding: 4px 8px;
554
- background-color: #f0f8ff; font-weight: bold; font-size: 12px;
555
- text-align: center;
556
- display: flex; align-items: center; justify-content: center;
557
- min-height: 28px; white-space: nowrap;
558
- " title="Accuracy of the best evaluated model.">
559
  Best model accuracy: {LEADERBOARD_DF.loc[LEADERBOARD_DF['Avg. Comb. Perf. ⬆️'].idxmax(), 'Avg. Comb. Perf. ⬆️']:.2f}
560
  </div>
561
- <div style="
562
- border: 2px solid #1f77b4; border-radius: 8px; padding: 4px 8px;
563
- background-color: #f0f8ff; font-weight: bold; font-size: 12px;
564
- text-align: center;
565
- display: flex; align-items: center; justify-content: center;
566
- min-height: 28px; white-space: nowrap;
567
- " title="Maximum achievable accuracy based on the highest performance for each task by any model in the leaderboard.">
568
- Theoretical max: {theoretical_max_combined_perf:.2f}
569
  </div>
570
  </div>
571
  """)
 
415
  def create_title_html():
416
  """Function for title HTML."""
417
  return """
418
+ <div class="title-header">
419
+ <h1 class="title-text">
 
 
 
 
 
 
 
 
 
 
420
  EVALITA-LLM Leaderboard
421
  </h1>
422
+ <a href="https://huggingface.co/spaces/mii-llm/open_ita_llm_leaderboard" target="_blank" class="title-link">
423
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
 
424
  <path d="M3.9 12a5 5 0 0 1 7.07-7.07l1.41 1.41-1.41 1.41-1.42-1.42a3 3 0 1 0 4.24 4.24l3.54-3.54a5 5 0 0 1-7.07 7.07l-1.41-1.41 1.41-1.41 1.42 1.42z"/>
425
  <path d="M20.1 12a5 5 0 0 1-7.07 7.07l-1.41-1.41 1.41-1.41 1.42 1.42a3 3 0 1 0-4.24-4.24l-3.54 3.54a5 5 0 0 1 7.07-7.07l1.41 1.41-1.41 1.41-1.42-1.42z"/>
426
  </svg>
 
497
  # Labels dei campi affiancate
498
 
499
  with gr.Row():
 
500
  gr.HTML(f"""
501
+ <div class="performance-metrics">
502
+ <div class="metric-label" title="Total number of configurations (zero-shot and 5-few-shot) of the models evaluated in the leaderboard.">
 
 
 
 
 
 
 
 
503
  Models tested: {len(LEADERBOARD_DF)}
504
  </div>
505
+ <div class="metric-label" title="Average accuracy of the evaluated models.">
 
 
 
 
 
 
506
  Avg combined perf.: {LEADERBOARD_DF['Avg. Comb. Perf. ⬆️'].mean():.2f}
507
  </div>
508
+ <div class="metric-label" title="Standard deviation of the evaluated models' performance.">
 
 
 
 
 
 
509
  Std. Dev. {LEADERBOARD_DF['Avg. Comb. Perf. ⬆️'].std():.2f}
510
  </div>
511
+ <div class="metric-label" title="Best evaluated model.">
 
 
 
 
 
 
512
  Best model: {LEADERBOARD_DF.loc[LEADERBOARD_DF['Avg. Comb. Perf. ⬆️'].idxmax(), 'Model']}
513
  </div>
514
+ <div class="metric-label" title="Accuracy of the best evaluated model.">
 
 
 
 
 
 
515
  Best model accuracy: {LEADERBOARD_DF.loc[LEADERBOARD_DF['Avg. Comb. Perf. ⬆️'].idxmax(), 'Avg. Comb. Perf. ⬆️']:.2f}
516
  </div>
517
+ <div class="metric-label" title="Maximum achievable accuracy based on the highest performance for each task by any model in the leaderboard.">
518
+ Ideal model: {theoretical_max_combined_perf:.2f}
 
 
 
 
 
 
519
  </div>
520
  </div>
521
  """)
src/display/css_html_js.py CHANGED
@@ -1,5 +1,67 @@
1
  custom_css = """
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  .markdown-text {
4
  font-size: 16px !important;
5
  }
@@ -120,3 +182,4 @@ get_window_url_params = """
120
  }
121
  """
122
 
 
 
1
  custom_css = """
2
 
3
+ /* Title header styles */
4
+ .title-header {
5
+ display: flex;
6
+ align-items: center;
7
+ position: relative;
8
+ width: 100%;
9
+ height: 60px;
10
+ padding: 10px 0;
11
+ }
12
+
13
+ .title-text {
14
+ margin: 0 auto;
15
+ font-weight: 900;
16
+ font-size: 2.5em;
17
+ letter-spacing: 2px;
18
+ text-transform: uppercase;
19
+ background: linear-gradient(90deg, #1f77b4, #00c6ff);
20
+ -webkit-background-clip: text;
21
+ -webkit-text-fill-color: transparent;
22
+ text-shadow: 2px 2px 8px rgba(0,0,0,0.2);
23
+ }
24
+
25
+ .title-link {
26
+ position: absolute;
27
+ right: 0;
28
+ display: inline-flex;
29
+ align-items: center;
30
+ gap: 6px;
31
+ text-decoration: none;
32
+ color: #1f77b4;
33
+ font-weight: 600;
34
+ }
35
+
36
+ .title-link svg {
37
+ width: 22px;
38
+ height: 22px;
39
+ fill: #1f77b4;
40
+ }
41
+
42
+ /* Performance metrics labels */
43
+ .performance-metrics {
44
+ display: flex;
45
+ justify-content: flex-start;
46
+ width: 100%;
47
+ gap: 5px;
48
+ }
49
+
50
+ .metric-label {
51
+ border: 2px solid #1f77b4;
52
+ border-radius: 8px;
53
+ padding: 4px 8px;
54
+ background-color: #f0f8ff;
55
+ font-weight: bold;
56
+ font-size: 12px;
57
+ text-align: center;
58
+ display: flex;
59
+ align-items: center;
60
+ justify-content: center;
61
+ min-height: 28px;
62
+ white-space: nowrap;
63
+ }
64
+
65
  .markdown-text {
66
  font-size: 16px !important;
67
  }
 
182
  }
183
  """
184
 
185
+