MCPcopy Create free account
hub / github.com/microsoft/Cream / encode

Method encode

TinyCLIP/src/open_clip/tokenizer.py:139–147  ·  view source on GitHub ↗
(self, text)

Source from the content-addressed store, hash-verified

137 return word
138
139 def encode(self, text):
140 bpe_tokens = []
141 text = whitespace_clean(basic_clean(text)).lower()
142 for token in re.findall(self.pat, text):
143 token = ''.join(self.byte_encoder[b]
144 for b in token.encode('utf-8'))
145 bpe_tokens.extend(self.encoder[bpe_token]
146 for bpe_token in self.bpe(token).split(' '))
147 return bpe_tokens
148
149 def decode(self, tokens):
150 text = ''.join([self.decoder[token] for token in tokens])

Callers 7

collect_resultsFunction · 0.80
collect_results_cpuFunction · 0.80
get_seg_masksMethod · 0.80
flowwriteFunction · 0.80
updateMethod · 0.80
tokenizeFunction · 0.80

Calls 3

bpeMethod · 0.95
whitespace_cleanFunction · 0.85
basic_cleanFunction · 0.85

Tested by 2

collect_resultsFunction · 0.64
collect_results_cpuFunction · 0.64