Skip to content

Commit

Permalink
fix lm bug (#122)
Browse files Browse the repository at this point in the history
Co-authored-by: hermanyu <[email protected]>
  • Loading branch information
yuzhangogogo and hermanyu authored Jan 24, 2024
1 parent 817a1b2 commit 1dc9dd1
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions tencentpretrain/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,8 @@ def __init__(self, args):
def forward_propagation(self, batch, model):
src, tgt_out, seg, tgt_in, tgt_seg = batch
loss_info = model(src, tgt_out, seg, tgt_in, tgt_seg)
loss, correct, denominator = loss_info
loss = loss_info
self.total_loss += loss.item()
self.total_correct += correct.item()
self.total_denominator += denominator.item()

loss = loss / self.accumulation_steps

Expand All @@ -464,13 +462,11 @@ def report_and_reset_stats(self):

self.logger.info("| {:8d}/{:8d} steps"
"| {:8.2f} tokens/s"
"| loss {:7.2f}"
"| acc: {:3.3f}".format(
"| loss {:7.2f}".format(
self.current_step,
self.total_steps,
done_tokens / (time.time() - self.start_time),
self.total_loss / self.report_steps,
self.total_correct / self.total_denominator))
self.total_loss / self.report_steps))

self.total_loss = 0.0
self.total_correct = 0.0
Expand Down

0 comments on commit 1dc9dd1

Please sign in to comment.