import React, { useState, useEffect } from "react"; import { useLocation, useNavigate } from "react-router-dom"; import { Box, Paper, Typography, Button, Stack, Collapse } from "@mui/material"; import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; const DocLink = ({ href, children }) => ( ); const StepNumber = ({ number }) => ( {number} ); const TUTORIAL_STEPS = [ { title: "Model Information", content: ( Your model should be public on the Hub and follow the{" "} username/model-id format (e.g. mistralai/Mistral-7B-v0.1). Specify the revision{" "} (commit hash or branch) and model type. Model uploading guide ), }, { title: "Technical Details", content: ( Make sure your model can be loaded locally before submitting: theme.palette.mode === "dark" ? "grey.50" : "grey.900", borderRadius: 1, "& pre": { m: 0, p: 0, fontFamily: "monospace", fontSize: "0.875rem", color: (theme) => theme.palette.mode === "dark" ? "grey.900" : "grey.50", }, }} >
            {`from transformers import AutoConfig, AutoModel, AutoTokenizer

config = AutoConfig.from_pretrained("your-username/your-model", revision="main")
model = AutoModel.from_pretrained("your-username/your-model", revision="main")
tokenizer = AutoTokenizer.from_pretrained("your-username/your-model", revision="main")`}
          
Transformers documentation
), }, { title: "License Requirements", content: ( A license tag is required.{" "} Open licenses (Apache, MIT, etc) are strongly recommended. About model licenses ), }, { title: "Model Card Requirements", content: ( Your model card must include: architecture,{" "} training details,{" "} dataset information, intended use, limitations, and{" "} performance metrics. Model cards guide ), }, { title: "Final Checklist", content: ( Ensure your model is public, uses{" "} safetensors format, has a{" "} license tag, and loads correctly{" "} with the provided code. Sharing best practices ), }, ]; function SubmissionGuide() { const location = useLocation(); const navigate = useNavigate(); // Initialize state directly with URL value const initialExpanded = !new URLSearchParams(location.search).get("guide"); const [expanded, setExpanded] = useState(initialExpanded); // Sync expanded state with URL changes after initial render useEffect(() => { const guideOpen = !new URLSearchParams(location.search).get("guide"); if (guideOpen !== expanded) { setExpanded(guideOpen); } }, [location.search, expanded]); const handleAccordionChange = () => { const newExpanded = !expanded; setExpanded(newExpanded); const params = new URLSearchParams(location.search); if (newExpanded) { params.delete("guide"); } else { params.set("guide", "closed"); } navigate({ search: params.toString() }, { replace: true }); }; return ( theme.palette.mode === "dark" ? "grey.800" : "grey.200", overflow: "hidden", }} > theme.palette.mode === "dark" ? "grey.900" : "grey.50", borderBottom: "1px solid", borderColor: (theme) => expanded ? theme.palette.mode === "dark" ? "grey.800" : "grey.200" : "transparent", }} > Submission Guide {TUTORIAL_STEPS.map((step, index) => ( {step.title} {step.content} {index < TUTORIAL_STEPS.length - 1 && ( theme.palette.mode === "dark" ? "grey.800" : "grey.100", }} /> )} ))} ); } export default SubmissionGuide;