File size: 19,060 Bytes
16d37fe
22b961e
37f25a7
 
 
 
22b961e
16d37fe
37f25a7
22b961e
 
37f25a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16d37fe
37f25a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16d37fe
37f25a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16d37fe
37f25a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16d37fe
37f25a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16d37fe
37f25a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16d37fe
 
37f25a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16d37fe
37f25a7
 
 
 
 
 
 
 
 
 
 
 
22b961e
37f25a7
 
 
 
 
 
 
 
 
22b961e
37f25a7
22b961e
37f25a7
22b961e
 
37f25a7
 
 
 
22b961e
37f25a7
 
 
 
22b961e
16d37fe
37f25a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16d37fe
37f25a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fc48a46
37f25a7
 
fc48a46
 
 
37f25a7
16d37fe
37f25a7
 
 
 
 
 
 
 
 
 
 
 
 
16d37fe
37f25a7
 
fc48a46
37f25a7
fc48a46
37f25a7
fc48a46
37f25a7
 
16d37fe
37f25a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16d37fe
37f25a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22b961e
37f25a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
612e75d
37f25a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
612e75d
37f25a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16d37fe
37f25a7
 
 
 
 
 
612e75d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
import gradio as gr
import plotly.graph_objs as go
import plotly.express as px
import pandas as pd
import numpy as np
from datetime import datetime
import json

# Enhanced model evaluation data with comprehensive metrics
MODEL_EVALS = {
    "Proteins": {
        "models": {
            "AlphaFold2 (Tertiary GDT-TS)": {
                "score": 0.924,
                "parameters": "2.3B",
                "institution": "DeepMind",
                "date": "2021-07-15",
                "paper": "https://doi.org/10.1038/s41586-021-03819-2",
                "task": "Protein Structure Prediction"
            },
            "Nexa Bio2 (Tertiary)": {
                "score": 0.90,
                "parameters": "1.8B",
                "institution": "Nexa Research",
                "date": "2024-11-20",
                "paper": "https://arxiv.org/abs/2024.protein.nexa",
                "task": "Protein Structure Prediction"
            },
            "DeepCNF (Secondary)": {
                "score": 0.85,
                "parameters": "450M",
                "institution": "University of Missouri",
                "date": "2019-03-12",
                "paper": "https://doi.org/10.1186/s12859-019-2940-0",
                "task": "Secondary Structure Prediction"
            },
            "Porter6 (Secondary)": {
                "score": 0.8456,
                "parameters": "120M",
                "institution": "University of Padova",
                "date": "2022-05-10",
                "paper": "https://doi.org/10.1038/s41598-022-10847-w",
                "task": "Secondary Structure Prediction"
            },
            "Nexa Bio1 (Secondary)": {
                "score": 0.71,
                "parameters": "800M",
                "institution": "Nexa Research",
                "date": "2024-09-15",
                "paper": "https://arxiv.org/abs/2024.bio1.nexa",
                "task": "Secondary Structure Prediction"
            }
        },
        "metric": "Accuracy",
        "description": "Protein structure prediction accuracy across secondary and tertiary structure tasks"
    },
    "Astronomy": {
        "models": {
            "Nexa Astro": {
                "score": 0.97,
                "parameters": "2.1B",
                "institution": "Nexa Research",
                "date": "2024-10-05",
                "paper": "https://arxiv.org/abs/2024.astro.nexa",
                "task": "Galaxy Classification"
            },
            "Baseline CNN": {
                "score": 0.89,
                "parameters": "50M",
                "institution": "Various",
                "date": "2020-01-01",
                "paper": "Standard CNN Architecture",
                "task": "Galaxy Classification"
            }
        },
        "metric": "F1-Score",
        "description": "Astronomical object classification and analysis performance"
    },
    "Materials Science": {
        "models": {
            "Nexa Materials": {
                "score": 0.9999,
                "parameters": "1.5B",
                "institution": "Nexa Research",
                "date": "2024-12-01",
                "paper": "https://arxiv.org/abs/2024.materials.nexa",
                "task": "Property Prediction"
            },
            "Random Forest Baseline": {
                "score": 0.92,
                "parameters": "N/A",
                "institution": "Various",
                "date": "2018-01-01",
                "paper": "Standard ML Baseline",
                "task": "Property Prediction"
            }
        },
        "metric": "RΒ² Score",
        "description": "Materials property prediction and discovery performance"
    },
    "Quantum State Tomography": {
        "models": {
            "Quantum TomoNet": {
                "score": 0.85,
                "parameters": "890M",
                "institution": "IBM Research",
                "date": "2023-04-20",
                "paper": "https://doi.org/10.1038/s41567-023-02020-x",
                "task": "State Reconstruction"
            },
            "Nexa QST Model": {
                "score": 0.80,
                "parameters": "1.2B",
                "institution": "Nexa Research",
                "date": "2024-08-30",
                "paper": "https://arxiv.org/abs/2024.qst.nexa",
                "task": "State Reconstruction"
            }
        },
        "metric": "Fidelity",
        "description": "Quantum state reconstruction accuracy and fidelity measures"
    },
    "High Energy Physics": {
        "models": {
            "CMSNet": {
                "score": 0.94,
                "parameters": "3.2B",
                "institution": "CERN",
                "date": "2023-11-15",
                "paper": "https://doi.org/10.1007/JHEP11(2023)045",
                "task": "Particle Detection"
            },
            "Nexa HEP Model": {
                "score": 0.91,
                "parameters": "2.8B",
                "institution": "Nexa Research",
                "date": "2024-07-12",
                "paper": "https://arxiv.org/abs/2024.hep.nexa",
                "task": "Particle Detection"
            }
        },
        "metric": "AUC-ROC",
        "description": "High energy physics event detection and classification"
    },
    "Computational Fluid Dynamics": {
        "models": {
            "Nexa CFD Model": {
                "score": 0.92,
                "parameters": "1.9B",
                "institution": "Nexa Research",
                "date": "2024-06-18",
                "paper": "https://arxiv.org/abs/2024.cfd.nexa",
                "task": "Flow Prediction"
            },
            "FlowNet": {
                "score": 0.89,
                "parameters": "1.1B",
                "institution": "Technical University of Munich",
                "date": "2022-09-30",
                "paper": "https://doi.org/10.1016/j.jcp.2022.111567",
                "task": "Flow Prediction"
            }
        },
        "metric": "RMSE",
        "description": "Fluid dynamics simulation and prediction accuracy"
    }
}

