MCPcopy
hub / github.com/tinygrad/tinygrad / encode

Method encode

extra/models/t5.py:46–49  ·  view source on GitHub ↗
(self, text:str, max_length:int)

Source from the content-addressed store, hash-verified

44 self.spp = SentencePieceProcessor(str(spiece_path))
45
46 def encode(self, text:str, max_length:int) -> List[int]:
47 encoded = self.spp.Encode(text)
48 if len(encoded) > max_length - 1: encoded = encoded[:max_length - 1]
49 return encoded + [1] + [0]*(max_length - len(encoded) - 1)
50
51class T5LayerNorm:
52 def __init__(self, hidden_size:int, eps:float=1e-6):

Callers 10

loadMethod · 0.45
saveMethod · 0.45
resp_errFunction · 0.45
handleFunction · 0.45
wregMethod · 0.45
programMethod · 0.45
isa_cbFunction · 0.45
upload_raid.pyFile · 0.45
__call__Method · 0.45
_compute_lossMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected