Spaces:
Runtime error
Runtime error
File size: 20,123 Bytes
736eb2a 2711cd6 5fbbee3 2711cd6 5fbbee3 2711cd6 5fbbee3 2711cd6 5bb95f3 2711cd6 5fbbee3 2711cd6 5bb95f3 736eb2a 5fbbee3 736eb2a 9a4a692 87e696f 9a4a692 87e696f 15af994 2ec74bb 0c7d699 87e696f 9a4a692 15af994 736eb2a 2711cd6 b2d9196 2711cd6 2ec74bb 87e696f 2711cd6 87e696f b2d9196 2711cd6 15af994 87e696f 15af994 0c7d699 b2d9196 87e696f b2d9196 a8356e2 b2d9196 87e696f 736eb2a 6c70e1e 736eb2a a1801f4 736eb2a 5fbbee3 736eb2a ef66fb7 2711cd6 15af994 2711cd6 736eb2a ef66fb7 736eb2a 5fbbee3 2711cd6 5bb95f3 2711cd6 736eb2a e6e82b8 5fbbee3 2711cd6 0c7d699 736eb2a 2711cd6 87e696f 2711cd6 15af994 87e696f 15af994 2ec74bb 0c7d699 15af994 87e696f 2711cd6 87e696f 736eb2a 5c81a32 5bb95f3 5c81a32 736eb2a 5c81a32 5fbbee3 5c81a32 5bb95f3 5c81a32 736eb2a e6e82b8 5fbbee3 5c81a32 2ec74bb 5c81a32 2ec74bb e6e82b8 5c81a32 736eb2a a1801f4 736eb2a 5fbbee3 736eb2a 5fbbee3 2ec74bb 5fbbee3 2ec74bb 736eb2a a1801f4 736eb2a a1801f4 736eb2a 0000bec 736eb2a 0000bec 736eb2a |
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 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
import gradio as gr
from css import custom_css
import pandas as pd
from gradio_modal import Modal
import os
import yaml
import itertools
folder_path = 'configs'
# List to store data from YAML files
data_list = []
metadata_dict = {}
def expand_string_list(string_list):
expanded_list = []
# Add individual strings to the expanded list
expanded_list.extend(string_list)
# Generate combinations of different lengths from the input list
for r in range(2, len(string_list) + 1):
combinations = itertools.combinations(string_list, r)
for combination in combinations:
# Generate permutations of each combination
permutations = itertools.permutations(combination)
for permutation in permutations:
expanded_list.append(' + '.join(permutation))
return expanded_list
# Iterate over each file in the folder
for filename in os.listdir(folder_path):
if filename.endswith('.yaml'):
# Read YAML file
file_path = os.path.join(folder_path, filename)
with open(file_path, 'r') as yamlfile:
yaml_data = yaml.safe_load(yamlfile)
# Append YAML data to list
data_list.append(yaml_data)
metadata_dict['<u>'+yaml_data['Link']+'</u>'] = yaml_data
globaldf = pd.DataFrame(data_list)
globaldf['Link'] = '<u>'+globaldf['Link']+'</u>'
# Define the desired order of categories
modality_order = ["Text", "Image", "Audio", "Video"]
level_order = ["Model", "Dataset", "Output", "Taxonomy"]
modality_order = expand_string_list(modality_order)
level_order = expand_string_list(level_order)
# Convert Modality and Level columns to categorical with specified order
globaldf['Modality'] = pd.Categorical(globaldf['Modality'], categories=modality_order, ordered=True)
globaldf['Level'] = pd.Categorical(globaldf['Level'], categories=level_order, ordered=True)
# Sort DataFrame by Modality and Level
globaldf.sort_values(by=['Modality', 'Level'], inplace=True)
# create a gradio page with tabs and accordions
# Path: taxonomy.py
def filter_modality_level(fulltable, modality_filter, level_filter):
filteredtable = fulltable[fulltable['Modality'].str.contains('|'.join(modality_filter)) & fulltable['Level'].str.contains('|'.join(level_filter))]
return filteredtable
def showmodal(evt: gr.SelectData):
print(evt.value, evt.index, evt.target)
modal = Modal(visible=False)
titlemd = gr.Markdown("",visible=False)
authormd = gr.Markdown("",visible=False)
affiliationmd = gr.Markdown("",visible=False)
tagsmd = gr.Markdown("",visible=False)
abstractmd = gr.Markdown("",visible=False)
whatisbeingmd = gr.Markdown("",visible=False)
methodmd = gr.Markdown("",visible=False)
considerationsmd = gr.Markdown("",visible=False)
modelsmd = gr.Markdown("",visible=False)
datasetmd = gr.Markdown("",visible=False)
metricsmd = gr.Markdown("",visible=False)
gallery = gr.Gallery([],visible=False)
if evt.index[1] == 4:
modal = Modal(visible=True)
itemdic = metadata_dict[evt.value]
tags = itemdic['Hashtags']
if isinstance(tags, list):
if len(tags) > 0:
tagstr = ''.join(['<span class="tag">#'+tag+'</span> ' for tag in tags])
tagsmd = gr.Markdown(tagstr, visible=True)
models = itemdic['Applicable Models']
if isinstance(models, list):
if len(models) > 0:
modelstr = '### Applicable Models: '+''.join(['<span class="tag">'+model+'</span> ' for model in models])
modelsmd = gr.Markdown(modelstr, visible=True)
titlemd = gr.Markdown('# ['+itemdic['Link']+']('+itemdic['URL']+')',visible=True)
if pd.notnull(itemdic['Authors']):
authormd = gr.Markdown('## '+itemdic['Authors'],visible=True)
if pd.notnull(itemdic['Affiliations']):
affiliationmd = gr.Markdown('<strong>Affiliations: </strong>'+ itemdic['Affiliations'],visible=True)
if pd.notnull(itemdic['Abstract']):
abstractmd = gr.Markdown(itemdic['Abstract'],visible=True)
if pd.notnull(itemdic['What it is evaluating']):
whatisbeingmd = gr.Markdown('<strong>Concept being evaluated: </strong>'+ itemdic['What it is evaluating'],visible=True)
if pd.notnull(itemdic['Methodology']):
methodmd = gr.Markdown('<strong>Method of Evaluation: </strong>'+ itemdic['Methodology'],visible=True)
if pd.notnull(itemdic['Considerations']):
considerationsmd = gr.Markdown('<strong>Considerations: </strong>'+ itemdic['Considerations'],visible=True)
if pd.notnull(itemdic['Datasets']):
datasetmd = gr.Markdown('#### [Dataset]('+itemdic['Datasets']+')',visible=True)
metrics = itemdic['Metrics']
if isinstance(metrics, list):
if len(metrics) > 0:
metricstr = '### Metrics: '+''.join(['<span class="tag">'+metric+'</span> ' for metric in metrics])
metricsmd = gr.Markdown(metricstr, visible=True)
screenshots = itemdic['Screenshots']
if isinstance(screenshots, list):
if len(screenshots) > 0:
gallery = gr.Gallery(screenshots, visible=True, height=500, object_fit="scale-down", interactive=False, show_share_button=False)
return [modal, titlemd, authormd, affiliationmd, tagsmd, abstractmd, whatisbeingmd, methodmd, considerationsmd, modelsmd, datasetmd, metricsmd, gallery]
with gr.Blocks(title = "Social Impact Measurement V2", css=custom_css, theme=gr.themes.Base()) as demo: #theme=gr.themes.Soft(),
# create tabs for the app, moving the current table to one titled "rewardbench" and the benchmark_text to a tab called "About"
with gr.Row():
gr.Markdown("""
# Social Impact Measurement
## A taxonomy of the social impacts of AI models and measurement techniques.
""")
with gr.Row():
gr.Markdown("""
#### Technical Base System Evaluations:
Below we list the aspects possible to evaluate in a generative system. Context-absent evaluations only provide narrow insights into the described aspects of the level of generative AI system. The depth of literature and research on evaluations differ by modality with some modalities having sparse or no relevant literature, but the themes for evaluations can be applied to most systems.
The following categories are high-level, non-exhaustive, and present a synthesis of the findings across different modalities. They refer solely to what can be evaluated in a base technical system:
""")
with gr.Tabs(elem_classes="tab-buttons") as tabs1:
with gr.TabItem("Bias/Stereotypes"):
fulltable = globaldf[globaldf['Group'] == 'BiasEvals']
fulltable = fulltable[['Modality','Level', 'Suggested Evaluation', 'What it is evaluating', 'Link']]
gr.Markdown("""
Generative AI systems can perpetuate harmful biases from various sources, including systemic, human, and statistical biases. These biases, also known as "fairness" considerations, can manifest in the final system due to choices made throughout the development process. They include harmful associations and stereotypes related to protected classes, such as race, gender, and sexuality. Evaluating biases involves assessing correlations, co-occurrences, sentiment, and toxicity across different modalities, both within the model itself and in the outputs of downstream tasks.
""")
with gr.Row():
modality_filter = gr.CheckboxGroup(["Text", "Image", "Audio", "Video"],
value=["Text", "Image", "Audio", "Video"],
label="Modality",
show_label=True,
# info="Which modality to show."
)
level_filter = gr.CheckboxGroup(["Model", "Dataset", "Output", "Taxonomy"],
value=["Model", "Dataset", "Output", "Taxonomy"],
label="Level",
show_label=True,
# info="Which modality to show."
)
with gr.Row():
table_full = gr.DataFrame(value=fulltable, wrap=True, datatype="markdown", visible=False, interactive=False)
table_filtered = gr.DataFrame(value=fulltable, wrap=True, datatype="markdown", visible=True, interactive=False)
modality_filter.change(filter_modality_level, inputs=[table_full, modality_filter, level_filter], outputs=table_filtered)
level_filter.change(filter_modality_level, inputs=[table_full, modality_filter, level_filter], outputs=table_filtered)
with Modal(visible=False) as modal:
titlemd = gr.Markdown(visible=False)
authormd = gr.Markdown(visible=False)
affiliationmd = gr.Markdown(visible=False)
tagsmd = gr.Markdown(visible=False)
abstractmd = gr.Markdown(visible=False)
gr.Markdown("""## Construct Validity<br>
### How well it measures the concept it was designed to evaluate""", visible=True)
whatisbeingmd = gr.Markdown(visible=False)
methodmd = gr.Markdown(visible=False)
considerationsmd = gr.Markdown(visible=False)
gr.Markdown("""## Resources<br>
### What you need to do this evaluation""", visible=True)
modelsmd = gr.Markdown(visible=False)
datasetmd = gr.Markdown(visible=False)
gr.Markdown("""## Results<br>
### Available evaluation results""", visible=True)
metricsmd = gr.Markdown(visible=False)
gallery = gr.Gallery(visible=False)
table_filtered.select(showmodal, None, [modal, titlemd, authormd, affiliationmd, tagsmd, abstractmd, whatisbeingmd, methodmd, considerationsmd, modelsmd, datasetmd, metricsmd, gallery])
with gr.TabItem("Cultural Values/Sensitive Content"):
fulltable = globaldf[globaldf['Group'] == 'CulturalEvals']
fulltable = fulltable[['Modality','Level', 'Suggested Evaluation', 'What it is evaluating', 'Considerations', 'Link']]
gr.Markdown("""Cultural values are specific to groups and sensitive content is normative. Sensitive topics also vary by culture and can include hate speech. What is considered a sensitive topic, such as egregious violence or adult sexual content, can vary widely by viewpoint. Due to norms differing by culture, region, and language, there is no standard for what constitutes sensitive content.
Distinct cultural values present a challenge for deploying models into a global sphere, as what may be appropriate in one culture may be unsafe in others. Generative AI systems cannot be neutral or objective, nor can they encompass truly universal values. There is no “view from nowhere”; in quantifying anything, a particular frame of reference is imposed.
""")
with gr.Row():
modality_filter = gr.CheckboxGroup(["Text", "Image", "Audio", "Video"],
value=["Text", "Image", "Audio", "Video"],
label="Modality",
show_label=True,
# info="Which modality to show."
)
level_filter = gr.CheckboxGroup(["Model", "Dataset", "Output", "Taxonomy"],
value=["Model", "Dataset", "Output", "Taxonomy"],
label="Level",
show_label=True,
# info="Which modality to show."
)
with gr.Row():
table_full = gr.DataFrame(value=fulltable, wrap=True, datatype="markdown", visible=False, interactive=False)
table_filtered = gr.DataFrame(value=fulltable, wrap=True, datatype="markdown", visible=True, interactive=False)
modality_filter.change(filter_modality_level, inputs=[table_full, modality_filter, level_filter], outputs=table_filtered)
level_filter.change(filter_modality_level, inputs=[table_full, modality_filter, level_filter], outputs=table_filtered)
with Modal(visible=False) as modal:
titlemd = gr.Markdown(visible=False)
authormd = gr.Markdown(visible=False)
tagsmd = gr.Markdown(visible=False)
abstractmd = gr.Markdown(visible=False)
modelsmd = gr.Markdown(visible=False)
datasetmd = gr.Markdown(visible=False)
gallery = gr.Gallery(visible=False)
table_filtered.select(showmodal, None, [modal, titlemd, authormd, tagsmd, abstractmd, modelsmd, datasetmd, gallery])
# with gr.TabItem("Disparate Performance"):
# with gr.Row():
# gr.Image()
with gr.TabItem("Privacy/Data Protection"):
fulltable = globaldf[globaldf['Group'] == 'PrivacyEvals']
fulltable = fulltable[['Modality','Level', 'Suggested Evaluation', 'What it is evaluating', 'Considerations', 'Link']]
gr.Markdown("""Cultural values are specific to groups and sensitive content is normative. Sensitive topics also vary by culture and can include hate speech. What is considered a sensitive topic, such as egregious violence or adult sexual content, can vary widely by viewpoint. Due to norms differing by culture, region, and language, there is no standard for what constitutes sensitive content.
Distinct cultural values present a challenge for deploying models into a global sphere, as what may be appropriate in one culture may be unsafe in others. Generative AI systems cannot be neutral or objective, nor can they encompass truly universal values. There is no “view from nowhere”; in quantifying anything, a particular frame of reference is imposed.
""")
with gr.Row():
modality_filter = gr.CheckboxGroup(["Text", "Image", "Audio", "Video"],
value=["Text", "Image", "Audio", "Video"],
label="Modality",
show_label=True,
# info="Which modality to show."
)
level_filter = gr.CheckboxGroup(["Model", "Dataset", "Output", "Taxonomy"],
value=["Model", "Dataset", "Output", "Taxonomy"],
label="Level",
show_label=True,
# info="Which modality to show."
)
with gr.Row():
table_full = gr.DataFrame(value=fulltable, wrap=True, datatype="markdown", visible=False, interactive=False)
table_filtered = gr.DataFrame(value=fulltable, wrap=True, datatype="markdown", visible=True, interactive=False)
modality_filter.change(filter_modality_level, inputs=[table_full, modality_filter, level_filter], outputs=table_filtered)
level_filter.change(filter_modality_level, inputs=[table_full, modality_filter, level_filter], outputs=table_filtered)
with Modal(visible=False) as modal:
titlemd = gr.Markdown(visible=False)
authormd = gr.Markdown(visible=False)
tagsmd = gr.Markdown(visible=False)
abstractmd = gr.Markdown(visible=False)
modelsmd = gr.Markdown(visible=False)
datasetmd = gr.Markdown(visible=False)
gallery = gr.Gallery(visible=False)
table_filtered.select(showmodal, None, [modal, titlemd, authormd, tagsmd, abstractmd, modelsmd, datasetmd, gallery])
# with gr.TabItem("Financial Costs"):
# with gr.Row():
# gr.Image()
with gr.TabItem("Environmental Costs"):
with gr.Row():
gr.Image()
# with gr.TabItem("Data and Content Moderation Labor"):
# with gr.Row():
# gr.Image()
# with gr.Row():
# gr.Markdown("""
# #### B: People and Society Impact Evaluations:
# Long-term effects of systems embedded in society, such as economic or labor impact, largely require ideation of generative AI systems’ possible use cases and have fewer available general evaluations. The following categories heavily depend on how generative AI systems are deployed, including sector and application. In the broader ecosystem, methods of deployment affect social impact.
# The following categories are high-level, non-exhaustive, and present a synthesis of the findings across different modalities. They refer solely to what can be evaluated in people and society:
# """)
# with gr.Tabs(elem_classes="tab-buttons") as tabs2:
# with gr.TabItem("Trustworthiness and Autonomy"):
# with gr.Accordion("Trust in Media and Information", open=False):
# gr.Image()
# with gr.Accordion("Overreliance on Outputs", open=False):
# gr.Image()
# with gr.Accordion("Personal Privacy and Sense of Self", open=False):
# gr.Image()
# with gr.TabItem("Inequality, Marginalization, and Violence"):
# with gr.Accordion("Community Erasure", open=False):
# gr.Image()
# with gr.Accordion("Long-term Amplifying Marginalization by Exclusion (and Inclusion)", open=False):
# gr.Image()
# with gr.Accordion("Abusive or Violent Content", open=False):
# gr.Image()
# with gr.TabItem("Concentration of Authority"):
# with gr.Accordion("Militarization, Surveillance, and Weaponization", open=False):
# gr.Image()
# with gr.Accordion("Imposing Norms and Values", open=False):
# gr.Image()
# with gr.TabItem("Labor and Creativity"):
# with gr.Accordion("Intellectual Property and Ownership", open=False):
# gr.Image()
# with gr.Accordion("Economy and Labor Market", open=False):
# gr.Image()
# with gr.TabItem("Ecosystem and Environment"):
# with gr.Accordion("Widening Resource Gaps", open=False):
# gr.Image()
# with gr.Accordion("Environmental Impacts", open=False):
# gr.Image()
with gr.Row():
with gr.Accordion("📚 Citation", open=False):
citation_button = gr.Textbox(
value=r"""BOOK CHAPTER CITE GOES HERE""",
lines=7,
label="Copy the following to cite this work.",
elem_id="citation-button",
show_copy_button=True,
)
demo.launch(debug=True) |