Anonymous Authors commited on
Commit
6257003
β€’
1 Parent(s): b64b066

Upload 10 files

Browse files
README.md CHANGED
@@ -1,13 +1,12 @@
1
  ---
2
- title: Diffusion Clustering
3
- emoji: πŸš€
4
- colorFrom: purple
5
- colorTo: gray
6
  sdk: gradio
7
- sdk_version: 3.40.1
8
  app_file: app.py
9
  pinned: false
10
- license: openrail
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: DiffusionClustering
3
+ emoji: πŸ“Š
4
+ colorFrom: blue
5
+ colorTo: green
6
  sdk: gradio
7
+ sdk_version: 3.18.0
8
  app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,397 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import json
3
+ import numpy as np
4
+ import pandas as pd
5
+ from datasets import load_from_disk
6
+ from itertools import chain
7
+ import operator
8
+
9
+ pd.options.plotting.backend = "plotly"
10
+
11
+
12
+ TITLE = "Identity Biases in Diffusion Models: Professions"
13
+
14
+ _INTRO = """
15
+ # Identity Biases in Diffusion Models: Professions
16
+
17
+ Explore profession-level social biases in the data from [DiffusionBiasExplorer](https://hf.co/spaces/tti-bias/DiffusionBiasExplorer)!
18
+ This demo leverages the gender and ethnicity representation clusters described in the [companion app](https://hf.co/spaces/tti-bias/DiffusionFaceClustering)
19
+ to analyze social trends in machine-generated visual representations of professions.
20
+ The **Professions Overview** tab lets you compare the distribution over
21
+ [identity clusters](https://hf.co/spaces/tti-bias/DiffusionFaceClustering "Identity clusters identify visual features in the systems' output space correlated with variation of gender and ethnicity in input prompts.")
22
+ across professions for Stable Diffusion and Dalle-2 systems (or aggregated for `All Models`).
23
+ The **Professions Focus** tab provides more details for each of the individual professions, including direct system comparisons and examples of profession images for each cluster.
24
+ This work was done in the scope of the [Stable Bias Project](https://hf.co/spaces/tti-bias/StableBias).
25
+ As you use this demo, please share findings and comments [in the discussions tab](https://hf.co/spaces/tti-bias/DiffusionClustering/discussions)!
26
+ """
27
+
28
+ _ = """
29
+ For example, you can use this tool to investigate:
30
+ - How do each model's representation of professions correlate with the gender ratios reported by the [U.S. Bureau of Labor
31
+ Statistics](https://www.bls.gov/cps/cpsaat11.htm "The reported percentage of women in each profession in the US is indicated in the `Labor Women` column in the Professions Overview tab.")?
32
+ Are social trends reflected, are they exaggerated?
33
+ - Which professions have the starkest differences in how different models represent them?
34
+ """
35
+
36
+ professions_dset = load_from_disk("professions")
37
+ professions_df = professions_dset.to_pandas()
38
+
39
+
40
+ clusters_dicts = dict(
41
+ (num_cl, json.load(open(f"clusters/professions_to_clusters_{num_cl}.json")))
42
+ for num_cl in [12, 24, 48]
43
+ )
44
+
45
+ cluster_summaries_by_size = json.load(open("clusters/cluster_summaries_by_size.json"))
46
+
47
+ prompts = pd.read_csv("promptsadjectives.csv")
48
+ professions = ["all professions"] + list(
49
+ # sorted([p.lower() for p in prompts["Occupation-Noun"].tolist()])
50
+ sorted([p for p in prompts["Occupation-Noun"].tolist()])
51
+ )
52
+ models = {
53
+ "All": "All Models",
54
+ "SD_14": "Stable Diffusion 1.4",
55
+ "SD_2": "Stable Diffusion 2",
56
+ "DallE": "Dall-E 2",
57
+ }
58
+
59
+ df_models = {
60
+ "All Models": "All",
61
+ "Stable Diffusion 1.4": "SD_14",
62
+ "Stable Diffusion 2": "SD_2",
63
+ "Dall-E 2": "DallE",
64
+ }
65
+
66
+
67
+ def describe_cluster(num_clusters, block="label"):
68
+ cl_dict = clusters_dicts[num_clusters]
69
+ labels_values = sorted(cl_dict.items(), key=operator.itemgetter(1))
70
+ labels_values.reverse()
71
+ total = float(sum(cl_dict.values()))
72
+ lv_prcnt = list(
73
+ (item[0], round(item[1] * 100 / total, 0)) for item in labels_values
74
+ )
75
+ top_label = lv_prcnt[0][0]
76
+ description_string = (
77
+ "<span>The most represented %s is <b>%s</b>, making up about <b>%d%%</b> of the cluster.</span>"
78
+ % (to_string(block), to_string(top_label), lv_prcnt[0][1])
79
+ )
80
+ description_string += "<p>This is followed by: "
81
+ for lv in lv_prcnt[1:]:
82
+ description_string += "<BR/><b>%s:</b> %d%%" % (to_string(lv[0]), lv[1])
83
+ description_string += "</p>"
84
+ return description_string
85
+
86
+
87
+ def make_profession_plot(num_clusters, prof_name):
88
+ sorted_cl_scores = [
89
+ (k, v)
90
+ for k, v in sorted(
91
+ clusters_dicts[num_clusters]["All"][prof_name][
92
+ "cluster_proportions"
93
+ ].items(),
94
+ key=lambda x: x[1],
95
+ reverse=True,
96
+ )
97
+ if v > 0
98
+ ]
99
+ pre_pandas = dict(
100
+ [
101
+ (
102
+ models[mod_name],
103
+ dict(
104
+ (
105
+ f"Cluster {k}",
106
+ clusters_dicts[num_clusters][mod_name][prof_name][
107
+ "cluster_proportions"
108
+ ][k],
109
+ )
110
+ for k, _ in sorted_cl_scores
111
+ ),
112
+ )
113
+ for mod_name in models
114
+ ]
115
+ )
116
+ df = pd.DataFrame.from_dict(pre_pandas)
117
+ prof_plot = df.plot(kind="bar", barmode="group")
118
+ cl_summary_text = f"Profession '{prof_name}':\n"
119
+ for cl_id, _ in sorted_cl_scores:
120
+ cl_summary_text += f"- {cluster_summaries_by_size[str(num_clusters)][int(cl_id)].replace(' gender terms', '').replace('; ethnicity terms:', ',')} \n"
121
+ return (
122
+ prof_plot,
123
+ gr.update(
124
+ choices=[k for k, _ in sorted_cl_scores], value=sorted_cl_scores[0][0]
125
+ ),
126
+ gr.update(value=cl_summary_text),
127
+ )
128
+
129
+
130
+ def make_profession_table(num_clusters, prof_names, mod_name, max_cols=8):
131
+ professions_list_clusters = [
132
+ (
133
+ prof_name,
134
+ clusters_dicts[num_clusters][df_models[mod_name]][prof_name][
135
+ "cluster_proportions"
136
+ ],
137
+ )
138
+ for prof_name in prof_names
139
+ ]
140
+ totals = sorted(
141
+ [
142
+ (
143
+ k,
144
+ sum(
145
+ prof_clusters[str(k)]
146
+ for _, prof_clusters in professions_list_clusters
147
+ ),
148
+ )
149
+ for k in range(num_clusters)
150
+ ],
151
+ key=lambda x: x[1],
152
+ reverse=True,
153
+ )[:max_cols]
154
+ prof_list_pre_pandas = [
155
+ dict(
156
+ [
157
+ ("Profession", prof_name),
158
+ (
159
+ "Entropy",
160
+ clusters_dicts[num_clusters][df_models[mod_name]][prof_name][
161
+ "entropy"
162
+ ],
163
+ ),
164
+ (
165
+ "Labor Women",
166
+ clusters_dicts[num_clusters][df_models[mod_name]][prof_name][
167
+ "labor_fm"
168
+ ][0],
169
+ ),
170
+ ("", ""),
171
+ ]
172
+ + [(f"Cluster {k}", prof_clusters[str(k)]) for k, v in totals if v > 0]
173
+ )
174
+ for prof_name, prof_clusters in professions_list_clusters
175
+ ]
176
+ clusters_df = pd.DataFrame.from_dict(prof_list_pre_pandas)
177
+ cl_summary_text = ""
178
+ for cl_id, _ in totals[:max_cols]:
179
+ cl_summary_text += f"- {cluster_summaries_by_size[str(num_clusters)][cl_id].replace(' gender terms', '').replace('; ethnicity terms:', ',')} \n"
180
+ return (
181
+ [c[0] for c in totals],
182
+ (
183
+ clusters_df.style.background_gradient(
184
+ axis=None, vmin=0, vmax=100, cmap="YlGnBu"
185
+ )
186
+ .format(precision=1)
187
+ .to_html()
188
+ ),
189
+ gr.update(value=cl_summary_text),
190
+ )
191
+
192
+
193
+ def get_image(model, fname, score):
194
+ return (
195
+ professions_dset.select(
196
+ professions_df[
197
+ (professions_df["image_path"] == fname)
198
+ & (professions_df["model"] == model)
199
+ ].index
200
+ )["image"][0],
201
+ " ".join(fname.split("/")[0].split("_")[4:])
202
+ + f" | {score:.2f}"
203
+ + f" | {models[model]}",
204
+ )
205
+
206
+
207
+ def show_examplars(num_clusters, prof_name, cl_id, confidence_threshold=0.6):
208
+ # only show images where the similarity to the centroid is > confidence_threshold
209
+ examplars_dict = clusters_dicts[num_clusters]["All"][prof_name][
210
+ "cluster_examplars"
211
+ ][str(cl_id)]
212
+ l = [
213
+ tuple(img)
214
+ for img in examplars_dict["close"]
215
+ + examplars_dict["mid"][:2]
216
+ + examplars_dict["far"]
217
+ ]
218
+ l = [
219
+ img
220
+ for i, img in enumerate(l)
221
+ if img[0] > confidence_threshold and img not in l[:i]
222
+ ]
223
+ return (
224
+ [get_image(model, fname, score) for score, model, fname in l],
225
+ gr.update(
226
+ label=f"Generations for profession ''{prof_name}'' assigned to cluster {cl_id} of {num_clusters}"
227
+ ),
228
+ )
229
+
230
+
231
+ with gr.Blocks(title=TITLE) as demo:
232
+ gr.Markdown(_INTRO)
233
+ gr.HTML(
234
+ """<span style="color:red" font-size:smaller>⚠️ DISCLAIMER: the images displayed by this tool were generated by text-to-image systems and may depict offensive stereotypes or contain explicit content.</span>"""
235
+ )
236
+ with gr.Tab("Professions Overview"):
237
+ gr.Markdown(
238
+ """
239
+ Select one or more professions and models from the dropdowns on the left to see which clusters are most representative for this combination.
240
+ Try choosing different numbers of clusters to see if the results change, and then go to the 'Profession Focus' tab to go more in-depth into these results.
241
+ The `Labor Women` column provided for comparison corresponds to the gender ratio reported by the
242
+ [U.S. Bureau of Labor Statistics](https://www.bls.gov/cps/cpsaat11.htm) for each profession.
243
+ """
244
+ )
245
+ with gr.Row():
246
+ with gr.Column(scale=1):
247
+ gr.Markdown("Select the parameters here:")
248
+ num_clusters = gr.Radio(
249
+ [12, 24, 48],
250
+ value=12,
251
+ label="How many clusters do you want to use to represent identities?",
252
+ )
253
+ model_choices = gr.Dropdown(
254
+ [
255
+ "All Models",
256
+ "Stable Diffusion 1.4",
257
+ "Stable Diffusion 2",
258
+ "Dall-E 2",
259
+ ],
260
+ value="All Models",
261
+ label="Which models do you want to compare?",
262
+ interactive=True,
263
+ )
264
+ profession_choices_overview = gr.Dropdown(
265
+ professions,
266
+ value=[
267
+ "all professions",
268
+ "CEO",
269
+ "director",
270
+ "social assistant",
271
+ "social worker",
272
+ ],
273
+ label="Which professions do you want to compare?",
274
+ multiselect=True,
275
+ interactive=True,
276
+ )
277
+ with gr.Column(scale=3):
278
+ with gr.Row():
279
+ table = gr.HTML(
280
+ label="Profession assignment per cluster", wrap=True
281
+ )
282
+ with gr.Row():
283
+ # clusters = gr.Dataframe(type="array", visible=False, col_count=1)
284
+ clusters = gr.Textbox(label="clusters", visible=False)
285
+ gr.Markdown(
286
+ """
287
+ ##### What do the clusters mean?
288
+ Below is a summary of the identity cluster compositions.
289
+ For more details, see the [companion demo](https://huggingface.co/spaces/tti-bias/DiffusionFaceClustering):
290
+ """
291
+ )
292
+ with gr.Row():
293
+ with gr.Accordion(label="Cluster summaries", open=True):
294
+ cluster_descriptions_table = gr.Text(
295
+ "TODO", label="Cluster summaries", show_label=False
296
+ )
297
+ with gr.Tab("Profession Focus"):
298
+ with gr.Row():
299
+ with gr.Column():
300
+ gr.Markdown(
301
+ "Select a profession to visualize and see which clusters and identity groups are most represented in the profession, as well as some examples of generated images below."
302
+ )
303
+ profession_choice_focus = gr.Dropdown(
304
+ choices=professions,
305
+ value="scientist",
306
+ label="Select profession:",
307
+ )
308
+ num_clusters_focus = gr.Radio(
309
+ [12, 24, 48],
310
+ value=12,
311
+ label="How many clusters do you want to use to represent identities?",
312
+ )
313
+ with gr.Column():
314
+ plot = gr.Plot(
315
+ label=f"Makeup of the cluster assignments for profession {profession_choice_focus}"
316
+ )
317
+ with gr.Row():
318
+ with gr.Column():
319
+ gr.Markdown(
320
+ """
321
+ ##### What do the clusters mean?
322
+ Below is a summary of the identity cluster compositions.
323
+ For more details, see the [companion demo](https://huggingface.co/spaces/tti-bias/DiffusionFaceClustering):
324
+ """
325
+ )
326
+ with gr.Accordion(label="Cluster summaries", open=True):
327
+ cluster_descriptions = gr.Text(
328
+ "TODO", label="Cluster summaries", show_label=False
329
+ )
330
+ with gr.Column():
331
+ gr.Markdown(
332
+ """
333
+ ##### What's in the clusters?
334
+ You can show examples of profession images assigned to each identity cluster by selecting one here:
335
+ """
336
+ )
337
+ with gr.Accordion(label="Cluster selection", open=True):
338
+ cluster_id_focus = gr.Dropdown(
339
+ choices=[i for i in range(num_clusters_focus.value)],
340
+ value=0,
341
+ label="Select cluster to visualize:",
342
+ )
343
+ with gr.Row():
344
+ examplars_plot = gr.Gallery(
345
+ label="Profession images assigned to the selected cluster."
346
+ ).style(grid=4, height="auto", container=True)
347
+ demo.load(
348
+ make_profession_table,
349
+ [num_clusters, profession_choices_overview, model_choices],
350
+ [clusters, table, cluster_descriptions_table],
351
+ queue=False,
352
+ )
353
+ demo.load(
354
+ make_profession_plot,
355
+ [num_clusters_focus, profession_choice_focus],
356
+ [plot, cluster_id_focus, cluster_descriptions],
357
+ queue=False,
358
+ )
359
+ demo.load(
360
+ show_examplars,
361
+ [
362
+ num_clusters_focus,
363
+ profession_choice_focus,
364
+ cluster_id_focus,
365
+ ],
366
+ [examplars_plot, examplars_plot],
367
+ queue=False,
368
+ )
369
+ for var in [num_clusters, model_choices, profession_choices_overview]:
370
+ var.change(
371
+ make_profession_table,
372
+ [num_clusters, profession_choices_overview, model_choices],
373
+ [clusters, table, cluster_descriptions_table],
374
+ queue=False,
375
+ )
376
+ for var in [num_clusters_focus, profession_choice_focus]:
377
+ var.change(
378
+ make_profession_plot,
379
+ [num_clusters_focus, profession_choice_focus],
380
+ [plot, cluster_id_focus, cluster_descriptions],
381
+ queue=False,
382
+ )
383
+ for var in [num_clusters_focus, profession_choice_focus, cluster_id_focus]:
384
+ var.change(
385
+ show_examplars,
386
+ [
387
+ num_clusters_focus,
388
+ profession_choice_focus,
389
+ cluster_id_focus,
390
+ ],
391
+ [examplars_plot, examplars_plot],
392
+ queue=False,
393
+ )
394
+
395
+
396
+ if __name__ == "__main__":
397
+ demo.queue().launch(debug=True)
clusters/cluster_summaries_by_size.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"12": ["Cluster 0: 219 items. Most frequent gender terms: woman (122), non-binary (74); ethnicity terms: South Asian (51), East Asian (42).", "Cluster 1: 215 items. Most frequent gender terms: man (67), unmarked (65); ethnicity terms: Native American (68), American Indian (66).", "Cluster 2: 204 items. Most frequent gender terms: woman (166), unmarked (24); ethnicity terms: Latinx (39), Caucasian (30).", "Cluster 3: 202 items. Most frequent gender terms: man (103), unmarked (92); ethnicity terms: South Asian (61), Hispanic (41).", "Cluster 4: 178 items. Most frequent gender terms: man (99), unmarked (75); ethnicity terms: White (52), unmarked (51).", "Cluster 5: 177 items. Most frequent gender terms: non-binary (160), woman (17); ethnicity terms: White (28), Caucasian (26).", "Cluster 6: 161 items. Most frequent gender terms: woman (85), non-binary (46); ethnicity terms: African-American (53), Black (50).", "Cluster 7: 156 items. Most frequent gender terms: man (66), unmarked (51); ethnicity terms: Pacific Islander (25), Southeast Asian (21).", "Cluster 8: 154 items. Most frequent gender terms: man (83), unmarked (66); ethnicity terms: African-American (55), Black (53).", "Cluster 9: 121 items. Most frequent gender terms: woman (52), unmarked (36); ethnicity terms: Indigenous American (39), First Nations (37).", "Cluster 10: 121 items. Most frequent gender terms: man (59), unmarked (42); ethnicity terms: East Asian (59), Southeast Asian (45).", "Cluster 11: 102 items. Most frequent gender terms: non-binary (69), woman (27); ethnicity terms: First Nations (21), Latinx (15)."], "24": ["Cluster 0: 161 items. Most frequent gender terms: woman (85), non-binary (46); ethnicity terms: African-American (53), Black (50).", "Cluster 1: 152 items. Most frequent gender terms: non-binary (71), woman (69); ethnicity terms: South Asian (51), Pacific Islander (19).", "Cluster 2: 139 items. Most frequent gender terms: woman (111), unmarked (20); ethnicity terms: Latinx (34), Hispanic (27).", "Cluster 3: 135 items. Most frequent gender terms: man (46), unmarked (44); ethnicity terms: Native American (50), American Indian (42).", "Cluster 4: 125 items. Most frequent gender terms: man (74), unmarked (47); ethnicity terms: South Asian (61), Latino (24).", "Cluster 5: 117 items. Most frequent gender terms: man (70), unmarked (44); ethnicity terms: White (34), unmarked (31).", "Cluster 6: 91 items. Most frequent gender terms: man (55), unmarked (33); ethnicity terms: African-American (44), Black (31).", "Cluster 7: 84 items. Most frequent gender terms: man (39), non-binary (29); ethnicity terms: Pacific Islander (16), Indigenous American (14).", "Cluster 8: 80 items. Most frequent gender terms: non-binary (24), unmarked (21); ethnicity terms: American Indian (24), Indigenous American (21).", "Cluster 9: 77 items. Most frequent gender terms: unmarked (45), man (29); ethnicity terms: Hispanic (25), Pacific Islander (13).", "Cluster 10: 76 items. Most frequent gender terms: woman (52), unmarked (19); ethnicity terms: Indigenous American (23), First Nations (20).", "Cluster 11: 72 items. Most frequent gender terms: unmarked (35), man (27); ethnicity terms: Southeast Asian (19), Latino (11).", "Cluster 12: 68 items. Most frequent gender terms: non-binary (58), woman (10); ethnicity terms: White (25), Caucasian (23).", "Cluster 13: 68 items. Most frequent gender terms: non-binary (62), woman (6); ethnicity terms: Black (14), Multiracial (13).", "Cluster 14: 67 items. Most frequent gender terms: woman (53), unmarked (11); ethnicity terms: East Asian (42), Southeast Asian (21).", "Cluster 15: 65 items. Most frequent gender terms: woman (55), non-binary (6); ethnicity terms: White (19), Caucasian (16).", "Cluster 16: 63 items. Most frequent gender terms: unmarked (33), man (28); ethnicity terms: Black (22), Multiracial (20).", "Cluster 17: 63 items. Most frequent gender terms: man (29), unmarked (18); ethnicity terms: East Asian (58), Southeast Asian (3).", "Cluster 18: 61 items. Most frequent gender terms: non-binary (53), woman (8); ethnicity terms: Latinx (15), Latino (10).", "Cluster 19: 61 items. Most frequent gender terms: unmarked (31), man (29); ethnicity terms: Caucasian (22), unmarked (20).", "Cluster 20: 58 items. Most frequent gender terms: man (30), unmarked (24); ethnicity terms: Southeast Asian (42), Pacific Islander (15).", "Cluster 21: 45 items. Most frequent gender terms: man (28), unmarked (17); ethnicity terms: First Nations (17), Indigenous American (16).", "Cluster 22: 41 items. Most frequent gender terms: non-binary (40), woman (1); ethnicity terms: East Asian (11), Southeast Asian (7).", "Cluster 23: 41 items. Most frequent gender terms: woman (19), non-binary (16); ethnicity terms: First Nations (12), Pacific Islander (10)."], "48": ["Cluster 0: 110 items. Most frequent gender terms: woman (57), non-binary (28); ethnicity terms: Multiracial (35), Black (32).", "Cluster 1: 80 items. Most frequent gender terms: unmarked (39), man (35); ethnicity terms: Multiracial (29), Black (22).", "Cluster 2: 73 items. Most frequent gender terms: man (35), unmarked (34); ethnicity terms: South Asian (60), Hispanic (6).", "Cluster 3: 72 items. Most frequent gender terms: unmarked (29), man (23); ethnicity terms: American Indian (27), Native American (26).", "Cluster 4: 71 items. Most frequent gender terms: man (39), unmarked (30); ethnicity terms: White (23), unmarked (23).", "Cluster 5: 67 items. Most frequent gender terms: non-binary (64), woman (2); ethnicity terms: East Asian (13), Latino (8).", "Cluster 6: 64 items. Most frequent gender terms: man (27), unmarked (19); ethnicity terms: East Asian (55), Southeast Asian (5).", "Cluster 7: 62 items. Most frequent gender terms: unmarked (31), man (30); ethnicity terms: Caucasian (23), unmarked (20).", "Cluster 8: 54 items. Most frequent gender terms: unmarked (30), man (22); ethnicity terms: Hispanic (17), Caucasian (12).", "Cluster 9: 54 items. Most frequent gender terms: woman (40), unmarked (9); ethnicity terms: East Asian (30), Southeast Asian (20).", "Cluster 10: 54 items. Most frequent gender terms: unmarked (30), man (19); ethnicity terms: Pacific Islander (19), Southeast Asian (13).", "Cluster 11: 51 items. Most frequent gender terms: non-binary (43), woman (8); ethnicity terms: White (25), Caucasian (22).", "Cluster 12: 50 items. Most frequent gender terms: unmarked (28), man (22); ethnicity terms: Southeast Asian (15), Latino (9).", "Cluster 13: 49 items. Most frequent gender terms: woman (32), unmarked (13); ethnicity terms: Latinx (19), Hispanic (13).", "Cluster 14: 46 items. Most frequent gender terms: non-binary (28), woman (16); ethnicity terms: South Asian (13), Pacific Islander (9).", "Cluster 15: 45 items. Most frequent gender terms: woman (36), unmarked (9); ethnicity terms: Indigenous American (18), First Nations (13).", "Cluster 16: 44 items. Most frequent gender terms: woman (37), unmarked (7); ethnicity terms: Latinx (8), Multiracial (8).", "Cluster 17: 43 items. Most frequent gender terms: man (24), unmarked (18); ethnicity terms: Latinx (21), Latino (11).", "Cluster 18: 43 items. Most frequent gender terms: man (27), unmarked (16); ethnicity terms: Indigenous American (16), First Nations (15).", "Cluster 19: 40 items. Most frequent gender terms: man (29), unmarked (11); ethnicity terms: African-American (20), Black (12).", "Cluster 20: 40 items. Most frequent gender terms: non-binary (39), woman (1); ethnicity terms: Latinx (14), Latino (7).", "Cluster 21: 39 items. Most frequent gender terms: man (23), unmarked (16); ethnicity terms: Southeast Asian (31), Pacific Islander (8).", "Cluster 22: 39 items. Most frequent gender terms: non-binary (27), man (8); ethnicity terms: American Indian (11), Indigenous American (8).", "Cluster 23: 37 items. Most frequent gender terms: woman (21), non-binary (16); ethnicity terms: Black (18), African-American (13).", "Cluster 24: 36 items. Most frequent gender terms: non-binary (32), woman (4); ethnicity terms: Hispanic (6), Multiracial (6).", "Cluster 25: 35 items. Most frequent gender terms: woman (17), unmarked (12); ethnicity terms: Native American (13), American Indian (8).", "Cluster 26: 35 items. Most frequent gender terms: man (27), unmarked (8); ethnicity terms: unmarked (8), Latino (7).", "Cluster 27: 34 items. Most frequent gender terms: non-binary (23), woman (8); ethnicity terms: African-American (15), Black (14).", "Cluster 28: 34 items. Most frequent gender terms: woman (20), non-binary (13); ethnicity terms: South Asian (34).", "Cluster 29: 34 items. Most frequent gender terms: woman (30), non-binary (2); ethnicity terms: White (15), Caucasian (11).", "Cluster 30: 34 items. Most frequent gender terms: man (19), unmarked (14); ethnicity terms: Black (18), African-American (15).", "Cluster 31: 34 items. Most frequent gender terms: non-binary (18), woman (14); ethnicity terms: Southeast Asian (14), Pacific Islander (10).", "Cluster 32: 32 items. Most frequent gender terms: non-binary (21), woman (10); ethnicity terms: Indigenous American (10), Native American (10).", "Cluster 33: 30 items. Most frequent gender terms: woman (29), unmarked (1); ethnicity terms: Hispanic (9), Latinx (7).", "Cluster 34: 29 items. Most frequent gender terms: man (18), unmarked (9); ethnicity terms: First Nations (10), Pacific Islander (9).", "Cluster 35: 27 items. Most frequent gender terms: unmarked (15), man (11); ethnicity terms: American Indian (10), Native American (6).", "Cluster 36: 27 items. Most frequent gender terms: woman (13), non-binary (11); ethnicity terms: First Nations (13), Latino (4).", "Cluster 37: 26 items. Most frequent gender terms: man (15), unmarked (11); ethnicity terms: Native American (9), American Indian (8).", "Cluster 38: 26 items. Most frequent gender terms: non-binary (12), woman (12); ethnicity terms: Native American (11), Indigenous American (8).", "Cluster 39: 25 items. Most frequent gender terms: woman (11), non-binary (10); ethnicity terms: Latinx (8), Hispanic (6).", "Cluster 40: 25 items. Most frequent gender terms: man (19), unmarked (6); ethnicity terms: Indigenous American (5), First Nations (4).", "Cluster 41: 24 items. Most frequent gender terms: man (21), unmarked (3); ethnicity terms: Latino (11), Hispanic (8).", "Cluster 42: 24 items. Most frequent gender terms: woman (17), unmarked (5); ethnicity terms: East Asian (17), Southeast Asian (4).", "Cluster 43: 24 items. Most frequent gender terms: woman (18), non-binary (3); ethnicity terms: Indigenous American (6), American Indian (6).", "Cluster 44: 23 items. Most frequent gender terms: non-binary (21), woman (2); ethnicity terms: Indigenous American (5), Native American (3).", "Cluster 45: 22 items. Most frequent gender terms: woman (19), non-binary (2); ethnicity terms: Caucasian (5), White (5).", "Cluster 46: 22 items. Most frequent gender terms: woman (15), non-binary (6); ethnicity terms: Caucasian (8), unmarked (8).", "Cluster 47: 21 items. Most frequent gender terms: man (10), non-binary (8); ethnicity terms: First Nations (8), American Indian (5)."]}
clusters/professions_to_clusters_12.json ADDED
The diff for this file is too large to render. See raw diff
 
