MCPcopy
hub / github.com/mlfoundations/open_clip / decode

Method decode

src/open_clip/tokenizer.py:221–224  ·  view source on GitHub ↗
(self, tokens)

Source from the content-addressed store, hash-verified

219 return bpe_tokens
220
221 def decode(self, tokens):
222 text = ''.join([self.decoder[token] for token in tokens])
223 text = bytearray([self.byte_decoder[c] for c in text]).decode('utf-8', errors="replace").replace('</w>', ' ')
224 return text
225
226 def __call__(self, texts: Union[str, List[str]], context_length: Optional[int] = None) -> torch.LongTensor:
227 """ Returns the tokenized representation of given input string(s)

Callers 6

__init__Method · 0.80
decodeFunction · 0.80
remote_sync_s3Function · 0.80
get_wds_datasetFunction · 0.80
get_latest_checkpointFunction · 0.80
mainFunction · 0.80

Calls

no outgoing calls

Tested by 1

mainFunction · 0.64