NimaBoscarino's picture
Create app.py
d60ed1f
raw
history blame
6.19 kB
import gradio as gr
import os
hf_writer = gr.HuggingFaceDatasetSaver(
os.getenv('HF_API_TOKEN'),
organization="society-ethics",
dataset_name="featured-spaces-submissions",
private=True
)
principles = [
{
"title": "Consentful",
"content": """
Consentful technology is built with [consent at its core](https://www.consentfultech.io).
For Spaces, some examples of this can include:
- Demonstrating a commitment to acquiring data from willing, informed, and appropriately compensated sources.
- Designing systems that respect end-user autonomy, e.g. with privacy-preserving techniques.
- Avoiding extractive, chauvinist, "dark", and otherwise "unethical" patterns of engagement.
"""
},
{
"title": "Sustainable",
"content": """
These are Spaces that highlight and explore techniques for making machine learning ecologically sustainable.
Examples could include:
- Tracking emissions from training and running inferences on large language models.
- Quantization and distillation methods to reduce carbon footprints without sacrificing model quality.
"""
},
{
"title": "Socially Conscious",
"content": """
"Socially Conscious" Spaces show us how machine learning can be applied as a force for *good*!
This is quite broad, but some examples could be:
- Using machine learning as part of an effort to tackle climate change.
- Building tools to assist with medical research and practice.
- Developing models for text-to-speech, image captioning, and other tasks aimed at increasing accessibility.
- Creating systems for the digital humanities, such as for Indigenous language revitalization.
"""
},
{
"title": "Inclusive",
"content": """
These are projects which broaden the scope of who *builds* and *benefits* in the machine learning world.
This could mean things like:
- Curating diverse datasets that increase the representation of underserved groups.
- Training language models on languages that aren't yet available on the Hugging Face Hub.
- Creating no-code frameworks that allow non-technical folk to engage with AI.
"""
},
{
"title": "Rigorous",
"content": """
Among the many concerns that go into creating new models is a seemingly simple question: "Does it work?"
Rigorous projects pay special attention to examining failure cases, protecting privacy through security
measures, and ensuring that potential users (technical and non-technical) are informed of the project's
limitations.
For example:
- Projects built with models that are well-documented with [Model Cards](https://huggingface.co/docs/hub/model-cards).
- Models that are evaluated against cutting-edge benchmarks, with results reported against disaggregated sets.
- Demonstrations of models failing across ["gender, skin type, ethnicity, age or other attributes"](http://gendershades.org/overview.html).
- Techniques for mitigating issues like over-fitting and training data memorization.
"""
},
{
"title": "Inquisitive",
"content": """
Some projects take a radical new approach to concepts which may have become commonplace. These projects, often
rooted in critical theory, shine a light on inequities and power structures which challenge the community to
rethink its relationship to technology.
For example:
- [Reframing AI and machine learning from Indigenous perspectives](https://jods.mitpress.mit.edu/pub/lewis-arista-pechawis-kite/release/1)
- [Highlighting LGBTQIA2S+ marginalization in AI.](https://edri.org/our-work/computers-are-binary-people-are-not-how-ai-systems-undermine-lgbtq-identity/)
- [Critiquing the harms perpetuated by AI systems.](https://www.ajl.org)
"""
},
]
def toggle_description(title, content):
with gr.Accordion(label=title, open=False):
gr.Markdown(content, elem_id="margin-top")
def submit_entry(URL, tags, suggestions, comments):
hf_writer.flag(
flag_data=[URL, tags, suggestions, comments]
)
return [
gr.Markdown.update(
visible=True,
value="Thank you for your submission! πŸ€—"
),
gr.Button.update(
visible=False
)
]
with gr.Blocks(css="#margin-top {margin-top: 15px}") as demo:
gr.Markdown("## Call for submissions! πŸ“’")
gr.Markdown("""
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 πŸ€—
""")
with gr.Row():
with gr.Column():
gr.Markdown("πŸ’‘ Click on the terms below to view their description and some examples.")
with gr.Column():
[toggle_description(x["title"], x["content"]) for x in principles]
with gr.Column():
URL = gr.Text(label="URL")
tags = gr.Checkboxgroup(
label="Tags - Pick as many as you like!",
choices=[
"Consentful",
"Sustainable",
"Socially Conscious",
"Inclusive",
"Rigorous",
"Critical",
]
)
suggestions = gr.Text(label="[Optional] Do you have suggestions for other tags?")
comments = gr.TextArea(label="[Optional] Any extra comments?")
submit = gr.Button(value="Submit")
thank_you = gr.Markdown(visible=False)
submit.click(
fn=submit_entry,
inputs=[URL, tags, suggestions, comments],
outputs=[thank_you, submit]
)
hf_writer.setup(
components=[URL, tags, suggestions, comments],
flagging_dir="flagged"
)
demo.launch()