[BugFix] Fix handling of stop strings and stop token ids (#3672)

This commit is contained in:
Nick Hill
2024-04-11 23:34:12 +01:00
committed by GitHub
parent 1e96c3341a
commit e46a60aa4c
8 changed files with 206 additions and 41 deletions

View File

@@ -235,6 +235,12 @@ class Sequence:
def lora_int_id(self) -> int:
return self.lora_request.lora_int_id if self.lora_request else 0
def get_output_text_to_return(self, buffer_length: int):
# We return the full output text if the sequence is finished.
truncate = buffer_length and not self.is_finished()
return self.output_text[:-buffer_length] if truncate else (
self.output_text)
def hash_of_block(self, logical_idx: int) -> int:
# TODO This can produce incorrect hash when block size > prompt size