guidance.models.Model

class guidance.models.Model(interpreter: Interpreter[S], sampling_params: SamplingParams, echo: bool = True)
__init__(interpreter: Interpreter[S], sampling_params: SamplingParams, echo: bool = True) None

Methods

__init__(interpreter, sampling_params[, echo])

copy()

get(key[, default])

Return the value of a variable, or a default value if the variable is not present.

log_prob(key[, default])

Return the log probability of a variable, or a default value if the variable is not present.

remove(key)

Return a new model with the given variable deleted.

set(key, value)

Return a new model with the given variable value set.

stream()

Return a new model stream object that delays execution until it is iterated over.

with_sampling_params(sampling_params)

Return a new model with the given sampling parameters set.

with_step_config(step_config)

Return a new model with step interjection configured (engine-backed models only).

get(key: str, default: D | None = None) str | list[str] | None | D

Return the value of a variable, or a default value if the variable is not present.

Parameters:
keystr

The name of the variable.

defaultAny

The value to return if the variable is not current set.

log_prob(key: str, default: D | None = None) float | list[float | None] | None | D

Return the log probability of a variable, or a default value if the variable is not present.

Parameters:
keystr

The name of the variable.

defaultAny

The value to return if the variable is not current set.

remove(key: str) Self

Return a new model with the given variable deleted.

Parameters:
keystr

The variable name to remove.

set(key: str, value: str | list[str]) Self

Return a new model with the given variable value set.

Parameters:
keystr

The name of the variable to be set.

valuestr

The value to set the variable to.

stream() ModelStream

Return a new model stream object that delays execution until it is iterated over.

with_sampling_params(sampling_params: SamplingParams) Self

Return a new model with the given sampling parameters set.

with_step_config(step_config: StepConfig) Self

Return a new model with step interjection configured (engine-backed models only).