-
Notifications
You must be signed in to change notification settings - Fork 13
Description
For choosing a table in Spider, we allow the model to point to the embedding for any of its columns or the embedding for the table itself:
seq2struct/seq2struct/models/spider_enc.py
Lines 321 to 328 in e69c8eb
| table_pointer_maps = { | |
| i: [ | |
| idx | |
| for col in desc['table_to_columns'][str(i)] | |
| for idx in column_pointer_maps[col] | |
| ] + list(range(left + c_enc_length, right + c_enc_length)) | |
| for i, (left, right) in enumerate(zip(t_boundaries, t_boundaries[1:])) | |
| } |
However, when computing the prev_action_emb, we only use the first of these embeddings (i.e. the first column of the table):
seq2struct/seq2struct/models/nl2code/decoder.py
Lines 501 to 516 in e69c8eb
| pointer_map = desc_enc.pointer_maps.get(parent_field_type) | |
| if pointer_map: | |
| values = pointer_map[node] | |
| if self.sup_att == '1h': | |
| if len(pointer_map) == len(enc_input['columns']): | |
| if self.attn_type != 'sep': | |
| traversal.step(values[0], values[1:], node + len(enc_input['question'])) | |
| else: | |
| traversal.step(values[0], values[1:], node) | |
| else: | |
| if self.attn_type != 'sep': | |
| traversal.step(values[0], values[1:], node + len(enc_input['question']) + len(enc_input['columns'])) | |
| else: | |
| traversal.step(values[0], values[1:], node + len(enc_input['columns'])) | |
| else: | |
| traversal.step(values[0], values[1:]) |
seq2struct/seq2struct/models/nl2code/decoder.py
Line 1263 in e69c8eb
| self.update_prev_action_emb = TreeTraversal._update_prev_action_emb_pointer |
seq2struct/seq2struct/models/nl2code/decoder.py
Lines 1465 to 1468 in e69c8eb
| def _update_prev_action_emb_pointer(cls, self, last_choice, extra_choice_info): | |
| # TODO batching | |
| self.prev_action_emb = self.model.pointer_action_emb_proj[self.cur_item.node_type]( | |
| self.desc_enc.pointer_memories[self.cur_item.node_type][:, last_choice]) |
seq2struct/seq2struct/models/nl2code/decoder.py
Line 1442 in e69c8eb
| self.update_prev_action_emb(self, last_choice, extra_choice_info) |