MCPcopy Create free account
hub / github.com/kyegomez/BitNet / generate

Method generate

bitnet/inference.py:56–65  ·  view source on GitHub ↗

Generates a sequence of tokens based on the input string.

(self, input_str, length)

Source from the content-addressed store, hash-verified

54 return "".join(list(map(BitNetInference.decode_token, tokens)))
55
56 def generate(self, input_str, length):
57 """Generates a sequence of tokens based on the input string."""
58 inp = (
59 torch.from_numpy(np.fromstring(input_str, dtype=np.uint8))
60 .long()
61 .to(self.device)
62 )
63 sample = self.model.generate(inp[None, ...], length)
64 output_str = self.decode_tokens(sample[0])
65 return output_str

Callers

nothing calls this directly

Calls 1

decode_tokensMethod · 0.95

Tested by

no test coverage detected