Zekun Wu
commited on
Commit
·
5f3d0b7
1
Parent(s):
1bf893a
update
Browse files- pages/1_Demo_1.py +6 -6
pages/1_Demo_1.py
CHANGED
@@ -9,7 +9,6 @@ import os
|
|
9 |
# Set up the Streamlit interface
|
10 |
st.title('Gender Bias Analysis in Text Generation')
|
11 |
|
12 |
-
|
13 |
def check_password():
|
14 |
def password_entered():
|
15 |
if password_input == os.getenv('PASSWORD'):
|
@@ -32,9 +31,12 @@ else:
|
|
32 |
st.write('Loading the BOLD dataset...')
|
33 |
bold = load_dataset("AlexaAI/bold", split="train")
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
38 |
|
39 |
male_prompts = [p['prompts'][0] for p in male_bold]
|
40 |
female_prompts = [p['prompts'][0] for p in female_bold]
|
@@ -69,5 +71,3 @@ else:
|
|
69 |
regard_results_avg = regard.compute(data=male_continuations, references=female_continuations, aggregation='average')
|
70 |
st.write('**Average Regard Results:**')
|
71 |
st.json(regard_results_avg)
|
72 |
-
|
73 |
-
|
|
|
9 |
# Set up the Streamlit interface
|
10 |
st.title('Gender Bias Analysis in Text Generation')
|
11 |
|
|
|
12 |
def check_password():
|
13 |
def password_entered():
|
14 |
if password_input == os.getenv('PASSWORD'):
|
|
|
31 |
st.write('Loading the BOLD dataset...')
|
32 |
bold = load_dataset("AlexaAI/bold", split="train")
|
33 |
|
34 |
+
# Allow user to set the sample size
|
35 |
+
data_size = st.sidebar.slider('Select number of samples per category:', min_value=1, max_value=50, value=10)
|
36 |
+
|
37 |
+
st.write(f'Sampling {data_size} female and male American actors...')
|
38 |
+
female_bold = sample([p for p in bold if p['category'] == 'American_actresses'], data_size)
|
39 |
+
male_bold = sample([p for p in bold if p['category'] == 'American_actors'], data_size)
|
40 |
|
41 |
male_prompts = [p['prompts'][0] for p in male_bold]
|
42 |
female_prompts = [p['prompts'][0] for p in female_bold]
|
|
|
71 |
regard_results_avg = regard.compute(data=male_continuations, references=female_continuations, aggregation='average')
|
72 |
st.write('**Average Regard Results:**')
|
73 |
st.json(regard_results_avg)
|
|
|
|