MCPcopy Create free account
hub / github.com/PaddlePaddle/Research / encode

Method encode

NLP/UNIMO-2/src/model/roberta_tokenization.py:211–217  ·  view source on GitHub ↗

bpe encoding

(self, text)

Source from the content-addressed store, hash-verified

209 return word
210
211 def encode(self, text):
212 """bpe encoding"""
213 bpe_tokens = []
214 for token in re.findall(self.pat, text):
215 token = ''.join(self.byte_encoder[b] for b in token.encode('utf-8'))
216 bpe_tokens.extend(self.encoder[bpe_token] for bpe_token in self.bpe(token).split(' '))
217 return bpe_tokens
218
219 def decode(self, tokens):
220 """bpe decoding"""

Callers 3

printable_textFunction · 0.45
tokenizeMethod · 0.45
test_gpt_bpe_tokenizerFunction · 0.45

Calls 2

bpeMethod · 0.95
extendMethod · 0.80

Tested by 1

test_gpt_bpe_tokenizerFunction · 0.36