import React, { useState } from "react";
import {
Box,
Paper,
Typography,
TextField,
Button,
FormControl,
InputLabel,
Select,
MenuItem,
Stack,
Grid,
CircularProgress,
Alert,
} from "@mui/material";
import RocketLaunchIcon from "@mui/icons-material/RocketLaunch";
import CheckCircleOutlineIcon from "@mui/icons-material/CheckCircleOutline";
import { alpha } from "@mui/material/styles";
import InfoIconWithTooltip from "../../../../components/shared/InfoIconWithTooltip";
import { MODEL_TYPES } from "../../../../pages/LeaderboardPage/components/Leaderboard/constants/modelTypes";
import { SUBMISSION_PRECISIONS } from "../../../../pages/LeaderboardPage/components/Leaderboard/constants/defaults";
import AuthContainer from "../../../../components/shared/AuthContainer";
const WEIGHT_TYPES = [
{ value: "Original", label: "Original" },
{ value: "Delta", label: "Delta" },
{ value: "Adapter", label: "Adapter" },
];
const HELP_TEXTS = {
modelName: (
Model Name on Hugging Face Hub
Your model must be public and loadable with AutoClasses without
trust_remote_code. The model should be in Safetensors format for better
safety and loading performance. Example: braindecode/EEGNetv4
),
revision: (
Model Revision
Git branch, tag or commit hash. The evaluation will be strictly tied to
this specific commit to ensure consistency. Make sure this version is
stable and contains all necessary files.
),
modelType: (
Adapter / Fine-tuning Method
LoRA: Low-Rank Adaptation (~98% param reduction){" "}
IA3: Scaling vectors only (~99.5% reduction){" "}
AdaLoRA: Adaptive rank allocation{" "}
DoRA: Weight-decomposed adaptation{" "}
OFT: Orthogonal fine-tuning{" "}
Probe: Linear probing (head only){" "}
Full Fine-tune: All parameters updated
),
baseModel: (
Base Model Reference
Required for delta weights or adapters. This information is used to
identify the original model and calculate the total parameter count by
combining base model and adapter/delta parameters.
),
precision: (
Model Precision
Size limits vary by precision: FP16/BF16: up to 500M parameters.
8-bit: up to 1B parameters. 4-bit: up to 2B parameters.
Choose carefully as incorrect precision can cause evaluation errors.
),
weightsType: (
Weights Format
Original: Complete model weights in safetensors format Delta: Weight
differences from base model (requires base model for size calculation)
Adapter: Lightweight fine-tuning layers (requires base model for size
calculation)
),
};
// Convert MODEL_TYPES to format expected by Select component
const modelTypeOptions = Object.entries(MODEL_TYPES).map(
([value, { label }]) => ({
value,
label,
})
);
function ModelSubmissionForm({ user, isAuthenticated }) {
const [formData, setFormData] = useState({
modelName: "",
revision: "main",
modelType: "lora",
precision: "float16",
weightsType: "Original",
baseModel: "",
});
const [error, setError] = useState(null);
const [submitting, setSubmitting] = useState(false);
const [success, setSuccess] = useState(false);
const [submittedData, setSubmittedData] = useState(null);
const handleChange = (event) => {
const { name, value, checked } = event.target;
setFormData((prev) => ({
...prev,
[name]: event.target.type === "checkbox" ? checked : value,
}));
};
const handleSubmit = async (e) => {
e.preventDefault();
setError(null);
setSubmitting(true);
try {
const response = await fetch("/api/models/submit", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
model_id: formData.modelName,
revision: formData.revision,
model_type: formData.modelType,
precision: formData.precision,
weight_type: formData.weightsType,
base_model: formData.baseModel,
user_id: user.username,
}),
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.detail || "Failed to submit model");
}
setSubmittedData(formData);
setSuccess(true);
} catch (error) {
setError(error.message);
} finally {
setSubmitting(false);
}
};
if (success && submittedData) {
return (
({
p: 6,
mb: 3,
bgcolor: alpha(theme.palette.success.main, 0.05),
borderColor: alpha(theme.palette.success.main, 0.2),
})}
>
Model submitted successfully!
Your model {submittedData.modelName} has been added
to the evaluation queue with the following parameters:
Model:
{submittedData.modelName}
Type:
{submittedData.modelType}
Revision:
{submittedData.revision}
Precision:
{submittedData.precision}
Weight type:
{submittedData.weightsType}
{submittedData.baseModel && (
Base model:
{submittedData.baseModel}
)}
An automatic upvote has been added to your model to help with
prioritization.
);
}
return (
<>
{error && (
{error}
)}
{isAuthenticated && (
{/* Header */}
theme.palette.mode === "dark"
? alpha(theme.palette.divider, 0.1)
: "grey.200",
bgcolor: (theme) =>
theme.palette.mode === "dark"
? alpha(theme.palette.background.paper, 0.5)
: "grey.50",
}}
>
Model Submission Form
{/* Form Content */}
{/* Model Information */}
Model Information
),
}}
/>
),
}}
/>
{/* Model Configuration */}
Model ConfigurationModel Type
}
>
{modelTypeOptions.map((type) => (
))}
Precision
}
>
{SUBMISSION_PRECISIONS.map((option) => (
))}
Weights Type
}
>
{WEIGHT_TYPES.map((type) => (
))}
{formData.weightsType !== "Original" && (
),
}}
/>
)}
{/* Submit Button */}
All fields marked with * are required
}
sx={{
minWidth: 120,
position: "relative",
}}
>
{submitting ? (
) : (
"Submit"
)}
)}
>
);
}
export default ModelSubmissionForm;