Skip to content

Commit 20f0c2b

Browse files
committed
Hint Generator type
1 parent 8ccb10a commit 20f0c2b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tokenizer/rwkv_tokenizer.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ def printTokens(self, tokens):
217217
# Tokenizer #4 (fast) https://github.com/LoganDark
218218
########################################################################################################
219219

220+
from typing import Generator
220221
from ast import literal_eval
221222

222223
class FastTokenizer:
@@ -255,7 +256,7 @@ def next_token(self, src: bytes) -> int:
255256
break
256257
return last_token
257258

258-
def encode_bytes(self, src: bytes) -> list[int]:
259+
def encode_bytes(self, src: bytes) -> Generator[int, None, None]:
259260
start, stop = 0, len(src)
260261
while start < stop:
261262
last_token, last = None, self.root
@@ -274,7 +275,7 @@ def encode_bytes(self, src: bytes) -> list[int]:
274275
def decode_bytes(self, tokens: list[int]) -> bytes:
275276
return b''.join(map(self.tok2val.__getitem__, tokens))
276277

277-
def encode(self, src: str) -> list[int]:
278+
def encode(self, src: str) -> Generator[int, None, None]:
278279
return self.encode_bytes(src.encode('utf-8'))
279280

280281
def decode(self, tokens: list[int]) -> str:

0 commit comments

Comments
 (0)