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

Method encode

llms/speculative_decoding/decoder.py:25–34  ·  view source on GitHub ↗
(self, s: str)

Source from the content-addressed store, hash-verified

23 return self._decoder_start_id
24
25 def encode(self, s: str) -> mx.array:
26 return mx.array(
27 self._tokenizer(
28 s,
29 return_tensors="np",
30 return_attention_mask=False,
31 )[
32 "input_ids"
33 ].squeeze(0)
34 )
35
36 def decode(self, t: List[int]) -> str:
37 return self._tokenizer.decode(t)

Callers 2

generateMethod · 0.45
speculative_decodeMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected