MCPcopy Create free account
hub / github.com/Alpha-VLLM/LLaMA2-Accessory / encode

Method encode

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

Source from the content-addressed store, hash-verified

50 )
51
52 def encode(self, s: str, bos: bool, eos: bool) -> List[int]:
53 assert type(s) is str
54 if self.tokenizer_type == "transformers":
55 t = self.tokenizer.encode(s, truncation=False, add_special_tokens=False)
56 else:
57 t = self.tokenizer.encode(s)
58 if bos:
59 t = [self.bos_id] + t
60 if eos:
61 t = t + [self.eos_id]
62 return t
63
64 def encode_segment(self, s:str):
65 s = s.lstrip(' ')

Callers 15

encode_segmentMethod · 0.95
resize_promptFunction · 0.80
resize_promptFunction · 0.80
extract_ans_by_logitsFunction · 0.80
resize_promptFunction · 0.80
resize_promptFunction · 0.80
extract_ans_by_logitsFunction · 0.80
resize_promptFunction · 0.80
resize_promptFunction · 0.80
mainFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected