From c0795de2f2c0beded136aa058f963dc1e341177a Mon Sep 17 00:00:00 2001 From: OlivierDehaene Date: Thu, 9 Mar 2023 13:00:10 +0100 Subject: [PATCH] fix(server): do not warp prefill logits (#116) --- server/text_generation_server/utils/tokens.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/text_generation_server/utils/tokens.py b/server/text_generation_server/utils/tokens.py index 1556376..c759464 100644 --- a/server/text_generation_server/utils/tokens.py +++ b/server/text_generation_server/utils/tokens.py @@ -75,7 +75,11 @@ class NextTokenChooser: def __call__(self, input_ids, scores): # Warp logits - scores = self.warpers(input_ids, scores) + if scores.shape[0] > 1: + # only warp the last token logits + scores[-1:, :] = self.warpers(input_ids, scores[-1:, :]) + else: + scores = self.warpers(input_ids, scores) # Compute logprobs logprobs = torch.log_softmax(scores, -1)