Skip to content

Arbitrary prev_action_emb when pointer maps have multiple entries #25

@rshin

Description

@rshin

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:

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):

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:])

self.update_prev_action_emb = TreeTraversal._update_prev_action_emb_pointer

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])

self.update_prev_action_emb(self, last_choice, extra_choice_info)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions