Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 5,611 Bytes
970eef1 |
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 |
import React, { useState, useEffect } from "react";
import {
Box,
Paper,
Typography,
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
Alert,
LinearProgress,
Card,
CardContent,
Link,
} from "@mui/material";
import OpenInNewIcon from "@mui/icons-material/OpenInNew";
const EvaluationDisplay = ({ sessionId }) => {
const [results, setResults] = useState(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
useEffect(() => {
const fetchEvaluationResults = async () => {
if (!sessionId) {
setError("No session ID provided");
setLoading(false);
return;
}
try {
// Fetch evaluation results from the API
const response = await fetch(
`http://localhost:3001/evaluation-results/${sessionId}`
);
if (!response.ok) {
throw new Error(`Failed to fetch results: ${response.status}`);
}
const data = await response.json();
if (!data.success) {
throw new Error(data.message || "Failed to fetch evaluation results");
}
setResults(data.results);
} catch (err) {
console.error("Error fetching evaluation results:", err);
setError(err.message);
} finally {
setLoading(false);
}
};
fetchEvaluationResults();
}, [sessionId]);
// Format accuracy as percentage
const formatAccuracy = (value) => {
return `${(value * 100).toFixed(2)}%`;
};
// Format evaluation time
const formatTime = (seconds) => {
return `${seconds.toFixed(2)}s`;
};
if (loading) {
return (
<Box sx={{ width: "100%", mt: 4, mb: 4 }}>
<Typography variant="h5" gutterBottom>
Loading Evaluation Results...
</Typography>
<LinearProgress />
</Box>
);
}
if (error) {
return (
<Alert severity="error" sx={{ mt: 4, mb: 4 }}>
{error}
</Alert>
);
}
if (
!results ||
!results.models_comparison ||
results.models_comparison.length === 0
) {
return (
<Alert severity="info" sx={{ mt: 4, mb: 4 }}>
No evaluation results found for this benchmark.
</Alert>
);
}
return (
<Box sx={{ mt: 4, mb: 6 }}>
<Typography variant="h4" gutterBottom>
Evaluation Results
</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 }}>
<TableHead>
<TableRow>
<TableCell>Rank</TableCell>
<TableCell>Model</TableCell>
<TableCell>Provider</TableCell>
<TableCell align="center">Accuracy</TableCell>
<TableCell align="center">Std Error</TableCell>
<TableCell align="center">Eval Time</TableCell>
<TableCell align="center">Status</TableCell>
</TableRow>
</TableHead>
<TableBody>
{results.models_comparison.map((model, index) => (
<TableRow
key={`${model.model_name}-${model.provider}`}
sx={{
"&:last-child td, &:last-child th": { border: 0 },
backgroundColor: model.success
? "inherit"
: "rgba(0, 0, 0, 0.04)",
}}
>
<TableCell>{index + 1}</TableCell>
<TableCell component="th" scope="row">
<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}
<OpenInNewIcon sx={{ ml: 0.5, fontSize: 16 }} />
</Link>
</TableCell>
<TableCell>{model.provider}</TableCell>
<TableCell align="center">
{model.success ? formatAccuracy(model.accuracy) : "-"}
</TableCell>
<TableCell align="center">
{model.success ? formatAccuracy(model.accuracy_stderr) : "-"}
</TableCell>
<TableCell align="center">
{model.success ? formatTime(model.evaluation_time) : "-"}
</TableCell>
<TableCell align="center">
{model.success ? (
<span style={{ color: "green" }}>✓ Success</span>
) : (
<span style={{ color: "red" }}>✗ Failed</span>
)}
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
<Box sx={{ mt: 4, textAlign: "center" }}>
<Typography variant="body2" color="textSecondary">
Need larger evaluation?{" "}
<Link
href="https://huggingface.co/spaces/yourbench/yourbench"
target="_blank"
rel="noopener noreferrer"
>
Go to this page
</Link>
</Typography>
</Box>
</Box>
);
};
export default EvaluationDisplay;
|