MCPcopy Create free account
hub / github.com/ml-explore/mlx-examples / encode

Method encode

t5/t5.py:31–38  ·  view source on GitHub ↗
(self, s: str)

Source from the content-addressed store, hash-verified

29 return self._decoder_start_id
30
31 def encode(self, s: str) -> mx.array:
32 return mx.array(
33 self._tokenizer(
34 s,
35 return_tensors="np",
36 return_attention_mask=False,
37 )["input_ids"]
38 )
39
40 def decode(self, t: List[int], with_sep: bool = True) -> str:
41 tokens = self._tokenizer.convert_ids_to_tokens(t)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected