Fix remaining issues in beam score calculation (#27808)

* Fix issues in add and is_done for BeamHypotheses

* make newly added arguments optional for better compatibility

* Directly use cur_len as generated_len, add note for retrocompatibility

* update test expectation

* make cur_len represents the length of the entire sequence including the decoder prompt

* remove redundant if/else in testing
This commit is contained in:
Xin Qiu
2023-12-08 21:14:16 +08:00
committed by GitHub
parent 3ac9945e56
commit b31905d1f6
3 changed files with 31 additions and 34 deletions

View File

@@ -800,7 +800,7 @@ class ViT2GPT2ModelIntegrationTest(unittest.TestCase):
preds, scores = generate_step(pixel_values)
EXPECTED_SCORES = np.array([-0.64145195])
EXPECTED_SCORES = np.array([-0.5956343])
max_diff = np.amax(np.abs(scores - EXPECTED_SCORES))
self.assertLessEqual(max_diff, 1e-4)