@@ -112,7 +112,7 @@ def __init__(
112
112
self .stop_sequence_criterias = stop_sequence_criterias
113
113
self .max_new_tokens = max_new_tokens
114
114
self .current_tokens = 0
115
- self .current_output = "test "
115
+ self .current_output = ""
116
116
self .ignore_eos_token = ignore_eos_token
117
117
118
118
def __call__ (self , last_token : int , last_output : str ) -> Tuple [bool , Optional [str ]]:
@@ -123,14 +123,15 @@ def __call__(self, last_token: int, last_output: str) -> Tuple[bool, Optional[st
123
123
if not self .ignore_eos_token and last_token == self .eos_token_id :
124
124
return True , FinishReason .FINISH_REASON_EOS_TOKEN
125
125
126
- self .current_output += last_output
127
- # There is no need to keep an output that is too long
128
- if len (self .current_output ) > 300 :
129
- # Slice to -200 to avoid doing it all the time
130
- self .current_output = self .current_output [- 200 :]
131
- for stop_sequence_criteria in self .stop_sequence_criterias :
132
- if stop_sequence_criteria (self .current_output ):
133
- return True , FinishReason .FINISH_REASON_STOP_SEQUENCE
126
+ if self .stop_sequence_criterias :
127
+ self .current_output += last_output
128
+ # There is no need to keep an output that is too long
129
+ if len (self .current_output ) > 300 :
130
+ # Slice to -200 to avoid doing it all the time
131
+ self .current_output = self .current_output [- 200 :]
132
+ for stop_sequence_criteria in self .stop_sequence_criterias :
133
+ if stop_sequence_criteria (self .current_output ):
134
+ return True , FinishReason .FINISH_REASON_STOP_SEQUENCE
134
135
135
136
return False , None
136
137
0 commit comments