Spaces:
Runtime error
Runtime error
NimaBoscarino
commited on
Commit
β’
d60ed1f
1
Parent(s):
7f6d2e5
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
|
4 |
+
hf_writer = gr.HuggingFaceDatasetSaver(
|
5 |
+
os.getenv('HF_API_TOKEN'),
|
6 |
+
organization="society-ethics",
|
7 |
+
dataset_name="featured-spaces-submissions",
|
8 |
+
private=True
|
9 |
+
)
|
10 |
+
|
11 |
+
principles = [
|
12 |
+
{
|
13 |
+
"title": "Consentful",
|
14 |
+
"content": """
|
15 |
+
Consentful technology is built with [consent at its core](https://www.consentfultech.io).
|
16 |
+
|
17 |
+
For Spaces, some examples of this can include:
|
18 |
+
|
19 |
+
- Demonstrating a commitment to acquiring data from willing, informed, and appropriately compensated sources.
|
20 |
+
- Designing systems that respect end-user autonomy, e.g. with privacy-preserving techniques.
|
21 |
+
- Avoiding extractive, chauvinist, "dark", and otherwise "unethical" patterns of engagement.
|
22 |
+
"""
|
23 |
+
},
|
24 |
+
{
|
25 |
+
"title": "Sustainable",
|
26 |
+
"content": """
|
27 |
+
These are Spaces that highlight and explore techniques for making machine learning ecologically sustainable.
|
28 |
+
|
29 |
+
Examples could include:
|
30 |
+
|
31 |
+
- Tracking emissions from training and running inferences on large language models.
|
32 |
+
- Quantization and distillation methods to reduce carbon footprints without sacrificing model quality.
|
33 |
+
"""
|
34 |
+
},
|
35 |
+
{
|
36 |
+
"title": "Socially Conscious",
|
37 |
+
"content": """
|
38 |
+
"Socially Conscious" Spaces show us how machine learning can be applied as a force for *good*!
|
39 |
+
|
40 |
+
This is quite broad, but some examples could be:
|
41 |
+
|
42 |
+
- Using machine learning as part of an effort to tackle climate change.
|
43 |
+
- Building tools to assist with medical research and practice.
|
44 |
+
- Developing models for text-to-speech, image captioning, and other tasks aimed at increasing accessibility.
|
45 |
+
- Creating systems for the digital humanities, such as for Indigenous language revitalization.
|
46 |
+
"""
|
47 |
+
},
|
48 |
+
{
|
49 |
+
"title": "Inclusive",
|
50 |
+
"content": """
|
51 |
+
These are projects which broaden the scope of who *builds* and *benefits* in the machine learning world.
|
52 |
+
|
53 |
+
This could mean things like:
|
54 |
+
|
55 |
+
- Curating diverse datasets that increase the representation of underserved groups.
|
56 |
+
- Training language models on languages that aren't yet available on the Hugging Face Hub.
|
57 |
+
- Creating no-code frameworks that allow non-technical folk to engage with AI.
|
58 |
+
"""
|
59 |
+
},
|
60 |
+
{
|
61 |
+
"title": "Rigorous",
|
62 |
+
"content": """
|
63 |
+
Among the many concerns that go into creating new models is a seemingly simple question: "Does it work?"
|
64 |
+
|
65 |
+
Rigorous projects pay special attention to examining failure cases, protecting privacy through security
|
66 |
+
measures, and ensuring that potential users (technical and non-technical) are informed of the project's
|
67 |
+
limitations.
|
68 |
+
|
69 |
+
For example:
|
70 |
+
|
71 |
+
- Projects built with models that are well-documented with [Model Cards](https://huggingface.co/docs/hub/model-cards).
|
72 |
+
- Models that are evaluated against cutting-edge benchmarks, with results reported against disaggregated sets.
|
73 |
+
- Demonstrations of models failing across ["gender, skin type, ethnicity, age or other attributes"](http://gendershades.org/overview.html).
|
74 |
+
- Techniques for mitigating issues like over-fitting and training data memorization.
|
75 |
+
"""
|
76 |
+
},
|
77 |
+
{
|
78 |
+
"title": "Inquisitive",
|
79 |
+
"content": """
|
80 |
+
Some projects take a radical new approach to concepts which may have become commonplace. These projects, often
|
81 |
+
rooted in critical theory, shine a light on inequities and power structures which challenge the community to
|
82 |
+
rethink its relationship to technology.
|
83 |
+
|
84 |
+
For example:
|
85 |
+
|
86 |
+
- [Reframing AI and machine learning from Indigenous perspectives](https://jods.mitpress.mit.edu/pub/lewis-arista-pechawis-kite/release/1)
|
87 |
+
- [Highlighting LGBTQIA2S+ marginalization in AI.](https://edri.org/our-work/computers-are-binary-people-are-not-how-ai-systems-undermine-lgbtq-identity/)
|
88 |
+
- [Critiquing the harms perpetuated by AI systems.](https://www.ajl.org)
|
89 |
+
"""
|
90 |
+
},
|
91 |
+
]
|
92 |
+
|
93 |
+
|
94 |
+
def toggle_description(title, content):
|
95 |
+
with gr.Accordion(label=title, open=False):
|
96 |
+
gr.Markdown(content, elem_id="margin-top")
|
97 |
+
|
98 |
+
|
99 |
+
def submit_entry(URL, tags, suggestions, comments):
|
100 |
+
hf_writer.flag(
|
101 |
+
flag_data=[URL, tags, suggestions, comments]
|
102 |
+
)
|
103 |
+
|
104 |
+
return [
|
105 |
+
gr.Markdown.update(
|
106 |
+
visible=True,
|
107 |
+
value="Thank you for your submission! π€"
|
108 |
+
),
|
109 |
+
gr.Button.update(
|
110 |
+
visible=False
|
111 |
+
)
|
112 |
+
]
|
113 |
+
|
114 |
+
|
115 |
+
with gr.Blocks(css="#margin-top {margin-top: 15px}") as demo:
|
116 |
+
gr.Markdown("## Call for submissions! π’")
|
117 |
+
gr.Markdown("""
|
118 |
+
Hugging Face is collecting examples of Spaces that are ethically mindful. What does that mean? There are a lot of ways to define this, so we've suggested a couple categories to get started π€
|
119 |
+
""")
|
120 |
+
|
121 |
+
with gr.Row():
|
122 |
+
with gr.Column():
|
123 |
+
gr.Markdown("π‘ Click on the terms below to view their description and some examples.")
|
124 |
+
with gr.Column():
|
125 |
+
[toggle_description(x["title"], x["content"]) for x in principles]
|
126 |
+
|
127 |
+
with gr.Column():
|
128 |
+
URL = gr.Text(label="URL")
|
129 |
+
tags = gr.Checkboxgroup(
|
130 |
+
label="Tags - Pick as many as you like!",
|
131 |
+
choices=[
|
132 |
+
"Consentful",
|
133 |
+
"Sustainable",
|
134 |
+
"Socially Conscious",
|
135 |
+
"Inclusive",
|
136 |
+
"Rigorous",
|
137 |
+
"Critical",
|
138 |
+
]
|
139 |
+
)
|
140 |
+
suggestions = gr.Text(label="[Optional] Do you have suggestions for other tags?")
|
141 |
+
comments = gr.TextArea(label="[Optional] Any extra comments?")
|
142 |
+
submit = gr.Button(value="Submit")
|
143 |
+
thank_you = gr.Markdown(visible=False)
|
144 |
+
|
145 |
+
submit.click(
|
146 |
+
fn=submit_entry,
|
147 |
+
inputs=[URL, tags, suggestions, comments],
|
148 |
+
outputs=[thank_you, submit]
|
149 |
+
)
|
150 |
+
|
151 |
+
hf_writer.setup(
|
152 |
+
components=[URL, tags, suggestions, comments],
|
153 |
+
flagging_dir="flagged"
|
154 |
+
)
|
155 |
+
|
156 |
+
demo.launch()
|