(self, *, n_vocab: int)
| 529 | |
| 530 | class LlamaTokenDataArray: |
| 531 | def __init__(self, *, n_vocab: int): |
| 532 | self.n_vocab = n_vocab |
| 533 | self.candidates_data = np.recarray( |
| 534 | (self.n_vocab,), |
| 535 | dtype=np.dtype( |
| 536 | [("id", np.intc), ("logit", np.single), ("p", np.single)], align=True |
| 537 | ), |
| 538 | ) |
| 539 | self.candidates = llama_cpp.llama_token_data_array( |
| 540 | data=self.candidates_data.ctypes.data_as(llama_cpp.llama_token_data_p), |
| 541 | size=self.n_vocab, |
| 542 | sorted=False, |
| 543 | ) |
| 544 | self.default_candidates_data_id = np.arange(self.n_vocab, dtype=np.intc) # type: ignore |
| 545 | self.default_candidates_data_p = np.zeros(self.n_vocab, dtype=np.single) |
| 546 | self.sampler = None # LlamaTokenDataArray doesn't use samplers, but some cleanup code expects this attribute |
| 547 | |
| 548 | def copy_logits(self, logits: npt.NDArray[np.single]): |
| 549 | self.candidates_data.id[:] = self.default_candidates_data_id |
nothing calls this directly
no outgoing calls
no test coverage detected