File size: 8,204 Bytes
e7abd9e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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 }) => (
  <Button
    variant="text"
    size="small"
    href={href}
    target="_blank"
    sx={{
      fontFamily: "monospace",
      textTransform: "none",
      color: "primary.main",
      fontSize: "0.875rem",
      p: 0,
      minWidth: "auto",
      justifyContent: "flex-start",
      "&:hover": {
        color: "primary.dark",
        backgroundColor: "transparent",
        textDecoration: "underline",
      },
    }}
  >
    {children} →
  </Button>
);

const StepNumber = ({ number }) => (
  <Box
    sx={{
      width: 32,
      height: 32,
      borderRadius: "50%",
      display: "flex",
      alignItems: "center",
      justifyContent: "center",
      border: "1px solid",
      borderColor: "primary.main",
      color: "primary.main",
      fontSize: "0.875rem",
      fontWeight: 600,
      flexShrink: 0,
      bgcolor: "transparent",
    }}
  >
    {number}
  </Box>
);

const TUTORIAL_STEPS = [
  {
    title: "Model Information",
    content: (
      <Stack spacing={2}>
        <Typography variant="body2" color="text.secondary">
          Your model should be <strong>public</strong> on the Hub and follow the{" "}
          <strong>username/model-id</strong> format (e.g.
          mistralai/Mistral-7B-v0.1). Specify the <strong>revision</strong>{" "}
          (commit hash or branch) and <strong>model type</strong>.
        </Typography>
        <DocLink href="https://huggingface.co/docs/hub/models-uploading">
          Model uploading guide
        </DocLink>
      </Stack>
    ),
  },
  {
    title: "Technical Details",
    content: (
      <Stack spacing={2}>
        <Typography variant="body2" color="text.secondary">
          Make sure your model can be <strong>loaded locally</strong> before
          submitting:
        </Typography>
        <Box
          sx={{
            p: 2,
            bgcolor: (theme) =>
              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",
            },
          }}
        >
          <pre>
            {`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")`}
          </pre>
        </Box>
        <DocLink href="https://huggingface.co/docs/transformers/installation">
          Transformers documentation
        </DocLink>
      </Stack>
    ),
  },
  {
    title: "License Requirements",
    content: (
      <Stack spacing={2}>
        <Typography variant="body2" color="text.secondary">
          A <strong>license tag</strong> is required.{" "}
          <strong>Open licenses</strong> (Apache, MIT, etc) are strongly
          recommended.
        </Typography>
        <DocLink href="https://huggingface.co/docs/hub/repositories-licenses">
          About model licenses
        </DocLink>
      </Stack>
    ),
  },
  {
    title: "Model Card Requirements",
    content: (
      <Stack spacing={2}>
        <Typography variant="body2" color="text.secondary">
          Your model card must include: <strong>architecture</strong>,{" "}
          <strong>training details</strong>,{" "}
          <strong>dataset information</strong>, intended use, limitations, and{" "}
          <strong>performance metrics</strong>.
        </Typography>
        <DocLink href="https://huggingface.co/docs/hub/model-cards">
          Model cards guide
        </DocLink>
      </Stack>
    ),
  },
  {
    title: "Final Checklist",
    content: (
      <Stack spacing={2}>
        <Typography variant="body2" color="text.secondary">
          Ensure your model is <strong>public</strong>, uses{" "}
          <strong>safetensors</strong> format, has a{" "}
          <strong>license tag</strong>, and <strong>loads correctly</strong>{" "}
          with the provided code.
        </Typography>
        <DocLink href="https://huggingface.co/docs/hub/repositories-getting-started">
          Sharing best practices
        </DocLink>
      </Stack>
    ),
  },
];

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 (
    <Paper
      elevation={0}
      sx={{
        mb: 3,
        borderRadius: "8px !important",
        border: "1px solid",
        borderColor: (theme) =>
          theme.palette.mode === "dark" ? "grey.800" : "grey.200",
        overflow: "hidden",
      }}
    >
      <Box
        onClick={handleAccordionChange}
        sx={{
          p: 2,
          display: "flex",
          alignItems: "center",
          justifyContent: "space-between",
          cursor: "pointer",
          bgcolor: (theme) =>
            theme.palette.mode === "dark" ? "grey.900" : "grey.50",
          borderBottom: "1px solid",
          borderColor: (theme) =>
            expanded
              ? theme.palette.mode === "dark"
                ? "grey.800"
                : "grey.200"
              : "transparent",
        }}
      >
        <Typography
          variant="h6"
          sx={{ fontWeight: 600, color: "text.primary" }}
        >
          Submission Guide
        </Typography>
        <ExpandMoreIcon
          sx={{
            transform: expanded ? "rotate(180deg)" : "rotate(0deg)",
            transition: "transform 0.3s",
          }}
        />
      </Box>
      <Collapse in={expanded} appear={false}>
        <Box sx={{ py: 4 }}>
          <Stack spacing={4}>
            {TUTORIAL_STEPS.map((step, index) => (
              <Box key={step.title}>
                <Stack spacing={3}>
                  <Stack
                    direction="row"
                    spacing={2}
                    alignItems="center"
                    sx={{ px: 4 }}
                  >
                    <StepNumber number={index + 1} />
                    <Typography
                      variant="subtitle1"
                      sx={{
                        fontWeight: 600,
                        color: "text.primary",
                        letterSpacing: "-0.01em",
                      }}
                    >
                      {step.title}
                    </Typography>
                  </Stack>
                  <Box sx={{ px: 4, pl: 7 }}>{step.content}</Box>
                </Stack>
                {index < TUTORIAL_STEPS.length - 1 && (
                  <Box
                    sx={{
                      mt: 4,
                      borderTop: "1px solid",
                      borderColor: (theme) =>
                        theme.palette.mode === "dark" ? "grey.800" : "grey.100",
                    }}
                  />
                )}
              </Box>
            ))}
          </Stack>
        </Box>
      </Collapse>
    </Paper>
  );
}

export default SubmissionGuide;