def create_overall_leaderboard():
    """Create overall leaderboard across all domains"""
    all_models = []
    for domain, data in MODEL_EVALS.items():
        for model_name, model_data in data["models"].items():
            all_models.append({
                "Model": model_name,
                "Domain": domain,
                "Score": model_data["score"],
                "Parameters": model_data["parameters"],
                "Institution": model_data["institution"],
                "Date": model_data["date"],
                "Paper": model_data["paper"],
                "Task": model_data["task"]
            })
    
    df = pd.DataFrame(all_models)
    df = df.sort_values('Score', ascending=False)
    return df

def create_domain_plot(domain):
    """Create domain-specific bar chart"""
    if domain not in MODEL_EVALS:
        return go.Figure()
    
    models_data = MODEL_EVALS[domain]["models"]
    models = list(models_data.keys())
    scores = [models_data[model]["score"] for model in models]
    
    # Color scheme: Nexa models in brand color, others in neutral
    colors = ['#6366f1' if 'Nexa' in model else '#64748b' for model in models]
    
    fig = go.Figure()
    fig.add_trace(go.Bar(
        x=models,
        y=scores,
        marker_color=colors,
        text=[f"{score:.3f}" for score in scores],
        textposition='auto',
        hovertemplate='<b>%{x}</b><br>Score: %{y:.3f}<extra></extra>'
    ))
    
    fig.update_layout(
        title=f"{domain} - Model Performance Comparison",
        xaxis_title="Model",
        yaxis_title=f"{MODEL_EVALS[domain]['metric']}",
        yaxis_range=[0, 1.0],
        template="plotly_white",
        height=500,
        font=dict(size=12),
        title_font_size=16,
        showlegend=False
    )
    
    # Rotate x-axis labels for better readability
    fig.update_xaxes(tickangle=45)
    
    return fig

def create_radar_chart():
    """Create radar chart showing Nexa models across domains"""
    nexa_models = {}
    categories = []
    
    for domain, data in MODEL_EVALS.items():
        for model_name, model_data in data["models"].items():
            if "Nexa" in model_name:
                categories.append(domain)
                nexa_models[domain] = model_data["score"]
                break
    
    if not nexa_models:
        return go.Figure()
    
    fig = go.Figure()
    
    fig.add_trace(go.Scatterpolar(
        r=list(nexa_models.values()),
        theta=categories,
        fill='toself',
        name='Nexa Models',
        line_color='#6366f1',
        fillcolor='rgba(99, 102, 241, 0.2)'
    ))
    
    fig.update_layout(
        polar=dict(
            radialaxis=dict(
                visible=True,
                range=[0, 1]
            )),
        showlegend=True,
        title="Nexa Models Performance Across Domains",
        height=500
    )
    
    return fig

