MCPcopy Create free account
hub / github.com/Pints-AI/1.5-Pints / decode

Method decode

lit_gpt/tokenizer.py:148–163  ·  view source on GitHub ↗
(
        self,
        tensor: Union[torch.Tensor, list],
        skip_special_tokens: Optional[bool] = None,
    )

Source from the content-addressed store, hash-verified

146 return torch.tensor(tokens, dtype=torch.int, device=device)
147
148 def decode(
149 self,
150 tensor: Union[torch.Tensor, list],
151 skip_special_tokens: Optional[bool] = None,
152 ) -> str:
153 if self.backend != HUGGINGFACE and skip_special_tokens is not None:
154 print(f'WARN: Using {self.backend} does not allow `skip_special_tokens`.')
155
156 tokens = tensor
157 if isinstance(tensor, torch.Tensor):
158 tokens = [tensor.item()] if tensor.ndim == 0 else tensor.tolist()
159
160 if skip_special_tokens is not None and self.backend == HUGGINGFACE:
161 return self.processor.decode(tokens, skip_special_tokens)
162
163 return self.processor.decode(tokens)

Callers 8

mainFunction · 0.95
get_lit_inferencesFunction · 0.95
setup_ignore_indexFunction · 0.95
test_deita_e2eFunction · 0.45
test_slim_orca_idk_e2eFunction · 0.45
test_metamath_e2eFunction · 0.45

Calls

no outgoing calls

Tested by 4

test_deita_e2eFunction · 0.36
test_slim_orca_idk_e2eFunction · 0.36
test_metamath_e2eFunction · 0.36