API Reference#

Completion After Prompt Probability. Make your LLM make a choice

https://cappr.readthedocs.io/

class cappr.Example(prompt: str, completions: Sequence[str], prior: Sequence[float] | None = None, end_of_prompt: Literal[' ', ''] = ' ', normalize: bool = True)[source]#

Bases: object

Represents a single prompt-completion task.

This data structure is only useful if different prompts correspond to a different set of possible choices/completions, and you want to run the model in batches for greater throughput.

Parameters:
  • prompt (str) – string, which, e.g., contains the text to classify

  • completions (Sequence[str]) – strings, where, e.g., each one is the name of a class which could come after the prompt

  • prior (Sequence[float] | None, optional) – a probability distribution over completions, representing a belief about their likelihoods regardless of the prompt. By default, each completion in completions is assumed to be equally likely

  • end_of_prompt (Literal[' ', ''], optional) – whitespace or empty string to join prompt and completion, by default whitespace

  • normalize (bool | None, optional) – whether or not to normalize completion-after-prompt probabilities into a probability distribution over completions. Set this to False if you’d like the raw completion-after-prompt probability, or you’re solving a multi-label prediction problem. By default, True

completions: Sequence[str]#
end_of_prompt: Literal[' ', ''] = ' '#
normalize: bool = True#
prior: Sequence[float] | None = None#
prompt: str#