def create_timeline_plot():
    """Create timeline showing model releases"""
    all_models = []
    for domain, data in MODEL_EVALS.items():
        for model_name, model_data in data["models"].items():
            all_models.append({
                "Model": model_name,
                "Domain": domain,
                "Score": model_data["score"],
                "Date": pd.to_datetime(model_data["date"]),
                "Institution": model_data["institution"],
                "IsNexa": "Nexa" in model_name
            })
    
    df = pd.DataFrame(all_models)
    df = df.sort_values('Date')
    
    fig = px.scatter(
        df, 
        x='Date', 
        y='Score',
        color='IsNexa',
        size='Score',
        hover_data=['Model', 'Domain', 'Institution'],
        color_discrete_map={True: '#6366f1', False: '#64748b'},
        title="Model Performance Timeline"
    )
    
    fig.update_layout(
        height=500,
        showlegend=True,
        legend=dict(title="Model Type")
    )
    
    # Update trace names for better legend display
    fig.for_each_trace(lambda t: t.update(name="Nexa Models" if t.name == "True" else "Other Models"))
    
    return fig

def get_domain_details(domain):
    """Get detailed information about a domain"""
    if domain not in MODEL_EVALS:
        return "Domain not found"
    
    data = MODEL_EVALS[domain]
    details = {
        "domain": domain,
        "metric": data["metric"],
        "description": data["description"],
        "models": data["models"]
    }
    return json.dumps(details, indent=2)

def format_leaderboard_table(df):
    """Format the leaderboard table for display"""
    # Create display-friendly format
    df_display = df.copy()
    # Truncate long URLs for better display
    df_display['Paper'] = df_display['Paper'].apply(
        lambda x: "πŸ“„ Link" if x.startswith('http') else x
    )
    return df_display

# Custom CSS for styling
custom_css = """
<style>
    .main-header {
        text-align: center;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        padding: 2rem;
        border-radius: 10px;
        margin-bottom: 2rem;
    }
    .metric-card {
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        padding: 1rem;
        margin: 0.5rem;
        text-align: center;
    }
    .metric-value {
        font-size: 2rem;
        font-weight: bold;
        color: #6366f1;
    }
    .metric-label {
        color: #64748b;
        font-size: 0.9rem;
    }
</style>
"""

