Spaces:
Runtime error
Runtime error
ezi_edits
#1
by
Ezi
- opened
- app.py +13 -59
- mc_template.md +0 -201
app.py
CHANGED
@@ -1,87 +1,41 @@
|
|
1 |
# %%
|
2 |
-
from jinja2 import Environment, FileSystemLoader
|
3 |
import pandas as pd
|
4 |
import gradio as gr
|
5 |
|
6 |
df = pd.read_csv("./data.csv")
|
7 |
|
8 |
|
9 |
-
def parse_into_jinja_markdown(
|
10 |
-
model_name,
|
11 |
-
performance,
|
12 |
-
accuracy,
|
13 |
-
Precision,
|
14 |
-
Recall,
|
15 |
-
Robustness,
|
16 |
-
Fairness,
|
17 |
-
Failure_Clusters,
|
18 |
-
):
|
19 |
-
env = Environment(loader=FileSystemLoader("."), autoescape=True)
|
20 |
-
temp = env.get_template("mc_template.md")
|
21 |
-
return temp.render(
|
22 |
-
model_id=model_name,
|
23 |
-
accuracy=accuracy,
|
24 |
-
Precision=Precision,
|
25 |
-
Recall=Recall,
|
26 |
-
Robustness=Robustness,
|
27 |
-
Fairness=Fairness,
|
28 |
-
Performance=performance,
|
29 |
-
Failure_Cluster=Failure_Clusters,
|
30 |
-
)
|
31 |
-
|
32 |
-
|
33 |
def md_builder(model, dataset, displayed_metrics):
|
34 |
row = df[df["friendly_name"] == model]
|
35 |
-
str =
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
## )
|
40 |
-
|
41 |
-
# init vars to empty string
|
42 |
-
(
|
43 |
-
perform_val,
|
44 |
-
accuracy_val,
|
45 |
-
precision_val,
|
46 |
-
recall_val,
|
47 |
-
robustness_val,
|
48 |
-
fairness_val,
|
49 |
-
fail_cluster,
|
50 |
-
) = ("", "", "", "", "", "", "")
|
51 |
|
52 |
if "Performance" in displayed_metrics:
|
53 |
-
|
54 |
|
55 |
if "Accuracy" in displayed_metrics:
|
56 |
-
|
57 |
|
58 |
if "Precision" in displayed_metrics:
|
59 |
-
|
60 |
|
61 |
if "Recall" in displayed_metrics:
|
62 |
-
|
63 |
|
64 |
if "Robustness" in displayed_metrics:
|
65 |
-
|
66 |
|
67 |
if "Fairness" in displayed_metrics:
|
68 |
-
|
69 |
|
70 |
if "Failure Clusters" in displayed_metrics:
|
71 |
-
cl_count = row[
|
72 |
-
|
73 |
|
74 |
str += "\n<div style='text-align: right'>⛶ Expand safety card</div>"
|
75 |
-
|
76 |
-
model,
|
77 |
-
perform_val,
|
78 |
-
accuracy_val,
|
79 |
-
precision_val,
|
80 |
-
recall_val,
|
81 |
-
robustness_val,
|
82 |
-
fairness_val,
|
83 |
-
fail_cluster,
|
84 |
-
)
|
85 |
return str
|
86 |
|
87 |
|
|
|
1 |
# %%
|
|
|
2 |
import pandas as pd
|
3 |
import gradio as gr
|
4 |
|
5 |
df = pd.read_csv("./data.csv")
|
6 |
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
def md_builder(model, dataset, displayed_metrics):
|
9 |
row = df[df["friendly_name"] == model]
|
10 |
+
str = (
|
11 |
+
f"## <span style='font-size: 16px;'>🚧 Performance and safety of <code style='font-weight: 400'>{model}</code></span>\n"
|
12 |
+
f"On dataset `{dataset}`\n"
|
13 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
if "Performance" in displayed_metrics:
|
16 |
+
str += f"\nPerformance: `{row['performance'].values[0]}`"
|
17 |
|
18 |
if "Accuracy" in displayed_metrics:
|
19 |
+
str += f"\nAccuracy: `{row['accuracy'].values[0]}`"
|
20 |
|
21 |
if "Precision" in displayed_metrics:
|
22 |
+
str += f"\nPrecision: `{row['precision_weighted'].values[0]}`"
|
23 |
|
24 |
if "Recall" in displayed_metrics:
|
25 |
+
str += f"\nRecall: `{row['recall_weighted'].values[0]}`"
|
26 |
|
27 |
if "Robustness" in displayed_metrics:
|
28 |
+
str += f"\nRobustness: `{100-row['robustness'].values[0]}`"
|
29 |
|
30 |
if "Fairness" in displayed_metrics:
|
31 |
+
str += f"\nFairness: `{0}`"
|
32 |
|
33 |
if "Failure Clusters" in displayed_metrics:
|
34 |
+
cl_count = row['cluster_count'].values[0]
|
35 |
+
str += f"\n<details><summary>Top failures: <code>{row['top_failure_cluster'].values[0]}</code> (+{cl_count - 1} others)</summary>(details for all {cl_count} clusters)</details>"
|
36 |
|
37 |
str += "\n<div style='text-align: right'>⛶ Expand safety card</div>"
|
38 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
return str
|
40 |
|
41 |
|
mc_template.md
DELETED
@@ -1,201 +0,0 @@
|
|
1 |
-
|
2 |
-
# Model Card for {{ model_id }}
|
3 |
-
|
4 |
-
<!-- Provide a quick summary of what the model is/does. -->
|
5 |
-
|
6 |
-
This modelcard aims to be a base template for new models. It has been generated using [this raw template](https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/templates/modelcard_template.md?plain=1).
|
7 |
-
|
8 |
-
## Model Details
|
9 |
-
|
10 |
-
### Model Description
|
11 |
-
|
12 |
-
<!-- Provide a longer summary of what this model is. -->
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
- **Developed by:** [More Information Needed]
|
17 |
-
- **Shared by [optional]:** [More Information Needed]
|
18 |
-
- **Model type:** [More Information Needed]
|
19 |
-
- **Language(s) (NLP):** [More Information Needed]
|
20 |
-
- **License:** [More Information Needed]
|
21 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
22 |
-
|
23 |
-
### Model Sources [optional]
|
24 |
-
|
25 |
-
<!-- Provide the basic links for the model. -->
|
26 |
-
|
27 |
-
- **Repository:** [More Information Needed]
|
28 |
-
- **Paper [optional]:** [More Information Needed]
|
29 |
-
- **Demo [optional]:** [More Information Needed]
|
30 |
-
|
31 |
-
## Uses
|
32 |
-
|
33 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
34 |
-
|
35 |
-
### Direct Use
|
36 |
-
|
37 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
38 |
-
|
39 |
-
[More Information Needed]
|
40 |
-
|
41 |
-
### Downstream Use [optional]
|
42 |
-
|
43 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
44 |
-
|
45 |
-
[More Information Needed]
|
46 |
-
|
47 |
-
### Out-of-Scope Use
|
48 |
-
|
49 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
50 |
-
|
51 |
-
{{ Fairness | default("More information needed", true)}}
|
52 |
-
|
53 |
-
## Bias, Risks, and Limitations
|
54 |
-
|
55 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
56 |
-
|
57 |
-
[More Information Needed]
|
58 |
-
|
59 |
-
### Recommendations
|
60 |
-
|
61 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
62 |
-
|
63 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
64 |
-
|
65 |
-
{{Failure_Cluster}}
|
66 |
-
|
67 |
-
## How to Get Started with the Model
|
68 |
-
|
69 |
-
Use the code below to get started with the model.
|
70 |
-
|
71 |
-
[More Information Needed]
|
72 |
-
|
73 |
-
## Training Details
|
74 |
-
|
75 |
-
### Training Data
|
76 |
-
|
77 |
-
<!-- This should link to a Data Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
78 |
-
|
79 |
-
[More Information Needed]
|
80 |
-
|
81 |
-
### Training Procedure
|
82 |
-
|
83 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
84 |
-
|
85 |
-
#### Preprocessing [optional]
|
86 |
-
|
87 |
-
[More Information Needed]
|
88 |
-
|
89 |
-
|
90 |
-
#### Training Hyperparameters
|
91 |
-
|
92 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
93 |
-
|
94 |
-
#### Speeds, Sizes, Times [optional]
|
95 |
-
|
96 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
97 |
-
|
98 |
-
[More Information Needed]
|
99 |
-
|
100 |
-
## Evaluation
|
101 |
-
|
102 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
103 |
-
|
104 |
-
### Testing Data, Factors & Metrics
|
105 |
-
|
106 |
-
#### Testing Data
|
107 |
-
|
108 |
-
<!-- This should link to a Data Card if possible. -->
|
109 |
-
|
110 |
-
[More Information Needed]
|
111 |
-
|
112 |
-
#### Factors
|
113 |
-
|
114 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
115 |
-
|
116 |
-
[More Information Needed]
|
117 |
-
|
118 |
-
#### Metrics
|
119 |
-
|
120 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
121 |
-
|
122 |
-
[More Information Needed]
|
123 |
-
|
124 |
-
### Results
|
125 |
-
|
126 |
-
{{ accuracy | default("More information needed", true)}}
|
127 |
-
{{ Precision}}
|
128 |
-
{{Recall}}
|
129 |
-
{{Performance}}
|
130 |
-
{{Robustness}}
|
131 |
-
|
132 |
-
|
133 |
-
#### Summary
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
## Model Examination [optional]
|
138 |
-
|
139 |
-
<!-- Relevant interpretability work for the model goes here -->
|
140 |
-
|
141 |
-
[More Information Needed]
|
142 |
-
|
143 |
-
## Environmental Impact
|
144 |
-
|
145 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
146 |
-
|
147 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
148 |
-
|
149 |
-
- **Hardware Type:** [More Information Needed]
|
150 |
-
- **Hours used:** [More Information Needed]
|
151 |
-
- **Cloud Provider:** [More Information Needed]
|
152 |
-
- **Compute Region:** [More Information Needed]
|
153 |
-
- **Carbon Emitted:** [More Information Needed]
|
154 |
-
|
155 |
-
## Technical Specifications [optional]
|
156 |
-
|
157 |
-
### Model Architecture and Objective
|
158 |
-
|
159 |
-
[More Information Needed]
|
160 |
-
|
161 |
-
### Compute Infrastructure
|
162 |
-
|
163 |
-
[More Information Needed]
|
164 |
-
|
165 |
-
#### Hardware
|
166 |
-
|
167 |
-
[More Information Needed]
|
168 |
-
|
169 |
-
#### Software
|
170 |
-
|
171 |
-
[More Information Needed]
|
172 |
-
|
173 |
-
## Citation [optional]
|
174 |
-
|
175 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
176 |
-
|
177 |
-
**BibTeX:**
|
178 |
-
|
179 |
-
[More Information Needed]
|
180 |
-
|
181 |
-
**APA:**
|
182 |
-
|
183 |
-
[More Information Needed]
|
184 |
-
|
185 |
-
## Glossary [optional]
|
186 |
-
|
187 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
188 |
-
|
189 |
-
[More Information Needed]
|
190 |
-
|
191 |
-
## More Information [optional]
|
192 |
-
|
193 |
-
[More Information Needed]
|
194 |
-
|
195 |
-
## Model Card Authors [optional]
|
196 |
-
|
197 |
-
[More Information Needed]
|
198 |
-
|
199 |
-
## Model Card Contact
|
200 |
-
|
201 |
-
[More Information Needed]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|