@@ -57,80 +57,84 @@ def debiasing(methods, content, bar):
57
57
else :
58
58
vocab , vecs = calculation .create_vocab_and_vecs (t1 , t2 , a1 , a2 , aug1 , aug2 )
59
59
60
- t1_deb , t2_deb , a1_deb , a2_deb , new_vecs = [], [], [], [], []
60
+ t1_deb , t2_deb , a1_deb , a2_deb , aug1_deb , aug2_deb , new_vecs = [], [], [], [], [], [], []
61
61
logging .info ("Debiasing-Engine: Specs loaded, starting computing" )
62
62
if methods == 'bam' :
63
- new_vecs , t1_deb , t2_deb , a1_deb , a2_deb = debiasing_bam (equality_sets , vocab , vecs , t1_list , t2_list , a1_list ,
64
- a2_list )
63
+ new_vecs , t1_deb , t2_deb , a1_deb , a2_deb , aug1_deb , aug2_deb = debiasing_bam (equality_sets , vocab , vecs , t1_list , t2_list , a1_list ,
64
+ a2_list , aug1_list , aug2_list )
65
65
if methods == 'gbdd' :
66
- new_vecs , t1_deb , t2_deb , a1_deb , a2_deb = debiasing_gbdd (equality_sets , vocab , vecs , t1_list ,
67
- t2_list , a1_list , a2_list )
68
- if methods == 'bamXgbdd ' :
69
- new_vecs , t1_deb , t2_deb , a1_deb , a2_deb = debiasing_bam_gbdd (equality_sets , vocab , vecs , t1_list , t2_list ,
70
- a1_list , a2_list )
71
- if methods == 'gbddXbam ' :
72
- new_vecs , t1_deb , t2_deb , a1_deb , a2_deb = debiasing_gbdd_bam (equality_sets , vocab , vecs , t1_list , t2_list ,
73
- a1_list , a2_list )
66
+ new_vecs , t1_deb , t2_deb , a1_deb , a2_deb , aug1_deb , aug2_deb = debiasing_gbdd (equality_sets , vocab , vecs , t1_list ,
67
+ t2_list , a1_list , a2_list , aug1_list , aug2_list )
68
+ if methods == 'bamxgbdd ' :
69
+ new_vecs , t1_deb , t2_deb , a1_deb , a2_deb , aug1_deb , aug2_deb = debiasing_bam_gbdd (equality_sets , vocab , vecs , t1_list , t2_list ,
70
+ a1_list , a2_list , aug1_list , aug2_list )
71
+ if methods == 'gbddxbam ' :
72
+ new_vecs , t1_deb , t2_deb , a1_deb , a2_deb , aug1_deb , aug2_deb = debiasing_gbdd_bam (equality_sets , vocab , vecs , t1_list , t2_list ,
73
+ a1_list , a2_list , aug1_list , aug2_list )
74
74
if pca == 'true' :
75
75
biased_space = calculation .principal_componant_analysis2 (vecs )
76
76
debiased_space = calculation .principal_componant_analysis2 (new_vecs )
77
- t1_pca_bias , t2_pca_bias , a1_pca_bias , a2_pca_bias = calculation .vocabs_to_dicts (vocab , biased_space , t1_list ,
77
+ t1_pca_bias , t2_pca_bias , a1_pca_bias , a2_pca_bias , aug1_pca_bias , aug2_pca_bias = calculation .vocabs_to_dicts (vocab , biased_space , t1_list ,
78
78
t2_list ,
79
- a1_list , a2_list )
80
- t1_pca_deb , t2_pca_deb , a1_pca_deb , a2_pca_deb = calculation .vocabs_to_dicts (vocab , debiased_space , t1_list ,
79
+ a1_list , a2_list , aug1_list , aug2_list )
80
+ t1_pca_deb , t2_pca_deb , a1_pca_deb , a2_pca_deb , aug1_pca_deb , aug2_pca_deb = calculation .vocabs_to_dicts (vocab , debiased_space , t1_list ,
81
81
t2_list ,
82
- a1_list , a2_list )
82
+ a1_list , a2_list , aug1_list , aug2_list )
83
83
if lex == 'false' :
84
- response = json_controller .debiasing_json (space , lower , methods , pca , aug1_list , aug2_list , t1 , t2 , a1 , a2 ,
85
- t1_deb , t2_deb , a1_deb , a2_deb , not_found , deleted ,
86
- t1_pca_bias , t2_pca_bias , a1_pca_bias , a2_pca_bias ,
87
- t1_pca_deb , t2_pca_deb , a1_pca_deb , a2_pca_deb )
84
+ response = json_controller .debiasing_json (space , lower , methods , pca , aug1_list , aug2_list ,
85
+ t1 , t2 , a1 , a2 , aug1 , aug2 ,
86
+ t1_deb , t2_deb , a1_deb , a2_deb , aug1_deb , aug2_deb ,
87
+ not_found , deleted ,
88
+ t1_pca_bias , t2_pca_bias , a1_pca_bias , a2_pca_bias , aug1_pca_bias , aug2_pca_bias ,
89
+ t1_pca_deb , t2_pca_deb , a1_pca_deb , a2_pca_deb , aug1_pca_deb , aug2_pca_deb )
88
90
else :
89
91
if lex == 'simlex' :
90
92
lex_dict = calculation .vocab_to_dict (vocab , new_vecs , calculation .simlex_vocab )
91
93
if lex == 'wordsim' :
92
94
lex_dict = calculation .vocab_to_dict (vocab , new_vecs , calculation .wordsim_vocab )
93
- response = json_controller .debiasing_json (space , lower , methods , pca , aug1_list , aug2_list , t1 , t2 , a1 , a2 ,
94
- t1_deb , t2_deb , a1_deb , a2_deb , not_found , deleted ,
95
- t1_pca_bias , t2_pca_bias , a1_pca_bias , a2_pca_bias ,
96
- t1_pca_deb , t2_pca_deb , a1_pca_deb , a2_pca_deb , lex_dict )
95
+ response = json_controller .debiasing_json (space , lower , methods , pca , aug1_list , aug2_list ,
96
+ t1 , t2 , a1 , a2 , aug1 , aug2 ,
97
+ t1_deb , t2_deb , a1_deb , a2_deb , aug1_deb , aug2_deb ,
98
+ not_found , deleted ,
99
+ t1_pca_bias , t2_pca_bias , a1_pca_bias , a2_pca_bias , aug1_pca_bias , aug2_pca_bias ,
100
+ t1_pca_deb , t2_pca_deb , a1_pca_deb , a2_pca_deb , aug1_pca_deb , aug2_pca_deb , lex_dict = lex_dict )
97
101
else :
98
102
if lex == 'false' :
99
- response = json_controller .debiasing_json (space , lower , methods , pca , aug1_list , aug2_list , t1 , t2 , a1 , a2 ,
100
- t1_deb , t2_deb , a1_deb , a2_deb , not_found , deleted )
103
+ response = json_controller .debiasing_json (space , lower , methods , pca , aug1_list , aug2_list , t1 , t2 , a1 , a2 , aug1 , aug2 ,
104
+ t1_deb , t2_deb , a1_deb , a2_deb , aug1_deb , aug2_deb , not_found , deleted )
101
105
else :
102
- response = json_controller .debiasing_json (space , lower , methods , pca , aug1_list , aug2_list , t1 , t2 , a1 , a2 ,
103
- t1_deb , t2_deb , a1_deb , a2_deb , not_found , deleted , lex_dict )
106
+ response = json_controller .debiasing_json (space , lower , methods , pca , aug1_list , aug2_list , t1 , t2 , a1 , a2 , aug1 , aug2 ,
107
+ t1_deb , t2_deb , a1_deb , a2_deb , aug1_deb , aug2_deb , not_found , deleted , lex_dict = lex_dict )
104
108
105
109
logging .info ("Debiasing-Engine: Finished" )
106
110
107
111
return response , 200
108
112
109
113
110
- def debiasing_bam (equality_sets , vocab , vecs , t1_list , t2_list , a1_list , a2_list ):
114
+ def debiasing_bam (equality_sets , vocab , vecs , t1_list , t2_list , a1_list , a2_list , aug1_list , aug2_list ):
111
115
new_vecs , proj_mat = bam .debias_proc (equality_sets , vocab , vecs )
112
- t1 , t2 , a1 , a2 = calculation .vocabs_to_dicts (vocab , new_vecs , t1_list , t2_list , a1_list , a2_list )
113
- return new_vecs , t1 , t2 , a1 , a2 ,
116
+ t1 , t2 , a1 , a2 , aug1 , aug2 = calculation .vocabs_to_dicts (vocab , new_vecs , t1_list , t2_list , a1_list , a2_list , aug1_list , aug2_list )
117
+ return new_vecs , t1 , t2 , a1 , a2 , aug1 , aug2
114
118
115
119
116
- def debiasing_gbdd (equality_sets , vocab , vecs , t1_list , t2_list , a1_list , a2_list ):
120
+ def debiasing_gbdd (equality_sets , vocab , vecs , t1_list , t2_list , a1_list , a2_list , aug1_list , aug2_list ):
117
121
v_b = gbdd .get_bias_direction (equality_sets , vocab , vecs )
118
122
new_vecs = gbdd .debias_direction_linear (v_b , vecs )
119
- t1 , t2 , a1 , a2 = calculation .vocabs_to_dicts (vocab , new_vecs , t1_list , t2_list , a1_list , a2_list )
120
- return new_vecs , t1 , t2 , a1 , a2
123
+ t1 , t2 , a1 , a2 , aug1 , aug2 = calculation .vocabs_to_dicts (vocab , new_vecs , t1_list , t2_list , a1_list , a2_list , aug1_list , aug2_list )
124
+ return new_vecs , t1 , t2 , a1 , a2 , aug1 , aug2
121
125
122
126
123
- def debiasing_bam_gbdd (equality_sets , vocab , vecs , t1_list , t2_list , a1_list , a2_list ):
124
- new_vocab , new_vecs = bam .debias_proc (equality_sets , vocab , vecs )
125
- v_b = gbdd .get_bias_direction (equality_sets , new_vecs , new_vocab )
126
- new_vocab , new_vecs = gbdd .debias_direction_linear (v_b , new_vecs )
127
- t1 , t2 , a1 , a2 = calculation .vocabs_to_dicts (new_vocab , new_vecs , t1_list , t2_list , a1_list , a2_list )
128
- return new_vecs , t1 , t2 , a1 , a2
127
+ def debiasing_bam_gbdd (equality_sets , vocab , vecs , t1_list , t2_list , a1_list , a2_list , aug1_list , aug2_list ):
128
+ new_vecs , proj_matrix = bam .debias_proc (equality_sets , vocab , vecs )
129
+ v_b = gbdd .get_bias_direction (equality_sets , vocab , new_vecs )
130
+ new_vecs = gbdd .debias_direction_linear (v_b , new_vecs )
131
+ t1 , t2 , a1 , a2 , aug1 , aug2 = calculation .vocabs_to_dicts (vocab , new_vecs , t1_list , t2_list , a1_list , a2_list , aug1_list , aug2_list )
132
+ return new_vecs , t1 , t2 , a1 , a2 , aug1 , aug2
129
133
130
134
131
- def debiasing_gbdd_bam (equality_sets , vocab , vecs , t1_list , t2_list , a1_list , a2_list ):
132
- v_b = gbdd .get_bias_direction (equality_sets , vecs , vocab )
133
- new_vocab , new_vecs = gbdd .debias_direction_linear (v_b , vecs )
134
- new_vocab , new_vecs = bam .debias_proc (equality_sets , new_vocab , new_vecs )
135
- t1 , t2 , a1 , a2 = calculation .vocabs_to_dicts (new_vocab , new_vecs , t1_list , t2_list , a1_list , a2_list )
136
- return new_vecs , t1 , t2 , a1 , a2
135
+ def debiasing_gbdd_bam (equality_sets , vocab , vecs , t1_list , t2_list , a1_list , a2_list , aug1_list , aug2_list ):
136
+ v_b = gbdd .get_bias_direction (equality_sets , vocab , vecs )
137
+ new_vecs = gbdd .debias_direction_linear (v_b , vecs )
138
+ new_vecs , proj_matrix = bam .debias_proc (equality_sets , vocab , new_vecs )
139
+ t1 , t2 , a1 , a2 , aug1 , aug2 = calculation .vocabs_to_dicts (vocab , new_vecs , t1_list , t2_list , a1_list , a2_list , aug1_list , aug2_list )
140
+ return new_vecs , t1 , t2 , a1 , a2 , aug1 , aug2
0 commit comments