MCPcopy Create free account
hub / github.com/csuhan/OneLLM / encode

Method encode

model/tokenizer.py:30–37  ·  view source on GitHub ↗
(self, s: str, bos: bool, eos: bool)

Source from the content-addressed store, hash-verified

28 assert self.sp_model.vocab_size() == self.sp_model.get_piece_size()
29
30 def encode(self, s: str, bos: bool, eos: bool) -> List[int]:
31 assert type(s) is str
32 t = self.sp_model.encode(s)
33 if bos:
34 t = [self.bos_id] + t
35 if eos:
36 t = t + [self.eos_id]
37 return t
38
39 def decode(self, t: List[int]) -> str:
40 return self.sp_model.decode(t)

Callers 5

generateMethod · 0.80
stream_generateMethod · 0.80
__getitem__Method · 0.80
__getitem__Method · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected