File size: 5,402 Bytes
c1ddcde
aa37927
c1ddcde
 
 
aa37927
 
 
 
 
 
c1ddcde
 
 
aa37927
ce8d243
aa37927
 
c1ddcde
 
 
 
 
 
dd5dfbd
c1ddcde
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aa37927
c391bf5
 
 
 
 
 
f8ae415
c1ddcde
c391bf5
c1ddcde
 
 
 
 
 
 
 
f8ae415
c1ddcde
 
 
 
 
 
f8ae415
c1ddcde
 
 
 
 
 
f8ae415
c1ddcde
 
 
 
 
 
f8ae415
c1ddcde
 
 
 
 
 
f8ae415
c1ddcde
 
 
 
 
 
f8ae415
c1ddcde
 
 
ce8d243
c1ddcde
f8ae415
dd5dfbd
f8ae415
a3a9c86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1193d13
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
# src/display/utils.py

from dataclasses import dataclass
from enum import Enum
from typing import Any, List

from src.about import Tasks

@dataclass
class ColumnContent:
    name: str
    type: Any
    label: str
    description: str
    hidden: bool = False
    displayed_by_default: bool = True
    never_hidden: bool = False

# Initialize the list of columns for the leaderboard
COLUMNS: List[ColumnContent] = []

# Essential columns
COLUMNS.append(
    ColumnContent(
        name="model_name",  # Changed from "model" to "model_name"
        type=str,
        label="Model",
        description="Model name",
        never_hidden=True,
    )
)
COLUMNS.append(
    ColumnContent(
        name="average",
        type=float,
        label="Average Accuracy (%)",
        description="Average accuracy across all subjects",
    )
)

# Include per-subject accuracy columns based on your subjects
for task in Tasks:
    COLUMNS.append(
        ColumnContent(
            name=task.value.benchmark,
            type=float,
            label=f"{task.value.col_name} (%)",
            description=f"Accuracy on {task.value.col_name}",
            displayed_by_default=True,
        )
    )

# Additional columns
COLUMNS.extend([
    ColumnContent(
        name="model_type",
        type=str,
        label="Model Type",
        description="Type of the model (e.g., Transformer, RNN, etc.)",
        displayed_by_default=True,
    ),
    ColumnContent(
        name="weight_type",
        type=str,
        label="Weight Type",
        description="Type of model weights (e.g., Original, Delta, Adapter)",
        displayed_by_default=True,
    ),
    ColumnContent(
        name="precision",
        type=str,
        label="Precision",
        description="Precision of the model weights (e.g., float16)",
        displayed_by_default=True,
    ),
    ColumnContent(
        name="license",
        type=str,
        label="License",
        description="License of the model",
        displayed_by_default=True,
    ),
    ColumnContent(
        name="likes",
        type=int,
        label="Likes",
        description="Number of likes on the Hugging Face Hub",
        displayed_by_default=True,
    ),
    ColumnContent(
        name="still_on_hub",
        type=bool,
        label="Available on the Hub",
        description="Whether the model is still available on the Hugging Face Hub",
        displayed_by_default=True,
    ),
])

# Create lists of column names for use in the application
COLS = [col.name for col in COLUMNS]
BENCHMARK_COLS = [col.name for col in COLUMNS if col.name not in [
    "model_name", "average", "model_type", "weight_type", "precision", "license", "likes", "still_on_hub"
]]

# For the queue columns in the submission tab
@dataclass(frozen=True)
class EvalQueueColumn:
    name: str
    type: Any
    label: str
    description: str

# Define the queue columns
EVAL_QUEUE_COLUMNS: List[EvalQueueColumn] = [
    EvalQueueColumn(
        name="model",
        type=str,
        label="Model",
        description="Model name",
    ),
    EvalQueueColumn(
        name="revision",
        type=str,
        label="Revision",
        description="Model revision or commit hash",
    ),
    EvalQueueColumn(
        name="private",
        type=bool,
        label="Private",
        description="Is the model private?",
    ),
    EvalQueueColumn(
        name="precision",
        type=str,
        label="Precision",
        description="Precision of the model weights",
    ),
    EvalQueueColumn(
        name="weight_type",
        type=str,
        label="Weight Type",
        description="Type of model weights",
    ),
    EvalQueueColumn(
        name="status",
        type=str,
        label="Status",
        description="Evaluation status",
    ),
]

# Create lists for evaluation columns and types
EVAL_COLS = [col.name for col in EVAL_QUEUE_COLUMNS]
EVAL_TYPES = [col.type for col in EVAL_QUEUE_COLUMNS]

# Model information
@dataclass
class ModelDetails:
    name: str
    display_name: str = ""
    symbol: str = ""  # emoji

class ModelType(Enum):
    PT = ModelDetails(name="pretrained", symbol="🟢")
    FT = ModelDetails(name="fine-tuned", symbol="🔶")
    IFT = ModelDetails(name="instruction-tuned", symbol="â­•")
    RL = ModelDetails(name="RL-tuned", symbol="🟦")
    Unknown = ModelDetails(name="", symbol="?")

    def to_str(self, separator=" "):
        return f"{self.value.symbol}{separator}{self.value.name}"

    @staticmethod
    def from_str(type_str):
        if "fine-tuned" in type_str or "🔶" in type_str:
            return ModelType.FT
        if "pretrained" in type_str or "🟢" in type_str:
            return ModelType.PT
        if "RL-tuned" in type_str or "🟦" in type_str:
            return ModelType.RL
        if "instruction-tuned" in type_str or "â­•" in type_str:
            return ModelType.IFT
        return ModelType.Unknown

class WeightType(Enum):
    Adapter = "Adapter"
    Original = "Original"
    Delta = "Delta"

class Precision(Enum):
    float16 = "float16"
    bfloat16 = "bfloat16"
    Unknown = "Unknown"

    @staticmethod
    def from_str(precision_str):
        if precision_str in ["torch.float16", "float16"]:
            return Precision.float16
        if precision_str in ["torch.bfloat16", "bfloat16"]:
            return Precision.bfloat16
        return Precision.Unknown