guidance.models.Mock

class guidance.models.Mock(byte_patterns=None, sampling_params: SamplingParams | None = None, echo=False, force=False, **kwargs)
__init__(byte_patterns=None, sampling_params: SamplingParams | None = None, echo=False, force=False, **kwargs)

Build a new Mock model object that represents a model in a given state.

Methods

__init__([byte_patterns, sampling_params, ...])

Build a new Mock model object that represents a model in a given state.

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).