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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7e57a09
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
927a4de
 
 
 
 
 
 
 
 
 
 
 
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
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
from dash import html, dcc
import dash_mantine_components as dmc
from dash_iconify import DashIconify

from config import BUTTON_STYLE, DARK_BACKGROUND, PRIMARY_COLOR

PAPER_URL = "https://arxiv.org/abs/2512.03073"
DATA_URL = "https://huggingface.co/datasets/mmpr/open_model_evolution_data"

def build_header(last_updated: str) -> html.Div:
    """Top header with live badge and partner logos."""
    return html.Div(
        [
            html.Div(
                [
                    html.Span(
                        [
                            html.Span(className="live-dot"),
                            html.Span("LIVE", className="live-label"),
                        ],
                        className="live-row",
                    ),
                    html.Span(
                        f"Last updated: {last_updated}", className="last-updated"
                    ),
                ],
                className="header-status-row",
            ),
            html.Div(
                [
                    html.A(
                        children=[
                            html.Img(
                                src="assets/images/dpi.svg",
                                className="header-logo-img",
                            ),
                            "Data Provenance Initiative",
                        ],
                        href="https://www.dataprovenance.org/",
                        target="_blank",
                        className="no-bg-link header-link",
                    ),
                    html.A(
                        children=[
                            html.Img(
                                src="assets/images/hf.svg",
                                className="header-logo-img",
                            ),
                            html.Span("Hugging Face", className="hf-brand-text"),
                        ],
                        href="https://huggingface.co/",
                        target="_blank",
                        className="no-bg-link header-link",
                    ),
                    html.A(
                        children=[html.Span("Read the paper", className="paper-text")],
                        href=PAPER_URL,
                        target="_blank",
                        className="no-bg-link header-link paper-link",
                    ),
                    html.A(
                        children=[html.Span("Download our data", className="paper-text")],
                        id="data-link-trigger-header",
                        n_clicks=0,
                        className="no-bg-link header-link paper-link",
                    ),
                ],
                className="header-links-row",
            ),
        ],
        style={
            "display": "flex",
            "justifyContent": "space-between",
            "alignItems": "center",
            "padding": "18px 24px",
            "gap": "24px",
            "backgroundColor": DARK_BACKGROUND,
        },
        className="responsive-header",
    )


def build_range_slider(start_ts: int, end_ts: int, value, marks, thumb_children=None):
    """Create the range slider used for time deltas."""
    return dmc.RangeSlider(
        id="time-slider",
        min=start_ts,
        max=end_ts,
        value=value,
        step=24 * 60 * 60,
        color=PRIMARY_COLOR,
        size="md",
        radius="xl",
        marks=marks,
        style={"width": "95%", "paddingLeft": "60px"},
        label=None,
        showLabelOnHover=False,
        labelTransitionProps={"transition": "fade", "duration": 150},
        thumbChildren=thumb_children,
    )


def build_single_slider(start_ts: int, end_ts: int, value, marks, thumb_children=None):
    """Create the single-value slider used for all-time selection."""
    return dmc.Slider(
        id="time-slider-alltime",
        min=start_ts,
        max=end_ts,
        value=value,
        step=24 * 60 * 60,
        color=PRIMARY_COLOR,
        size="md",
        radius="xl",
        marks=marks,
        style={"width": "95%", "paddingLeft": "60px"},
        label=None,
        showLabelOnHover=False,
        labelTransitionProps={"transition": "fade", "duration": 150},
        thumbChildren=thumb_children,
    )


def build_alert_and_title() -> html.Div:
    """Intro alert and title block."""
    return html.Div(
        children=[
            dmc.Alert(
                icon=DashIconify(
                    icon="mdi:information-outline",
                    width=18,
                    height=18,
                    style={"color": "#1A5F8D"},
                ),
                children=[
                    "Note: This dashboard utilizes annotated, publicly available Hugging Face data, which can be downloaded ",
                    html.A(
                        "here",
                        href="https://huggingface.co/datasets/mmpr/open_model_evolution_data",
                        target="_blank",
                        style={
                            "color": "#1A5F8D",
                            "fontWeight": "bold",
                            "textDecoration": "underline",
                        },
                    ),
                    ". Our paper uses deduplicated usage data, which is available upon request.",
                ],
                color="blue",
                radius="md",
                variant="light",
                withCloseButton=True,
                style={
                    "marginTop": "16px",
                    "marginBottom": "8px",
                    "fontSize": "15px",
                    "fontWeight": "500",
                    "marginLeft": "auto",
                    "marginRight": "auto",
                },
            ),
            html.Span(
                "The Open Model Leaderboard",
                style={
                    "fontSize": 40,
                    "fontWeight": "700",
                    "textAlign": "center",
                    "marginTop": "20px",
                    "marginBottom": "20px",
                },
            ),
        ],
        style={
            "display": "flex",
            "flexDirection": "column",
            "alignItems": "center",
            "justifyContent": "center",
            "gap": "12px",
            "marginTop": "20px",
            "marginBottom": "20px",
        },
        className="responsive-title-row",
    )