# Create Gradio interface
with gr.Blocks(
    title="πŸ”¬ Nexa Evals - Scientific ML Benchmark Leaderboard",
    theme=gr.themes.Soft(),
    css=custom_css
) as demo:
    
    # Header
    gr.HTML("""
    <div class="main-header">
        <h1>πŸ”¬ Nexa Evals</h1>
        <h2>Scientific Machine Learning Benchmark Leaderboard</h2>
        <p>Comprehensive evaluation suite comparing state-of-the-art models across scientific domains</p>
    </div>
    """)
    
    # Metrics overview
    total_models = sum(len(data["models"]) for data in MODEL_EVALS.values())
    total_domains = len(MODEL_EVALS)
    nexa_models = sum(1 for data in MODEL_EVALS.values() 
                     for model in data["models"].keys() if "Nexa" in model)
    
    with gr.Row():
        gr.HTML(f"""
        <div class="metric-card">
            <div class="metric-value">{total_models}</div>
            <div class="metric-label">Total Models</div>
        </div>
        """)
        gr.HTML(f"""
        <div class="metric-card">
            <div class="metric-value">{total_domains}</div>
            <div class="metric-label">Scientific Domains</div>
        </div>
        """)
        gr.HTML(f"""
        <div class="metric-card">
            <div class="metric-value">{nexa_models}</div>
            <div class="metric-label">Nexa Models</div>
        </div>
        """)
    
    # Main content tabs
    with gr.Tabs():
        
        # Overall Leaderboard Tab
        with gr.TabItem("πŸ† Overall Leaderboard"):
            gr.Markdown("""
            ### Complete ranking of all models across scientific domains
            Models are ranked by their performance scores within their respective domains.
            """)
            
            overall_df = create_overall_leaderboard()
            leaderboard_table = gr.Dataframe(
                value=overall_df,
                headers=["Model", "Domain", "Score", "Parameters", "Institution", "Date", "Paper", "Task"],
                datatype=["str", "str", "number", "str", "str", "str", "str", "str"],
                interactive=False
            )
        
        # Domain Analysis Tab
        with gr.TabItem("πŸ“Š Domain Analysis"):
            gr.Markdown("""
            ### Domain-specific model performance analysis
            Select a domain to view detailed performance metrics and model comparisons.
            """)
            
            with gr.Row():
                domain_dropdown = gr.Dropdown(
                    choices=list(MODEL_EVALS.keys()),
                    value=list(MODEL_EVALS.keys())[0],
                    label="Select Scientific Domain"
                )
                
            with gr.Row():
                domain_plot = gr.Plot(label="Performance Comparison")
                
            with gr.Row():
                domain_details = gr.Code(
                    label="Domain Details (JSON)",
                    language="json"
                )
            
            domain_dropdown.change(
                fn=lambda x: [create_domain_plot(x), get_domain_details(x)],
                inputs=domain_dropdown,
                outputs=[domain_plot, domain_details]
            )
            
            # Initialize with first domain
            demo.load(
                fn=lambda: [create_domain_plot(list(MODEL_EVALS.keys())[0]), 
                           get_domain_details(list(MODEL_EVALS.keys())[0])],
                outputs=[domain_plot, domain_details]
            )
        
        # Nexa Models Tab
        with gr.TabItem("πŸš€ Nexa Models"):
            gr.Markdown("""
            ### Nexa Research model performance overview
            Comprehensive analysis of Nexa models across all scientific domains.
            """)
            
            with gr.Row():
                nexa_radar = gr.Plot(
                    value=create_radar_chart(),
                    label="Nexa Models - Cross-Domain Performance"
                )
            
            nexa_df = overall_df[overall_df['Model'].str.contains('Nexa', na=False)]
            nexa_table = gr.Dataframe(
                value=nexa_df,
                headers=["Model", "Domain", "Score", "Parameters", "Institution", "Date", "Paper", "Task"],
                label="Nexa Models Detailed View"
            )
        
        # Timeline Tab
        with gr.TabItem("πŸ“ˆ Timeline"):
            gr.Markdown("""
            ### Model development timeline
            Track the evolution of scientific ML models over time.
            """)
            
            timeline_plot = gr.Plot(
                value=create_timeline_plot(),
                label="Model Performance Timeline"
            )
        
        # About Tab
        with gr.TabItem("ℹ️ About"):
            gr.Markdown("""
            ## About Nexa Evals
            
            Nexa Evals is a comprehensive benchmarking suite for evaluating machine learning models 
            across diverse scientific domains. Our evaluation framework provides:
            
            ### 🎯 Evaluation Domains
            - **Proteins**: Structure prediction (secondary/tertiary)
            - **Astronomy**: Galaxy classification and analysis
            - **Materials Science**: Property prediction and discovery
            - **Quantum State Tomography**: State reconstruction
            - **High Energy Physics**: Particle detection and classification
            - **Computational Fluid Dynamics**: Flow prediction and simulation
            
            ### πŸ“Š Evaluation Metrics
            Each domain uses appropriate metrics:
            - **Accuracy**: Classification tasks
            - **F1-Score**: Balanced precision/recall evaluation
            - **RΒ² Score**: Regression performance
            - **Fidelity**: Quantum state reconstruction accuracy
            - **AUC-ROC**: Binary classification performance
            - **RMSE**: Regression error measurement
            
            ### πŸ”¬ Scientific Rigor
            All benchmarks are based on established datasets and evaluation protocols 
            from peer-reviewed research. Model scores are computed using standardized 
            metrics to ensure fair comparison.
            
            ### πŸš€ Nexa Research
            Nexa Research is developing next-generation AI models specifically designed 
            for scientific applications. Our models are trained on domain-specific data 
            and optimized for scientific reasoning and discovery.
            
            ### πŸ“š Citations & References
            For detailed information about evaluation protocols and datasets, please 
            refer to the linked papers in the model details.
            
            ---
            
            **Last Updated**: {datetime.now().strftime("%B %d, %Y")}
            
            **Contact**: [Nexa Research](https://nexaresearch.ai) | [GitHub](https://github.com/nexa-research)
            """)
    
    # Footer
    gr.HTML("""
    <div style="text-align: center; margin-top: 2rem; padding: 1rem; background: #f8fafc; border-radius: 8px;">
        <p>πŸ”¬ <strong>Nexa Evals</strong> - Advancing Scientific Machine Learning</p>
        <p>Built with ❀️ by <a href="https://nexaresearch.ai" target="_blank">Nexa Research</a></p>
    </div>
    """)

if __name__ == "__main__":
    demo.launch(
        share=False,
        server_name="0.0.0.0",
        server_port=7860,
        show_error=True
    )