clusters/professions_to_clusters_24.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:60002a2db2baf80593f5ee78cff69ab3da3ea484c2164a167acebbafce52d095
3
+ size 11263571
clusters/professions_to_clusters_48.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cdfb0225cab02890cc86d78a653353e13090d0010a3ea25aab90cd13f14e5f4f
3
+ size 16982605
professions/dataset_info.json ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "citation": "",
3
+ "dataset_size": 3089241323,
4
+ "description": "",
5
+ "download_checksums": {
6
+ "https://huggingface.co/datasets/SDbiaseval/professions/resolve/4d67923c5740d1530f54ea7c8f6544906006499f/data/train-00000-of-00007-3b31e5f6c84de043.parquet": {
7
+ "num_bytes": 498356472,
8
+ "checksum": "53b1c32f5fc976a4c1dc00493d163b76fbf64bd7c0f7c57088a689c802abba24"
9
+ },
10
+ "https://huggingface.co/datasets/SDbiaseval/professions/resolve/4d67923c5740d1530f54ea7c8f6544906006499f/data/train-00001-of-00007-554593e2dcffb358.parquet": {
11
+ "num_bytes": 500540901,
12
+ "checksum": "b0061ec7a28bbb69653b32038e3f65e777167c469c5a8504822ab9de2ef68d2d"
13
+ },
14
+ "https://huggingface.co/datasets/SDbiaseval/professions/resolve/4d67923c5740d1530f54ea7c8f6544906006499f/data/train-00002-of-00007-80bfc2d01d5f617a.parquet": {
15
+ "num_bytes": 471684879,
16
+ "checksum": "80a59afad1705d7009a12ba90fdacaa9ac7d3e597bf46aee94824c65847f5e42"
17
+ },
18
+ "https://huggingface.co/datasets/SDbiaseval/professions/resolve/4d67923c5740d1530f54ea7c8f6544906006499f/data/train-00003-of-00007-5879e1e46f149000.parquet": {
19
+ "num_bytes": 441709921,
20
+ "checksum": "95d5d192d35297fdc3e37ce3d4296a4cc4a7ce61e877591956c46d0e073df790"
21
+ },
22
+ "https://huggingface.co/datasets/SDbiaseval/professions/resolve/4d67923c5740d1530f54ea7c8f6544906006499f/data/train-00004-of-00007-b38d2407c040db34.parquet": {
23
+ "num_bytes": 418266167,
24
+ "checksum": "f8ce3ec4d7369a73e8d45f0faa1acb65ca8524892dd29c281de0a4ad77c0d57d"
25
+ },
26
+ "https://huggingface.co/datasets/SDbiaseval/professions/resolve/4d67923c5740d1530f54ea7c8f6544906006499f/data/train-00005-of-00007-8c7dc4ce48ca40eb.parquet": {
27
+ "num_bytes": 367229116,
28
+ "checksum": "d25286b4f983ca4b28ef6b21ce95623e488254fd4b5ae67fd727860caf150b7a"
29
+ },
30
+ "https://huggingface.co/datasets/SDbiaseval/professions/resolve/4d67923c5740d1530f54ea7c8f6544906006499f/data/train-00006-of-00007-1c5d5d431e4a9776.parquet": {
31
+ "num_bytes": 377708035,
32
+ "checksum": "93ae11b5e5e63940d9eb769747d9be72fec3b97c13853ef6d177b950b7af42e6"
33
+ }
34
+ },
35
+ "download_size": 3075495491,
36
+ "features": {
37
+ "adjective": {
38
+ "dtype": "string",
39
+ "_type": "Value"
40
+ },
41
+ "profession": {
42
+ "dtype": "string",
43
+ "_type": "Value"
44
+ },
45
+ "no": {
46
+ "dtype": "int32",
47
+ "_type": "Value"
48
+ },
49
+ "image_path": {
50
+ "dtype": "string",
51
+ "_type": "Value"
52
+ },
53
+ "image": {
54
+ "_type": "Image"
55
+ },
56
+ "model": {
57
+ "dtype": "string",
58
+ "_type": "Value"
59
+ }
60
+ },
61
+ "homepage": "",
62
+ "license": "",
63
+ "size_in_bytes": 6164736814,
64
+ "splits": {
65
+ "train": {
66
+ "name": "train",
67
+ "num_bytes": 3089241323,
68
+ "num_examples": 94500,
69
+ "shard_lengths": [
70
+ 13500,
71
+ 13500,
72
+ 23500,
73
+ 17000,
74
+ 23500,
75
+ 3500
76
+ ],
77
+ "dataset_name": "parquet"
78
+ }
79
+ }
80
+ }
professions/state.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_data_files": [
3
+ {
4
+ "filename": "data-00000-of-00007.arrow"
5
+ },
6
+ {
7
+ "filename": "data-00001-of-00007.arrow"
8
+ },
9
+ {
10
+ "filename": "data-00002-of-00007.arrow"
11
+ },
12
+ {
13
+ "filename": "data-00003-of-00007.arrow"
14
+ },
15
+ {
16
+ "filename": "data-00004-of-00007.arrow"
17
+ },
18
+ {
19
+ "filename": "data-00005-of-00007.arrow"
20
+ },
21
+ {
22
+ "filename": "data-00006-of-00007.arrow"
23
+ }
24
+ ],
25
+ "_fingerprint": "b5009ffb3c3f22be",
26
+ "_format_columns": null,
27
+ "_format_kwargs": {},
28
+ "_format_type": null,
29
+ "_output_all_columns": false,
30
+ "_split": "train"
31
+ }
promptsadjectives.csv ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Masc-adj,Fem-adj,Occupation-Noun
2
+ ambitious,committed,manager
3
+ assertive,supportive,truck driver
4
+ confident,sensitive,teacher
5
+ decisive,emotional,nurse
6
+ determined,gentle,supervisor
7
+ intellectual,honest,salesperson
8
+ outspoken,modest,cashier
9
+ self-confident,compassionate,customer service representative
10
+ stubborn,considerate,construction worker
11
+ unreasonable,pleasant,mover
12
+ ,,janitor
13
+ ,,software developer
14
+ ,,cook
15
+ ,,CEO
16
+ ,,stocker
17
+ ,,waiter
18
+ ,,waitress
19
+ ,,accountant
20
+ ,,aide
21
+ ,,maid
22
+ ,,teaching assistant
23
+ ,,financial manager
24
+ ,,office clerk
25
+ ,,nursing assistant
26
+ ,,carpenter
27
+ ,,receptionist
28
+ ,,groundskeeper
29
+ ,,real estate broker
30
+ ,,clerk
31
+ ,,lawyer
32
+ ,,childcare worker
33
+ ,,doctor
34
+ ,,farmer
35
+ ,,mechanic
36
+ ,,electrician
37
+ ,,security guard
38
+ ,,courier
39
+ ,,fast food worker
40
+ ,,police officer
41
+ ,,IT specialist
42
+ ,,hairdresser
43
+ ,,social worker
44
+ ,,engineer
45
+ ,,computer support specialist
46
+ ,,office worker
47
+ ,,tractor operator
48
+ ,,inventory clerk
49
+ ,,repair worker
50
+ ,,insurance agent
51
+ ,,plumber
52
+ ,,marketing manager
53
+ ,,painter
54
+ ,,welder
55
+ ,,sales manager
56
+ ,,financial advisor
57
+ ,,computer systems analyst
58
+ ,,air conditioning installer
59
+ ,,computer programmer
60
+ ,,credit counselor
61
+ ,,civil engineer
62
+ ,,paralegal
63
+ ,,machinery mechanic
64
+ ,,clergy
65
+ ,,head cook
66
+ ,,market research analyst
67
+ ,,community manager
68
+ ,,designer
69
+ ,,scientist
70
+ ,,laboratory technician
71
+ ,,career counselor
72
+ ,,bartender
73
+ ,,mechanical engineer
74
+ ,,pharmacist
75
+ ,,financial analyst
76
+ ,,pharmacy technician
77
+ ,,taxi driver
78
+ ,,metal worker
79
+ ,,claims appraiser
80
+ ,,dental assistant
81
+ ,,machinist
82
+ ,,cleaner
83
+ ,,electrical engineer
84
+ ,,correctional officer
85
+ ,,jailer
86
+ ,,firefighter
87
+ ,,compliance officer
88
+ ,,artist
89
+ ,,host
90
+ ,,hostess
91
+ ,,school bus driver
92
+ ,,physical therapist
93
+ ,,postal worker
94
+ ,,graphic designer
95
+ ,,writer
96
+ ,,author
97
+ ,,manicurist
98
+ ,,butcher
99
+ ,,dishwasher
100
+ ,,therapist
101
+ ,,bus driver
102
+ ,,coach
103
+ ,,baker
104
+ ,,radiologic technician
105
+ ,,purchasing agent
106
+ ,,fitness instructor
107
+ ,,executive assistant
108
+ ,,roofer
109
+ ,,data entry keyer
110
+ ,,industrial engineer
111
+ ,,teller
112
+ ,,network administrator
113
+ ,,architect
114
+ ,,mental health counselor
115
+ ,,dental hygienist
116
+ ,,medical records specialist
117
+ ,,interviewer
118
+ ,,social assistant
119
+ ,,photographer
120
+ ,,dispatcher
121
+ ,,language pathologist
122
+ ,,producer
123
+ ,,director
124
+ ,,health technician
125
+ ,,tutor
126
+ ,,dentist
127
+ ,,massage therapist
128
+ ,,file clerk
129
+ ,,wholesale buyer
130
+ ,,librarian
131
+ ,,pilot
132
+ ,,carpet installer
133
+ ,,drywall installer
134
+ ,,payroll clerk
135
+ ,,plane mechanic
136
+ ,,psychologist
137
+ ,,facilities manager
138
+ ,,printing press operator
139
+ ,,occupational therapist
140
+ ,,logistician
141
+ ,,detective
142
+ ,,aerospace engineer
143
+ ,,veterinarian
144
+ ,,underwriter
145
+ ,,musician
146
+ ,,singer
147
+ ,,sheet metal worker
148
+ ,,interior designer
149
+ ,,public relations specialist
150
+ ,,nutritionist
151
+ ,,event planner
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ pandas
2
+ plotly
3
+ numpy