def build_intro_paragraph() -> html.Div:
    """Body intro paragraph under the title."""
    return html.Div(
        children=[
            "This leaderboard assesses concentrations of power in the open model ecosystem through ranking user downloads across three groups: countries, developers, and models. Explore how user downloads of models are distributed among these groups and identify key players shaping the open model ecosystem on Hugging Face. This dashboard accompanies the paper titled ",
            html.A(
                "Economies of Open Intelligence: Tracing Power & Participation in the Model Ecosystem.",
                href=PAPER_URL,
                target="_blank",
                style={
                    "color": PRIMARY_COLOR,
                    "fontWeight": "700",
                    "textDecoration": "underline",
                },
            ),
        ],
        style={
            "fontSize": 14,
            "marginTop": 18,
            "marginBottom": 12,
            "marginLeft": 100,
            "marginRight": 100,
            "textAlign": "center",
        },
        className="responsive-intro",
    )


def build_filter_controls(time_slider_component) -> html.Div:
    """Filter controls block with segmented controls and sliders."""
    return html.Div(
        children=[
            html.Div(
                [
                    html.Div(
                        html.Span(
                            [
                                "Download View",
                                dmc.HoverCard(
                                    width=260,
                                    shadow="md",
                                    position="top",
                                    children=[
                                        dmc.HoverCardTarget(
                                            html.Span(
                                                DashIconify(
                                                    icon="mdi:information-outline",
                                                    width=16,
                                                    height=16,
                                                    style={
                                                        "marginLeft": "6px",
                                                        "color": PRIMARY_COLOR,
                                                        "verticalAlign": "middle",
                                                    },
                                                ),
                                                style={"cursor": "pointer"},
                                            )
                                        ),
                                        dmc.HoverCardDropdown(
                                            dmc.Text(
                                                "We believe this filter isolates more authentic usage, mitigating the impact of automatic software downloads for older models.",
                                                size="sm",
                                                style={"maxWidth": "240px"},
                                            )
                                        ),
                                    ],
                                ),
                            ],
                            className="filter-label-row",
                        ),
                        className="filter-label-container",
                    ),
                    html.Div(
                        [
                            dmc.SegmentedControl(
                                id="segmented",
                                value="all-downloads",
                                color=PRIMARY_COLOR,
                                transitionDuration=200,
                                data=[
                                    {
                                        "value": "all-downloads",
                                        "label": "All Downloads",
                                    },
                                    {
                                        "value": "filtered-downloads",
                                        "label": html.Span(["Filtered Downloads"]),
                                    },
                                ],
                                mb=10,
                            ),
                        ],
                        className="filter-segmented-row",
                    ),
                    html.Div(
                        "Choose whether to count all downloads, or only downloads up to one year from model creation.",
                        className="filter-description",
                    ),
                    html.Div(
                        [
                            html.Div("Model Attribution", className="filter-label"),
                            dmc.SegmentedControl(
                                id="model-attribution-segmented",
                                value="uploader",
                                color=PRIMARY_COLOR,
                                transitionDuration=200,
                                data=[
                                    {"value": "uploader", "label": "Model Uploader"},
                                    {
                                        "value": "original_creator",
                                        "label": "Original Model Creator",
                                    },
                                ],
                                mb=10,
                            ),
                            html.Div(
                                "Toggle between having downloads attributed to the account that uploaded the model, or the account that uploaded the model that this was originally derived from.",
                                className="filter-description",
                            ),
                        ],
                        style={"marginTop": "10px"},
                    ),
                    html.Span(
                        id="global-toggle-status", className="global-toggle-status"
                    ),
                ],
                className="main-content-left",
            ),
            html.Div(
                [
                    html.Div(
                        [
                            html.Span("Download Date Range", className="filter-label"),
                            dmc.HoverCard(
                                width=260,
                                shadow="md",
                                position="top",
                                children=[
                                    dmc.HoverCardTarget(
                                        html.Span(
                                            DashIconify(
                                                icon="mdi:information-outline",
                                                width=16,
                                                height=16,
                                                style={
                                                    "marginLeft": "6px",
                                                    "color": PRIMARY_COLOR,
                                                    "verticalAlign": "middle",
                                                },
                                            ),
                                            style={"cursor": "pointer"},
                                        )
                                    ),
                                    dmc.HoverCardDropdown(
                                        dmc.Text(
                                            "Toggle between viewing downloads between a date range or all-time downloads at a single date.",
                                            size="sm",
                                            style={"maxWidth": "240px"},
                                        )
                                    ),
                                ],
                            ),
                        ],
                        className="filter-label-row",
                    ),
                    dmc.Switch(
                        id="time-range-toggle",
                        label="All-time",
                        checked=False,
                        color=PRIMARY_COLOR,
                        style={"marginBottom": "12px"},
                    ),
                    dcc.Loading(
                        id="loading-slider",
                        type="circle",
                        color=PRIMARY_COLOR,
                        children=html.Div(
                            id="slider-container", children=[time_slider_component]
                        ),
                    ),
                    html.Div(
                        id="slider-description",
                        children="Adjust the time range to filter leaderboard results by when models were downloaded by users.",
                        className="filter-description filter-description-margin",
                    ),
                    html.Div(
                        [
                            html.Div(
                                [
                                    DashIconify(
                                        icon="mdi:lightbulb-on-outline",
                                        width=20,
                                        height=20,
                                        style={
                                            "marginRight": "8px",
                                            "color": DARK_BACKGROUND,
                                        },
                                    ),
                                    html.Span("Tip"),
                                ],
                                className="tip-title",
                            ),
                            html.Div(
                                [
                                    "Try switching between ",
                                    html.Span(
                                        "All Downloads", className="tip-highlight"
                                    ),
                                    " and ",
                                    html.Span(
                                        "Filtered Downloads", className="tip-highlight"
                                    ),
                                    " to compare net popularity (but many duplicate, unused downloads) versus more immediate interest as models are released. ",
                                    "You can also toggle between ",
                                    html.Span(
                                        "Model Uploader", className="tip-highlight"
                                    ),
                                    " and ",
                                    html.Span(
                                        "Original Model Creator",
                                        className="tip-highlight",
                                    ),
                                    " to see how attribution affects perceived popularity.",
                                ],
                                className="tip-description",
                            ),
                        ],
                        className="tip-section",
                    ),
                ],
                className="main-content-right",
            ),
        ],
        style={
            "display": "flex",
            "gap": "24px",
            "padding": "32px",
            "alignItems": "flex-start",
            "marginLeft": "100px",
            "marginRight": "100px",
            "backgroundColor": "#FFFBF9",
            "borderRadius": "18px",
        },
        className="responsive-main-content",
    )


