Zekun Wu commited on
Commit
f0d28e4
1 Parent(s): 08a5da2
Files changed (2) hide show
  1. pages/1_Generation.py +14 -12
  2. pages/2_Evaluation.py +1 -0
pages/1_Generation.py CHANGED
@@ -9,15 +9,19 @@ from util.analysis import statistical_tests, result_evaluation
9
  st.title('JobFair: A Benchmark for Fairness in LLM Employment Decision')
10
  st.sidebar.title('Model Settings')
11
 
 
12
  # Define a function to manage state initialization
13
  def initialize_state():
14
  keys = ["model_submitted", "api_key", "endpoint_url", "deployment_name", "temperature", "max_tokens",
15
- "data_processed", "group_name","occupation", "privilege_label", "protect_label", "num_run", "uploaded_file"]
16
- defaults = [False, "", "https://safeguard-monitor.openai.azure.com/", "gpt35-1106", 0.5, 150, False,"Gender", "Programmer", "Male", "Female", 1, None]
 
 
17
  for key, default in zip(keys, defaults):
18
  if key not in st.session_state:
19
  st.session_state[key] = default
20
 
 
21
  initialize_state()
22
 
23
  # Model selection and configuration
@@ -62,17 +66,20 @@ if st.session_state.model_submitted:
62
  if st.button('Process Data') and not st.session_state.data_processed:
63
  # Initialize the correct agent based on model type
64
  if model_type == 'AzureAgent':
65
- agent = AzureAgent(st.session_state.api_key, st.session_state.endpoint_url, st.session_state.deployment_name)
 
66
  else:
67
- agent = GPTAgent(st.session_state.api_key, st.session_state.endpoint_url, st.session_state.deployment_name, api_version)
 
68
 
69
  # Process data and display results
70
  with st.spinner('Processing data...'):
71
  parameters = {"temperature": st.session_state.temperature, "max_tokens": st.session_state.max_tokens}
72
- df = process_scores(df, st.session_state.num_run, parameters, st.session_state.privilege_label, st.session_state.protect_label, agent, st.session_state.group_name, st.session_state.occupation)
 
 
73
  st.session_state.data_processed = True # Mark as processed
74
 
75
-
76
  st.write('Processed Data:', df)
77
 
78
  # Allow downloading of the evaluation results
@@ -83,11 +90,6 @@ if st.session_state.model_submitted:
83
  mime='text/csv',
84
  )
85
 
86
-
87
-
88
-
89
-
90
-
91
  if st.button("Reset Experiment Settings"):
92
  st.session_state.occupation = "Programmer"
93
  st.session_state.group_name = "Gender"
@@ -95,4 +97,4 @@ if st.session_state.model_submitted:
95
  st.session_state.protect_label = "Female"
96
  st.session_state.num_run = 1
97
  st.session_state.data_processed = False
98
- st.session_state.uploaded_file = None
 
9
  st.title('JobFair: A Benchmark for Fairness in LLM Employment Decision')
10
  st.sidebar.title('Model Settings')
11
 
12
+
13
  # Define a function to manage state initialization
14
  def initialize_state():
15
  keys = ["model_submitted", "api_key", "endpoint_url", "deployment_name", "temperature", "max_tokens",
16
+ "data_processed", "group_name", "occupation", "privilege_label", "protect_label", "num_run",
17
+ "uploaded_file"]
18
+ defaults = [False, "", "https://safeguard-monitor.openai.azure.com/", "gpt35-1106", 0.5, 150, False, "Gender",
19
+ "Programmer", "Male", "Female", 1, None]
20
  for key, default in zip(keys, defaults):
21
  if key not in st.session_state:
22
  st.session_state[key] = default
23
 
24
+
25
  initialize_state()
26
 
27
  # Model selection and configuration
 
66
  if st.button('Process Data') and not st.session_state.data_processed:
67
  # Initialize the correct agent based on model type
68
  if model_type == 'AzureAgent':
69
+ agent = AzureAgent(st.session_state.api_key, st.session_state.endpoint_url,
70
+ st.session_state.deployment_name)
71
  else:
72
+ agent = GPTAgent(st.session_state.api_key, st.session_state.endpoint_url,
73
+ st.session_state.deployment_name, api_version)
74
 
75
  # Process data and display results
76
  with st.spinner('Processing data...'):
77
  parameters = {"temperature": st.session_state.temperature, "max_tokens": st.session_state.max_tokens}
78
+ df = process_scores(df, st.session_state.num_run, parameters, st.session_state.privilege_label,
79
+ st.session_state.protect_label, agent, st.session_state.group_name,
80
+ st.session_state.occupation)
81
  st.session_state.data_processed = True # Mark as processed
82
 
 
83
  st.write('Processed Data:', df)
84
 
85
  # Allow downloading of the evaluation results
 
90
  mime='text/csv',
91
  )
92
 
 
 
 
 
 
93
  if st.button("Reset Experiment Settings"):
94
  st.session_state.occupation = "Programmer"
95
  st.session_state.group_name = "Gender"
 
97
  st.session_state.protect_label = "Female"
98
  st.session_state.num_run = 1
99
  st.session_state.data_processed = False
100
+ st.session_state.uploaded_file = None
pages/2_Evaluation.py CHANGED
@@ -25,6 +25,7 @@ def app():
25
  if st.button('Evaluate Data'):
26
  with st.spinner('Evaluating data...'):
27
  test_results = statistical_tests(df)
 
28
  evaluation_results = result_evaluation(test_results)
29
  st.write('Evaluation Results:', evaluation_results)
30
 
 
25
  if st.button('Evaluate Data'):
26
  with st.spinner('Evaluating data...'):
27
  test_results = statistical_tests(df)
28
+ st.write('Test Results:', test_results)
29
  evaluation_results = result_evaluation(test_results)
30
  st.write('Evaluation Results:', evaluation_results)
31