parlai/agents/transformer/polyencoder.py
Killed 145 out of 221 mutantsSurvived
Survived mutation testing. These mutants show holes in your test suite.Mutant 116
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -38,7 +38,7 @@
Add command-line arguments specifically for this agent.
"""
TransformerRankerAgent.add_cmdline_args(argparser)
- agent = argparser.add_argument_group('Polyencoder Arguments')
+ agent = argparser.add_argument_group('XXPolyencoder ArgumentsXX')
agent.add_argument(
'--polyencoder-type',
type=str,
Mutant 120
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -43,7 +43,7 @@
'--polyencoder-type',
type=str,
default='codes',
- choices=['codes', 'n_first'],
+ choices=['XXcodesXX', 'n_first'],
help='Type of polyencoder, either we compute'
'vectors using codes + attention, or we '
'simply take the first N vectors.',
Mutant 121
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -43,7 +43,7 @@
'--polyencoder-type',
type=str,
default='codes',
- choices=['codes', 'n_first'],
+ choices=['codes', 'XXn_firstXX'],
help='Type of polyencoder, either we compute'
'vectors using codes + attention, or we '
'simply take the first N vectors.',
Mutant 122
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -44,7 +44,7 @@
type=str,
default='codes',
choices=['codes', 'n_first'],
- help='Type of polyencoder, either we compute'
+ help='XXType of polyencoder, either we computeXX'
'vectors using codes + attention, or we '
'simply take the first N vectors.',
recommended='codes',
Mutant 125
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -52,7 +52,7 @@
agent.add_argument(
'--poly-n-codes',
type=int,
- default=64,
+ default=65,
help='number of vectors used to represent the context'
'in the case of n_first, those are the number'
'of vectors that are considered.',
Mutant 126
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -53,7 +53,7 @@
'--poly-n-codes',
type=int,
default=64,
- help='number of vectors used to represent the context'
+ help='XXnumber of vectors used to represent the contextXX'
'in the case of n_first, those are the number'
'of vectors that are considered.',
recommended=64,
Mutant 127
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -56,7 +56,7 @@
help='number of vectors used to represent the context'
'in the case of n_first, those are the number'
'of vectors that are considered.',
- recommended=64,
+ recommended=65,
)
agent.add_argument(
'--poly-attention-type',
Mutant 129
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -61,7 +61,7 @@
agent.add_argument(
'--poly-attention-type',
type=str,
- default='basic',
+ default='XXbasicXX',
choices=['basic', 'sqrt', 'multihead'],
help='Type of the top aggregation layer of the poly-'
'encoder (where the candidate representation is'
Mutant 130
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -62,7 +62,7 @@
'--poly-attention-type',
type=str,
default='basic',
- choices=['basic', 'sqrt', 'multihead'],
+ choices=['XXbasicXX', 'sqrt', 'multihead'],
help='Type of the top aggregation layer of the poly-'
'encoder (where the candidate representation is'
'the key)',
Mutant 131
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -62,7 +62,7 @@
'--poly-attention-type',
type=str,
default='basic',
- choices=['basic', 'sqrt', 'multihead'],
+ choices=['basic', 'XXsqrtXX', 'multihead'],
help='Type of the top aggregation layer of the poly-'
'encoder (where the candidate representation is'
'the key)',
Mutant 132
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -62,7 +62,7 @@
'--poly-attention-type',
type=str,
default='basic',
- choices=['basic', 'sqrt', 'multihead'],
+ choices=['basic', 'sqrt', 'XXmultiheadXX'],
help='Type of the top aggregation layer of the poly-'
'encoder (where the candidate representation is'
'the key)',
Mutant 133
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -63,7 +63,7 @@
type=str,
default='basic',
choices=['basic', 'sqrt', 'multihead'],
- help='Type of the top aggregation layer of the poly-'
+ help='XXType of the top aggregation layer of the poly-XX'
'encoder (where the candidate representation is'
'the key)',
recommended='basic',
Mutant 134
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -66,7 +66,7 @@
help='Type of the top aggregation layer of the poly-'
'encoder (where the candidate representation is'
'the key)',
- recommended='basic',
+ recommended='XXbasicXX',
)
agent.add_argument(
'--poly-attention-num-heads',
Mutant 136
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -71,7 +71,7 @@
agent.add_argument(
'--poly-attention-num-heads',
type=int,
- default=4,
+ default=5,
help='In case poly-attention-type is multihead, '
'specify the number of heads',
)
Mutant 137
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -72,7 +72,7 @@
'--poly-attention-num-heads',
type=int,
default=4,
- help='In case poly-attention-type is multihead, '
+ help='XXIn case poly-attention-type is multihead, XX'
'specify the number of heads',
)
Mutant 140
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -81,7 +81,7 @@
'--codes-attention-type',
type=str,
default='basic',
- choices=['basic', 'sqrt', 'multihead'],
+ choices=['XXbasicXX', 'sqrt', 'multihead'],
help='Type ',
recommended='basic',
)
Mutant 141
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -81,7 +81,7 @@
'--codes-attention-type',
type=str,
default='basic',
- choices=['basic', 'sqrt', 'multihead'],
+ choices=['basic', 'XXsqrtXX', 'multihead'],
help='Type ',
recommended='basic',
)
Mutant 142
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -81,7 +81,7 @@
'--codes-attention-type',
type=str,
default='basic',
- choices=['basic', 'sqrt', 'multihead'],
+ choices=['basic', 'sqrt', 'XXmultiheadXX'],
help='Type ',
recommended='basic',
)
Mutant 143
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -82,7 +82,7 @@
type=str,
default='basic',
choices=['basic', 'sqrt', 'multihead'],
- help='Type ',
+ help='XXType XX',
recommended='basic',
)
agent.add_argument(
Mutant 144
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -83,7 +83,7 @@
default='basic',
choices=['basic', 'sqrt', 'multihead'],
help='Type ',
- recommended='basic',
+ recommended='XXbasicXX',
)
agent.add_argument(
'--codes-attention-num-heads',
Mutant 146
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -88,7 +88,7 @@
agent.add_argument(
'--codes-attention-num-heads',
type=int,
- default=4,
+ default=5,
help='In case codes-attention-type is multihead, '
'specify the number of heads',
)
Mutant 147
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -89,7 +89,7 @@
'--codes-attention-num-heads',
type=int,
default=4,
- help='In case codes-attention-type is multihead, '
+ help='XXIn case codes-attention-type is multihead, XX'
'specify the number of heads',
)
return agent
Mutant 150
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -100,7 +100,7 @@
opt_from_disk = super(PolyencoderAgent, cls).upgrade_opt(opt_from_disk)
polyencoder_attention_keys_value = opt_from_disk.get(
- 'polyencoder_attention_keys'
+ 'XXpolyencoder_attention_keysXX'
)
if polyencoder_attention_keys_value is not None:
# 2020-02-19 We are deprecating this flag because it was used for a one-time
Mutant 152
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -117,7 +117,7 @@
def __init__(self, opt, shared=None):
super().__init__(opt, shared)
- self.rank_loss = torch.nn.CrossEntropyLoss(reduce=True, size_average=True)
+ self.rank_loss = torch.nn.CrossEntropyLoss(reduce=False, size_average=True)
if self.use_cuda:
self.rank_loss.cuda()
Mutant 153
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -117,7 +117,7 @@
def __init__(self, opt, shared=None):
super().__init__(opt, shared)
- self.rank_loss = torch.nn.CrossEntropyLoss(reduce=True, size_average=True)
+ self.rank_loss = torch.nn.CrossEntropyLoss(reduce=True, size_average=False)
if self.use_cuda:
self.rank_loss.cuda()
Mutant 154
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -117,7 +117,7 @@
def __init__(self, opt, shared=None):
super().__init__(opt, shared)
- self.rank_loss = torch.nn.CrossEntropyLoss(reduce=True, size_average=True)
+ self.rank_loss = None
if self.use_cuda:
self.rank_loss.cuda()
Mutant 163
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -141,7 +141,7 @@
Add the start and end token to the text.
"""
obs = super()._set_text_vec(*args, **kwargs)
- if 'text_vec' in obs and 'added_start_end_tokens' not in obs:
+ if 'XXtext_vecXX' in obs and 'added_start_end_tokens' not in obs:
obs.force_set(
'text_vec', self._add_start_end_tokens(obs['text_vec'], True, True)
)
Mutant 165
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -141,7 +141,7 @@
Add the start and end token to the text.
"""
obs = super()._set_text_vec(*args, **kwargs)
- if 'text_vec' in obs and 'added_start_end_tokens' not in obs:
+ if 'text_vec' in obs and 'XXadded_start_end_tokensXX' not in obs:
obs.force_set(
'text_vec', self._add_start_end_tokens(obs['text_vec'], True, True)
)
Mutant 166
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -141,7 +141,7 @@
Add the start and end token to the text.
"""
obs = super()._set_text_vec(*args, **kwargs)
- if 'text_vec' in obs and 'added_start_end_tokens' not in obs:
+ if 'text_vec' in obs and 'added_start_end_tokens' in obs:
obs.force_set(
'text_vec', self._add_start_end_tokens(obs['text_vec'], True, True)
)
Mutant 168
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -143,7 +143,7 @@
obs = super()._set_text_vec(*args, **kwargs)
if 'text_vec' in obs and 'added_start_end_tokens' not in obs:
obs.force_set(
- 'text_vec', self._add_start_end_tokens(obs['text_vec'], True, True)
+ 'XXtext_vecXX', self._add_start_end_tokens(obs['text_vec'], True, True)
)
obs['added_start_end_tokens'] = True
return obs
Mutant 170
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -143,7 +143,7 @@
obs = super()._set_text_vec(*args, **kwargs)
if 'text_vec' in obs and 'added_start_end_tokens' not in obs:
obs.force_set(
- 'text_vec', self._add_start_end_tokens(obs['text_vec'], True, True)
+ 'text_vec', self._add_start_end_tokens(obs['text_vec'], False, True)
)
obs['added_start_end_tokens'] = True
return obs
Mutant 171
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -143,7 +143,7 @@
obs = super()._set_text_vec(*args, **kwargs)
if 'text_vec' in obs and 'added_start_end_tokens' not in obs:
obs.force_set(
- 'text_vec', self._add_start_end_tokens(obs['text_vec'], True, True)
+ 'text_vec', self._add_start_end_tokens(obs['text_vec'], True, False)
)
obs['added_start_end_tokens'] = True
return obs
Mutant 172
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -145,7 +145,7 @@
obs.force_set(
'text_vec', self._add_start_end_tokens(obs['text_vec'], True, True)
)
- obs['added_start_end_tokens'] = True
+ obs['XXadded_start_end_tokensXX'] = True
return obs
def vectorize_fixed_candidates(self, *args, **kwargs):
Mutant 173
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -145,7 +145,7 @@
obs.force_set(
'text_vec', self._add_start_end_tokens(obs['text_vec'], True, True)
)
- obs['added_start_end_tokens'] = True
+ obs['added_start_end_tokens'] = False
return obs
def vectorize_fixed_candidates(self, *args, **kwargs):
Mutant 174
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -145,7 +145,7 @@
obs.force_set(
'text_vec', self._add_start_end_tokens(obs['text_vec'], True, True)
)
- obs['added_start_end_tokens'] = True
+ obs['added_start_end_tokens'] = None
return obs
def vectorize_fixed_candidates(self, *args, **kwargs):
Mutant 179
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -156,7 +156,7 @@
interactive mode.
"""
kwargs['add_start'] = True
- kwargs['add_end'] = True
+ kwargs['add_end'] = False
return super().vectorize_fixed_candidates(*args, **kwargs)
def _make_candidate_encs(self, vecs):
Mutant 180
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -156,7 +156,7 @@
interactive mode.
"""
kwargs['add_start'] = True
- kwargs['add_end'] = True
+ kwargs['add_end'] = None
return super().vectorize_fixed_candidates(*args, **kwargs)
def _make_candidate_encs(self, vecs):
Mutant 191
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -189,7 +189,7 @@
ctxt_rep, ctxt_rep_mask, _ = self.model(**self._model_context_input(batch))
if cand_encs is not None:
- if bsz == 1:
+ if bsz == 2:
cand_rep = cand_encs
else:
cand_rep = cand_encs.expand(bsz, cand_encs.size(1), -1)
Mutant 212
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -232,7 +232,7 @@
"""
Override to account for codes.
"""
- if self.model.type == 'codes' and 'codes' not in state_dict:
+ if self.model.type != 'codes' and 'codes' not in state_dict:
state_dict['codes'] = self.model.codes
super().load_state_dict(state_dict)
Mutant 213
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -232,7 +232,7 @@
"""
Override to account for codes.
"""
- if self.model.type == 'codes' and 'codes' not in state_dict:
+ if self.model.type == 'XXcodesXX' and 'codes' not in state_dict:
state_dict['codes'] = self.model.codes
super().load_state_dict(state_dict)
Mutant 214
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -232,7 +232,7 @@
"""
Override to account for codes.
"""
- if self.model.type == 'codes' and 'codes' not in state_dict:
+ if self.model.type == 'codes' and 'XXcodesXX' not in state_dict:
state_dict['codes'] = self.model.codes
super().load_state_dict(state_dict)
Mutant 215
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -232,7 +232,7 @@
"""
Override to account for codes.
"""
- if self.model.type == 'codes' and 'codes' not in state_dict:
+ if self.model.type == 'codes' and 'codes' in state_dict:
state_dict['codes'] = self.model.codes
super().load_state_dict(state_dict)
Mutant 216
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -232,7 +232,7 @@
"""
Override to account for codes.
"""
- if self.model.type == 'codes' and 'codes' not in state_dict:
+ if self.model.type == 'codes' or 'codes' not in state_dict:
state_dict['codes'] = self.model.codes
super().load_state_dict(state_dict)
Mutant 217
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -246,7 +246,7 @@
def __init__(self, opt, dict_, null_idx):
super(PolyEncoderModule, self).__init__()
- self.null_idx = null_idx
+ self.null_idx = None
self.encoder_ctxt = self.get_encoder(
opt=opt,
dict_=dict_,
Mutant 218
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -252,7 +252,7 @@
dict_=dict_,
null_idx=null_idx,
reduction_type=None,
- for_context=True,
+ for_context=False,
)
self.encoder_cand = self.get_encoder(
opt=opt,
Mutant 220
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -259,7 +259,7 @@
dict_=dict_,
null_idx=null_idx,
reduction_type=opt['reduction_type'],
- for_context=False,
+ for_context=True,
)
self.type = opt['polyencoder_type']
Mutant 226
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -264,7 +264,7 @@
self.type = opt['polyencoder_type']
self.n_codes = opt['poly_n_codes']
- self.attention_type = opt['poly_attention_type']
+ self.attention_type = None
self.attention_num_heads = opt['poly_attention_num_heads']
self.codes_attention_type = opt['codes_attention_type']
self.codes_attention_num_heads = opt['codes_attention_num_heads']
Mutant 228
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -265,7 +265,7 @@
self.type = opt['polyencoder_type']
self.n_codes = opt['poly_n_codes']
self.attention_type = opt['poly_attention_type']
- self.attention_num_heads = opt['poly_attention_num_heads']
+ self.attention_num_heads = None
self.codes_attention_type = opt['codes_attention_type']
self.codes_attention_num_heads = opt['codes_attention_num_heads']
embed_dim = opt['embedding_size']
Mutant 232
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -267,7 +267,7 @@
self.attention_type = opt['poly_attention_type']
self.attention_num_heads = opt['poly_attention_num_heads']
self.codes_attention_type = opt['codes_attention_type']
- self.codes_attention_num_heads = opt['codes_attention_num_heads']
+ self.codes_attention_num_heads = None
embed_dim = opt['embedding_size']
# In case it's a polyencoder with code.
Mutant 241
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -278,7 +278,7 @@
self.codes = torch.nn.Parameter(codes)
# The attention for the codes.
- if self.codes_attention_type == 'multihead':
+ if self.codes_attention_type == 'XXmultiheadXX':
self.code_attention = MultiHeadAttention(
self.codes_attention_num_heads, embed_dim, opt['dropout']
)
Mutant 242
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -282,7 +282,7 @@
self.code_attention = MultiHeadAttention(
self.codes_attention_num_heads, embed_dim, opt['dropout']
)
- elif self.codes_attention_type == 'sqrt':
+ elif self.codes_attention_type != 'sqrt':
self.code_attention = PolyBasicAttention(
self.type, self.n_codes, dim=2, attn='sqrt', get_weights=False
)
Mutant 243
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -282,7 +282,7 @@
self.code_attention = MultiHeadAttention(
self.codes_attention_num_heads, embed_dim, opt['dropout']
)
- elif self.codes_attention_type == 'sqrt':
+ elif self.codes_attention_type == 'XXsqrtXX':
self.code_attention = PolyBasicAttention(
self.type, self.n_codes, dim=2, attn='sqrt', get_weights=False
)
Mutant 247
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -288,7 +288,7 @@
)
elif self.codes_attention_type == 'basic':
self.code_attention = PolyBasicAttention(
- self.type, self.n_codes, dim=2, attn='basic', get_weights=False
+ self.type, self.n_codes, dim=2, attn='XXbasicXX', get_weights=False
)
# The final attention (the one that takes the candidate as key)
Mutant 250
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -292,7 +292,7 @@
)
# The final attention (the one that takes the candidate as key)
- if self.attention_type == 'multihead':
+ if self.attention_type == 'XXmultiheadXX':
self.attention = MultiHeadAttention(
self.attention_num_heads, opt['embedding_size'], opt['dropout']
)
Mutant 264
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -342,7 +342,7 @@
embeddings_scale=opt['embeddings_scale'],
reduction_type=reduction_type,
n_positions=n_positions,
- n_segments=opt.get('n_segments', 2),
+ n_segments=opt.get('XXn_segmentsXX', 2),
activation=opt['activation'],
variant=opt['variant'],
output_scaling=opt['output_scaling'],
Mutant 265
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -342,7 +342,7 @@
embeddings_scale=opt['embeddings_scale'],
reduction_type=reduction_type,
n_positions=n_positions,
- n_segments=opt.get('n_segments', 2),
+ n_segments=opt.get('n_segments', 3),
activation=opt['activation'],
variant=opt['variant'],
output_scaling=opt['output_scaling'],
Mutant 269
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -352,7 +352,7 @@
embeddings = torch.nn.Embedding(
len(dict_), embedding_size, padding_idx=null_idx
)
- torch.nn.init.normal_(embeddings.weight, 0, embedding_size ** -0.5)
+ torch.nn.init.normal_(embeddings.weight, 1, embedding_size ** -0.5)
return embeddings
def attend(self, attention_layer, queries, keys, values, mask):
Mutant 270
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -352,7 +352,7 @@
embeddings = torch.nn.Embedding(
len(dict_), embedding_size, padding_idx=null_idx
)
- torch.nn.init.normal_(embeddings.weight, 0, embedding_size ** -0.5)
+ torch.nn.init.normal_(embeddings.weight, 0, embedding_size * -0.5)
return embeddings
def attend(self, attention_layer, queries, keys, values, mask):
Mutant 271
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -352,7 +352,7 @@
embeddings = torch.nn.Embedding(
len(dict_), embedding_size, padding_idx=null_idx
)
- torch.nn.init.normal_(embeddings.weight, 0, embedding_size ** -0.5)
+ torch.nn.init.normal_(embeddings.weight, 0, embedding_size ** +0.5)
return embeddings
def attend(self, attention_layer, queries, keys, values, mask):
Mutant 272
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -352,7 +352,7 @@
embeddings = torch.nn.Embedding(
len(dict_), embedding_size, padding_idx=null_idx
)
- torch.nn.init.normal_(embeddings.weight, 0, embedding_size ** -0.5)
+ torch.nn.init.normal_(embeddings.weight, 0, embedding_size ** -1.5)
return embeddings
def attend(self, attention_layer, queries, keys, values, mask):
Mutant 273
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -374,7 +374,7 @@
the result of applying attention to the values, with weights computed
wrt to the queries and keys.
"""
- if keys is None:
+ if keys is not None:
keys = values
if isinstance(attention_layer, PolyBasicAttention):
return attention_layer(queries, keys, mask_ys=mask, values=values)
Mutant 274
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -403,7 +403,7 @@
in the ctxt_rep)
- cand_rep (3D float tensor) batchsize x num_cands x dim
"""
- cand_embed = None
+ cand_embed = ""
ctxt_rep = None
ctxt_rep_mask = None
Mutant 275
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -404,7 +404,7 @@
- cand_rep (3D float tensor) batchsize x num_cands x dim
"""
cand_embed = None
- ctxt_rep = None
+ ctxt_rep = ""
ctxt_rep_mask = None
if cand_tokens is not None:
Mutant 276
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -405,7 +405,7 @@
"""
cand_embed = None
ctxt_rep = None
- ctxt_rep_mask = None
+ ctxt_rep_mask = ""
if cand_tokens is not None:
assert len(cand_tokens.shape) == 3
Mutant 296
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -416,7 +416,7 @@
if len(ctxt_inputs) > 0:
assert 'ctxt_tokens' in ctxt_inputs
- if ctxt_inputs['ctxt_tokens'] is not None:
+ if ctxt_inputs['ctxt_tokens'] is None:
assert len(ctxt_inputs['ctxt_tokens'].shape) == 2
bsz = self._get_context_batch_size(**ctxt_inputs)
# get context_representation. Now that depends on the cases.
Mutant 302
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -423,7 +423,7 @@
ctxt_out, ctxt_mask = self.encoder_ctxt(
**self._context_encoder_input(ctxt_inputs)
)
- dim = ctxt_out.size(2)
+ dim = None
if self.type == 'codes':
ctxt_rep = self.attend(
Mutant 324
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -528,7 +528,7 @@
if len(ctxt_inputs) > 0 or cand_tokens is not None:
return self.encode(cand_tokens=cand_tokens, **ctxt_inputs)
elif (
- ctxt_rep is not None and ctxt_rep_mask is not None and cand_rep is not None
+ ctxt_rep is not None or ctxt_rep_mask is not None and cand_rep is not None
):
return self.score(ctxt_rep, ctxt_rep_mask, cand_rep)
raise Exception('Unsupported operation')
Mutant 325
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -541,7 +541,7 @@
def __init__(self, poly_type, n_codes, *args, **kwargs):
super().__init__(*args, **kwargs)
- self.poly_type = poly_type
+ self.poly_type = None
self.n_codes = n_codes
def forward(self, *args, **kwargs):
Mutant 326
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -542,7 +542,7 @@
def __init__(self, poly_type, n_codes, *args, **kwargs):
super().__init__(*args, **kwargs)
self.poly_type = poly_type
- self.n_codes = n_codes
+ self.n_codes = None
def forward(self, *args, **kwargs):
"""
Mutant 328
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -552,7 +552,7 @@
polyencoder type is 'codes'
"""
lhs_emb = super().forward(*args, **kwargs)
- if self.poly_type == 'codes' and self.n_codes == 1 and len(lhs_emb.shape) == 2:
+ if self.poly_type != 'codes' and self.n_codes == 1 and len(lhs_emb.shape) == 2:
lhs_emb = lhs_emb.unsqueeze(self.dim - 1)
return lhs_emb
Mutant 329
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -552,7 +552,7 @@
polyencoder type is 'codes'
"""
lhs_emb = super().forward(*args, **kwargs)
- if self.poly_type == 'codes' and self.n_codes == 1 and len(lhs_emb.shape) == 2:
+ if self.poly_type == 'XXcodesXX' and self.n_codes == 1 and len(lhs_emb.shape) == 2:
lhs_emb = lhs_emb.unsqueeze(self.dim - 1)
return lhs_emb
Mutant 330
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -552,7 +552,7 @@
polyencoder type is 'codes'
"""
lhs_emb = super().forward(*args, **kwargs)
- if self.poly_type == 'codes' and self.n_codes == 1 and len(lhs_emb.shape) == 2:
+ if self.poly_type == 'codes' and self.n_codes != 1 and len(lhs_emb.shape) == 2:
lhs_emb = lhs_emb.unsqueeze(self.dim - 1)
return lhs_emb
Mutant 331
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -552,7 +552,7 @@
polyencoder type is 'codes'
"""
lhs_emb = super().forward(*args, **kwargs)
- if self.poly_type == 'codes' and self.n_codes == 1 and len(lhs_emb.shape) == 2:
+ if self.poly_type == 'codes' and self.n_codes == 2 and len(lhs_emb.shape) == 2:
lhs_emb = lhs_emb.unsqueeze(self.dim - 1)
return lhs_emb
Mutant 332
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -552,7 +552,7 @@
polyencoder type is 'codes'
"""
lhs_emb = super().forward(*args, **kwargs)
- if self.poly_type == 'codes' and self.n_codes == 1 and len(lhs_emb.shape) == 2:
+ if self.poly_type == 'codes' and self.n_codes == 1 and len(lhs_emb.shape) != 2:
lhs_emb = lhs_emb.unsqueeze(self.dim - 1)
return lhs_emb
Mutant 333
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -552,7 +552,7 @@
polyencoder type is 'codes'
"""
lhs_emb = super().forward(*args, **kwargs)
- if self.poly_type == 'codes' and self.n_codes == 1 and len(lhs_emb.shape) == 2:
+ if self.poly_type == 'codes' and self.n_codes == 1 and len(lhs_emb.shape) == 3:
lhs_emb = lhs_emb.unsqueeze(self.dim - 1)
return lhs_emb
Mutant 335
--- parlai/agents/transformer/polyencoder.py
+++ parlai/agents/transformer/polyencoder.py
@@ -562,7 +562,6 @@
Poly-encoder agent that allows for adding label to fixed cands.
"""
- @classmethod
def add_cmdline_args(cls, argparser):
"""
Add cmd line args.