Skip to content

tinker_cookbook.completers.TinkerTokenCompleter

class tinker_cookbook.completers.TinkerTokenCompleter(TokenCompleter)

Token completer that uses a tinker.SamplingClient to sample actions.

completer = TinkerTokenCompleter(sampling_client, max_tokens=512)
result = await completer(model_input, stop=["<|endoftext|>"])
print(result.tokens, result.logprobs)

Fields:

__call__(model_input, stop, max_tokens)

Sample an action from the policy given an observation.

A per-call max_tokens override is combined with the completer's own max_tokens by taking the minimum, and the context_window cap (when configured) still applies on top.

Parameters:

Returns: TokensWithLogprobs