MCPcopy Create free account
hub / github.com/NVIDIA/FasterTransformer / encode

Method encode

examples/pytorch/gpt/utils/gpt_token_encoder.py:134–139  ·  view source on GitHub ↗
(self, text)

Source from the content-addressed store, hash-verified

132 return word
133
134 def encode(self, text):
135 bpe_tokens = []
136 for token in re.findall(self.pat, text):
137 token = ''.join(self.byte_encoder[b] for b in token.encode('utf-8'))
138 bpe_tokens.extend(self.encoder[bpe_token] for bpe_token in self.bpe(token).split(' '))
139 return bpe_tokens
140
141 def decode(self, tokens):
142 text = ''.join([self.decoder[token] for token in tokens])

Callers 13

url_to_filenameFunction · 0.45
translateMethod · 0.45
mainFunction · 0.45
tokenizeMethod · 0.45
summarize_ft_e2eFunction · 0.45
summarize_ft_sepFunction · 0.45
summarize_hfFunction · 0.45
summarize_ft_e2eFunction · 0.45
summarize_ft_sepFunction · 0.45
summarize_hfFunction · 0.45
to_word_list_formatFunction · 0.45
summarize_hfFunction · 0.45

Calls 1

bpeMethod · 0.95

Tested by

no test coverage detected