Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 9,234 Bytes
970eef1 2a8ebbd 970eef1 ffa4ae8 970eef1 ebdfd67 81e0b0c ffa4ae8 81e0b0c 970eef1 ffa4ae8 970eef1 81e0b0c 373381c 81e0b0c 970eef1 ebdfd67 c63d8a7 970eef1 ffa4ae8 970eef1 ffa4ae8 970eef1 ffa4ae8 970eef1 373381c 2a8ebbd 373381c 2a8ebbd 373381c ffa4ae8 373381c ffa4ae8 2a8ebbd ffa4ae8 373381c 2a8ebbd 373381c 970eef1 ebdfd67 970eef1 ebdfd67 970eef1 81e0b0c |
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 |
import React, { useState, useEffect } from "react";
import {
Box,
Paper,
Typography,
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
Alert,
CircularProgress,
Card,
CardContent,
Link,
Tooltip,
} from "@mui/material";
import OpenInNewIcon from "@mui/icons-material/OpenInNew";
import CheckCircleIcon from "@mui/icons-material/CheckCircle";
import ErrorDisplay from "../common/ErrorDisplay";
// Styles pour les médailles
const MEDAL_STYLES = {
1: {
color: "#B58A1B",
background: "linear-gradient(135deg, #FFF7E0 0%, #FFD700 100%)",
borderColor: "rgba(212, 160, 23, 0.35)",
shadowColor: "rgba(212, 160, 23, 0.8)",
},
2: {
color: "#667380",
background: "linear-gradient(135deg, #FFFFFF 0%, #D8E3ED 100%)",
borderColor: "rgba(124, 139, 153, 0.35)",
shadowColor: "rgba(124, 139, 153, 0.8)",
},
3: {
color: "#B85C2F",
background: "linear-gradient(135deg, #FDF0E9 0%, #FFBC8C 100%)",
borderColor: "rgba(204, 108, 61, 0.35)",
shadowColor: "rgba(204, 108, 61, 0.8)",
},
default: {
color: "text.primary",
background: "transparent",
borderColor: "transparent",
shadowColor: "transparent",
},
};
// Fonction pour obtenir le style de médaille en fonction du rang
const getMedalStyle = (rank) => {
if (rank <= 3) {
const medalStyle = MEDAL_STYLES[rank];
return {
color: medalStyle.color,
fontWeight: 900,
fontFamily: '"Inter", -apple-system, sans-serif',
width: "24px",
height: "24px",
background: medalStyle.background,
border: "1px solid",
borderColor: medalStyle.borderColor,
borderRadius: "50%",
display: "flex",
alignItems: "center",
justifyContent: "center",
fontSize: "0.95rem",
lineHeight: 1,
padding: 0,
boxShadow: `1px 1px 0 ${medalStyle.shadowColor}`,
marginRight: "8px",
};
}
// Pour les rangs > 3, même dimensions mais transparent
return {
color: "text.primary",
fontWeight: rank <= 10 ? 600 : 400,
width: "24px",
height: "24px",
display: "flex",
alignItems: "center",
justifyContent: "center",
fontSize: "0.95rem",
marginRight: "8px",
};
};
const Display = ({ sessionId, results }) => {
// Format accuracy as percentage
const formatAccuracy = (value) => {
return `${(value * 100).toFixed(2)}\u2009%`;
};
// Fonction pour obtenir une couleur en fonction du score (rouge au vert)
const getColorForScore = (score) => {
// Convertir en pourcentage (0-100)
const percent = score * 100;
// Calcul de la couleur: rouge (0%) à vert (100%)
// Rouge diminue, vert augmente
const red = Math.max(
0,
Math.min(255, Math.round(255 * (1 - percent / 100)))
);
const green = Math.max(0, Math.min(255, Math.round(255 * (percent / 100))));
return `rgb(${red}, ${green}, 0)`;
};
// Format evaluation time
const formatTime = (seconds) => {
return `${seconds.toFixed(2)}s`;
};
if (
!results ||
!results.models_comparison ||
results.models_comparison.length === 0
) {
return (
<ErrorDisplay
error="The demo is currently under heavy load, please try again later."
title="Service Unavailable"
/>
);
}
// Vérifier s'il n'y a aucun modèle réussi
const successfulModels = results.models_comparison.filter(
(model) => model.success
);
if (successfulModels.length === 0) {
return (
<ErrorDisplay
error="The demo is currently under heavy load, please try again later."
title="Service Unavailable"
/>
);
}
return (
<>
<Box sx={{ display: "flex", alignItems: "center", mb: 4 }}>
<CheckCircleIcon color="success" sx={{ mr: 1.5, fontSize: 28 }} />
<Typography variant="h6">Evaluation finished successfully</Typography>
</Box>
<Typography variant="body2" color="text.secondary" sx={{ mb: 2 }}>
The best models for this benchmark are
</Typography>
<TableContainer
component={Paper}
sx={{
border: "1px solid rgba(224, 224, 224, 1)",
boxShadow: "0 2px 4px rgba(0,0,0,0.05)",
}}
>
<Table
sx={{
minWidth: 650,
"& .MuiTableCell-root": {
borderRight: "1px solid rgba(224, 224, 224, 1)",
borderBottom: "1px solid rgba(224, 224, 224, 1)",
"&:last-child": {
borderRight: "none",
},
},
"& .MuiTableRow-root:last-child .MuiTableCell-root": {
borderBottom: "1px solid rgba(224, 224, 224, 1)",
},
}}
>
<TableHead>
<TableRow
sx={{
"& .MuiTableCell-root": {
fontWeight: "bold",
backgroundColor: "rgba(0, 0, 0, 0.02)",
},
}}
>
<TableCell width="80px">Rank</TableCell>
<TableCell>Model</TableCell>
<TableCell align="left">Accuracy</TableCell>
<TableCell align="left">Eval Time</TableCell>
<TableCell align="right">Status</TableCell>
</TableRow>
</TableHead>
<TableBody>
{successfulModels.map((model, index) => (
<TableRow
key={`${model.model_name}-${model.provider}`}
sx={{
"&:nth-of-type(even)": {
backgroundColor: "rgba(0, 0, 0, 0.02)",
},
}}
>
<TableCell>
<Box sx={{ display: "flex", alignItems: "center" }}>
<Box sx={getMedalStyle(index + 1)}>{index + 1}</Box>
</Box>
</TableCell>
<TableCell component="th" scope="row">
<Tooltip title={model.model_name} placement="top">
<Link
href={`https://huggingface.co/${model.model_name}`}
target="_blank"
rel="noopener noreferrer"
sx={{
textDecoration: "none",
"&:hover": {
textDecoration: "underline",
},
display: "flex",
alignItems: "center",
}}
>
{model.model_name.length > 40
? `${model.model_name.substring(0, 40)}...`
: model.model_name}
<OpenInNewIcon sx={{ ml: 0.5, fontSize: 16 }} />
</Link>
</Tooltip>
</TableCell>
<TableCell
align="left"
sx={{
padding: 0,
position: "relative",
overflow: "hidden",
}}
>
<Box
sx={{
position: "absolute",
width: "100%",
height: "100%",
left: 0,
top: 0,
display: "flex",
alignItems: "center",
justifyContent: "flex-start",
pl: 2,
}}
>
<Box
sx={{
position: "absolute",
left: 0,
top: 0,
height: "100%",
width: `${model.accuracy * 100}%`,
backgroundColor: getColorForScore(model.accuracy),
opacity: 0.2,
zIndex: 0,
}}
/>
<Typography
sx={{
position: "relative",
zIndex: 1,
fontWeight: model.accuracy > 0.7 ? "bold" : "normal",
py: 1.5,
textAlign: "left",
}}
>
{formatAccuracy(model.accuracy)}
</Typography>
</Box>
</TableCell>
<TableCell align="left">
{formatTime(model.evaluation_time)}
</TableCell>
<TableCell align="right">
<span style={{ color: "green" }}>✓ Success</span>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
<Box sx={{ mt: 4, textAlign: "center" }}>
<Typography variant="body2" color="textSecondary">
Need larger evaluation?{" "}
<Link
href="https://github.com/huggingface/lighteval"
target="_blank"
rel="noopener noreferrer"
>
Go to this page
</Link>
</Typography>
</Box>
</>
);
};
export default Display;
|