Closed urialon closed 2 years ago
Hi, maybe we don't need move the Beam
initialization. By changing
past = [torch.cat([x[0].unsqueeze(0),x[1].unsqueeze(0)],dim=0) if type(x)==tuple else x for x in outputs]
past_hidden = [x.data.index_select(1, beam.getCurrentOrigin()) for x in past]
to
past = [torch.cat([x[0].unsqueeze(0),x[1].unsqueeze(0)],dim=0) if type(x)==tuple else x for x in outputs]
past_hidden = [x[:, i:i+1].expand(-1, beam_size, -1, -1, -1) for x in past]
Then it works.
BTW, I have commit this changes to the file https://github.com/microsoft/CodeXGLUE/commit/78e6812a3315c6096b764048e8235d592c00da35
Thank you for the quick response!
Hi, Thank you for releasing this project!
I got an error while running line-completion evaluation using the command line here: https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/CodeCompletion-line#inference
Then I found a past issue ( https://github.com/microsoft/CodeXGLUE/issues/74#issuecomment-990986297 ) where @LIANGQINGYUAN suggested changing this line https://github.com/microsoft/CodeXGLUE/blob/main/Code-Code/CodeCompletion-line/code/run_lm.py#L376 from:
to this:
However, this change requires also moving the initialization of the
Beam
object from https://github.com/microsoft/CodeXGLUE/blob/main/Code-Code/CodeCompletion-line/code/run_lm.py#L377 to before the change to thepast_hidden
line. If I fix this by moving up thebeam
initialization, I encounter another error:any advice? Thanks!