elfsong commited on
Commit
987f2a7
1 Parent(s): c616aea
Files changed (4) hide show
  1. .gitignore +1 -0
  2. app.py +36 -32
  3. img/meeting.jpg +0 -0
  4. img/meeting.psd +0 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ src/__pycache__/*
app.py CHANGED
@@ -3,34 +3,33 @@ from src.caller import OpenAI_Caller
3
  from src.committee import Committee
4
  from datasets import load_dataset
5
 
 
6
 
7
- st.title("Committee")
8
 
 
 
 
 
9
 
10
- committee_dict = {
11
- "chair": {
12
- "model_caller": OpenAI_Caller('gpt-4-1106-preview')
13
- },
14
- "member": [
15
- {
16
- "bias_type": "age",
17
  "model_caller": OpenAI_Caller('gpt-4-1106-preview')
18
  },
19
- {
20
- "bias_type": "gender",
21
- "model_caller": OpenAI_Caller('gpt-4-1106-preview')
22
- },
23
- {
24
- "bias_type": "religion",
25
- "model_caller": OpenAI_Caller('gpt-4-1106-preview')
26
- },
27
- ]
28
- }
29
 
30
- committee = Committee(committee_dict=committee_dict)
 
31
 
32
- dataset = load_dataset("Elfsong/BBQ")
33
- raw_instance = dataset['age'][0]
 
34
 
35
  instance = {
36
  "context": raw_instance['context'],
@@ -39,26 +38,31 @@ instance = {
39
  "ans1": raw_instance['ans1'],
40
  "ans2": raw_instance['ans2'],
41
  }
42
-
43
  instance = st.data_editor(instance)
44
 
45
- print(instance)
46
-
47
  # Propose
48
  st.header("Propose")
49
  proposals = list()
50
  for member in committee.members:
51
- st.text("member is proposing...")
52
- proposal = member.propose(instance)
53
- st.markdown(proposal)
54
- proposals += [proposal]
 
55
 
56
  # Craft Motion
57
  st.header("Motion")
58
- motion = committee.chair.craft_motion(proposals, instance)
59
- st.markdown(motion)
 
 
60
 
61
  # Vote
62
  st.header("Vote")
63
- vote = [member.vote(motion, instance) for member in committee.members]
64
- st.markdown(vote)
 
 
 
 
 
 
3
  from src.committee import Committee
4
  from datasets import load_dataset
5
 
6
+ st.image('./img/meeting.psd')
7
 
8
+ st.header("Committee")
9
 
10
+ domains = st.multiselect(
11
+ "Let's nominate committee members!",
12
+ ["Age", "Disability Status", "Gender Identity", "Nationality", "Physical Appearance", "Race Ethnicity", "Religion", "Socioeconomic Status", "Sexual Orientation"],
13
+ ["Age", "Nationality", "Religion"])
14
 
15
+ with st.spinner('Initializing committee members...'):
16
+ committee_dict = {
17
+ "chair": {
 
 
 
 
18
  "model_caller": OpenAI_Caller('gpt-4-1106-preview')
19
  },
20
+ "member": [
21
+ {"bias_type": domain, "model_caller": OpenAI_Caller('gpt-4-1106-preview')} for domain in domains
22
+ ]
23
+ }
24
+ with st.spinner('Initializing the committee...'):
25
+ committee = Committee(committee_dict=committee_dict)
 
 
 
 
26
 
27
+ with st.spinner('Loding the BBQ datasets...'):
28
+ dataset = load_dataset("Elfsong/BBQ")
29
 
30
+ category = st.selectbox("Which category you are going to deliberate?", dataset.keys())
31
+ # instance_id = st.number_input("Ok, which one?", min_value=0, max_value=len(dataset[category]))
32
+ raw_instance = dataset[category][0]
33
 
34
  instance = {
35
  "context": raw_instance['context'],
 
38
  "ans1": raw_instance['ans1'],
39
  "ans2": raw_instance['ans2'],
40
  }
 
41
  instance = st.data_editor(instance)
42
 
 
 
43
  # Propose
44
  st.header("Propose")
45
  proposals = list()
46
  for member in committee.members:
47
+ with st.spinner(f'Member who concerns {member.bias_type} is proposing...'):
48
+ proposal = member.propose(instance)
49
+ st.subheader(f"Proposal from Member who concerns [{member.bias_type}]:")
50
+ st.markdown(proposal)
51
+ proposals += [proposal]
52
 
53
  # Craft Motion
54
  st.header("Motion")
55
+ with st.spinner(f'Chair is crafting a motion...'):
56
+ motion = committee.chair.craft_motion(proposals, instance)
57
+ st.subheader(f"Motion from the Chair:")
58
+ st.markdown(motion)
59
 
60
  # Vote
61
  st.header("Vote")
62
+ for member in committee.members:
63
+ with st.spinner(f'Member who concerns {member.bias_type} is voting...'):
64
+ vote_result = member.vote(motion, instance)
65
+ st.subheader(f"Member who concerns [{member.bias_type}] votes:")
66
+ st.markdown(vote_result)
67
+
68
+ st.balloons
img/meeting.jpg ADDED
img/meeting.psd ADDED