Skip to content
View as Markdown

tinker.types.SampledSequence

Generated from tinker 0.30.4 at commit 1e5777e. Source links point at that snapshot.

class tinker.types.SampledSequence()

A single sampled sequence from the model.

Provides two ways to access token data:

  • Numpy arrays (tokens_np, logprobs_np): As numpy arrays without format conversion.

  • Python lists (tokens, logprobs): Standard Python lists, converted lazily on first access.

Fields:

  • stop_reason (StopReason) – Reason why sampling stopped.
  • sequence_id (str) – Session-scoped identifier, distinct per sequence; use it wherever a later request needs to reference this exact sequence.
  • tokens_np (Optional[np.ndarray]) – Generated token IDs as a 1-D int32 numpy array, shape (num_tokens,).
  • logprobs_np (Optional[np.ndarray]) – Log probabilities for each generated token as a 1-D float32 numpy array, shape (num_tokens,). None if logprobs were not requested.
  • topk_logprobs_np (Optional[TopkLogprobs]) – Top-k logprobs at each generated position as a pair of dense (num_tokens, k) matrices (see TopkLogprobs). None if SampleRequest.topk_sample_logprobs was not requested.

tokens()

Generated token IDs as a Python list.

Converted from tokens_np on first access (cached afterwards).

Returns: List[int]

logprobs()

Log probabilities for each generated token (optional).

None if logprobs were not requested. Converted from logprobs_np on first access (cached afterwards).

Returns: Optional[List[float]]

topk_logprobs()

Top-k logprobs at each generated position as nested Python lists.

If SampleRequest.topk_sample_logprobs was set to a positive integer k in the request, each generated position gets a list of up to k (token_id, logprob) tuples, or None where the engine reported nothing. Returns None if top-k was not requested.

Converted from topk_logprobs_np on first access (cached afterwards).

Returns: Optional[List[Optional[List[tuple[int, float]]]]]

Referenced by