def build_leaderboard_tabs() -> html.Div:
    """Tabbed leaderboard section."""
    return html.Div(
        [
            dcc.Tabs(
                id="leaderboard-tabs",
                value="Countries",
                children=[
                    dcc.Tab(
                        label="Countries",
                        value="Countries",
                        style={
                            "backgroundColor": "transparent",
                            "border": "none",
                            "padding": "10px 18px",
                            "color": "#6B7280",
                            "fontWeight": "500",
                        },
                        selected_style={
                            "backgroundColor": "transparent",
                            "border": "none",
                            "padding": "10px 18px",
                            "fontWeight": "700",
                            "borderBottom": "3px solid #082030",
                        },
                        children=[
                            html.Div(
                                children=[
                                    "The country leaderboard shows how downloads are distributed across different nations, highlighting which countries are leading in model usage and adoption. The metadata includes the ",
                                    html.Span("country", className="meta-var"),
                                    " and number of ",
                                    html.Span("user downloads", className="meta-var"),
                                    ".",
                                ],
                                className="tab-description",
                            ),
                            html.Div(
                                dcc.Loading(
                                    id="loading-countries",
                                    type="circle",
                                    color=PRIMARY_COLOR,
                                    children=html.Div(id="top_countries-table"),
                                ),
                                className="responsive-table-wrapper",
                            ),
                            html.Button(
                                id="top_countries-toggle",
                                children="▼ Show Top 50",
                                n_clicks=0,
                                style={**BUTTON_STYLE, "border": "none"},
                            ),
                        ],
                    ),
                    dcc.Tab(
                        label="Developers",
                        value="Developers",
                        style={
                            "backgroundColor": "transparent",
                            "border": "none",
                            "padding": "10px 18px",
                            "color": "#6B7280",
                            "fontWeight": "500",
                        },
                        selected_style={
                            "backgroundColor": "transparent",
                            "border": "none",
                            "padding": "10px 18px",
                            "fontWeight": "700",
                            "borderBottom": "3px solid #082030",
                        },
                        children=[
                            html.Div(
                                children=[
                                    "The developer leaderboard highlights the most influential model creators on Hugging Face, showcasing which developers have garnered the highest download counts for their models. The metadata includes the ",
                                    html.Span("developer", className="meta-var"),
                                    ", number of ",
                                    html.Span("user downloads", className="meta-var"),
                                    ", and ",
                                    html.Span("country", className="meta-var"),
                                    ".",
                                ],
                                className="tab-description",
                            ),
                            html.Div(
                                dcc.Loading(
                                    id="loading-developers",
                                    type="circle",
                                    color=PRIMARY_COLOR,
                                    children=html.Div(id="top_developers-table"),
                                ),
                                className="responsive-table-wrapper",
                            ),
                            html.Button(
                                id="top_developers-toggle",
                                children="▼ Show Top 50",
                                n_clicks=0,
                                style={**BUTTON_STYLE, "border": "none"},
                            ),
                        ],
                    ),
                    dcc.Tab(
                        label="Models",
                        value="Models",
                        style={
                            "backgroundColor": "transparent",
                            "border": "none",
                            "padding": "10px 18px",
                            "color": "#6B7280",
                            "fontWeight": "500",
                        },
                        selected_style={
                            "backgroundColor": "transparent",
                            "border": "none",
                            "padding": "10px 18px",
                            "fontWeight": "700",
                            "borderBottom": "3px solid #082030",
                        },
                        children=[
                            html.Div(
                                children=[
                                    "The model leaderboard ranks individual models based on their download counts, revealing which models are most popular among users on Hugging Face. The metadata includes the ",
                                    html.Span("model name", className="meta-var"),
                                    ", number of ",
                                    html.Span("user downloads", className="meta-var"),
                                    ", ",
                                    html.Span("developer", className="meta-var"),
                                    ", and ",
                                    html.Span("modality", className="meta-var"),
                                    " (the input and output types of the model).",
                                ],
                                className="tab-description",
                            ),
                            html.Div(
                                dcc.Loading(
                                    id="loading-models",
                                    type="circle",
                                    color=PRIMARY_COLOR,
                                    children=html.Div(id="top_models-table"),
                                ),
                                className="responsive-table-wrapper",
                            ),
                            html.Button(
                                id="top_models-toggle",
                                children="▼ Show Top 50",
                                n_clicks=0,
                                style={**BUTTON_STYLE, "border": "none"},
                            ),
                        ],
                    ),
                ],
            ),
        ],
        style={
            "borderRadius": "18px",
            "padding": "32px",
            "marginTop": "12px",
            "marginBottom": "12px",
            "marginLeft": "50px",
            "marginRight": "50px",
        },
        className="responsive-tabs",
    )

def build_main_layout(last_updated: str, time_slider_component) -> html.Div:
    """Full page layout assembled from smaller sections."""
    return html.Div(
        [
            dmc.Modal(
                id="paper-disclaimer-modal",
                opened=False,
                withCloseButton=False,
                title=html.Span("Before you continue", style={"fontWeight": "700"}),
                centered=True,
                children=[
                    dmc.Text(
                        "The dashboard's data is based upon publicly available Hugging Face data. This differs from our paper that uses deduplicated usage data, which is available upon request.",
                        size="sm",
                    ),
                    dmc.Group(
                        mt="md",
                        justify="flex-end",
                        children=[
                            dmc.Button(
                                "Cancel",
                                id="paper-disclaimer-close",
                                variant="default",
                            ),
                            dmc.Button(
                                "I understand",
                                id="paper-disclaimer-confirm",
                                color=PRIMARY_COLOR,
                            ),
                        ],
                    ),
                ],
            ),
            build_header(last_updated),
            build_alert_and_title(),
            build_intro_paragraph(),
            build_filter_controls(time_slider_component),
            build_leaderboard_tabs(),
        ],
        style={
            "fontFamily": "Inter",
            "backgroundColor": "#ffffff",
            "minHeight": "100vh",
        },
    )