MCPcopy Create free account
hub / github.com/abetlen/llama-cpp-python / _sample_token

Method _sample_token

examples/server/server.py:1374–1383  ·  view source on GitHub ↗
(self, output_index: int = 0, *, seq_id: int = 0)

Source from the content-addressed store, hash-verified

1372 return 1.0 / total >= self.p_min
1373
1374 def _sample_token(self, output_index: int = 0, *, seq_id: int = 0) -> Optional[int]:
1375 if seq_id < 0 or seq_id >= len(self._samplers):
1376 return None
1377 if not self._passes_p_min(output_index):
1378 return None
1379 sampler = self._samplers[seq_id]
1380 token = int(llama_cpp.llama_sampler_sample(sampler, self.ctx, output_index))
1381 if token == llama_cpp.LLAMA_TOKEN_NULL:
1382 return None
1383 return token
1384
1385 def _reset_sampler(self, seq_id: int) -> None:
1386 if 0 <= seq_id < len(self._samplers):

Callers 5

_draft_chain_headsMethod · 0.95
draftMethod · 0.95
draft_manyMethod · 0.95

Calls 1

_passes_p_minMethod · 0.95

Tested by

no test coverage detected