Generates a sequence of tokens based on the input string.
(self, input_str, length)
| 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 |
nothing calls this directly
no test coverage detected