mixle.inference.synthesize module

Verified synthetic dataset creation.

synthesize draws inputs from a generative source, optionally labels them with a teacher callable, and optionally filters them through a verifier. The result is a Dataset that carries its verifier so consumers can recheck rows independently.

Supported sources include:

  • a fitted model with a sampler;

  • a list of real inputs, from which a generator is inferred and sampled;

  • a callable () -> input or rng -> input.

Without label the result is unlabeled. Without verify every draw is accepted. max_tries bounds rejection sampling so an impossible verifier returns a clear failure instead of looping indefinitely.

class Dataset(inputs, labels=None, verify=None, acceptance_rate=1.0, n_rejected=0, provenance=<factory>)[source]

Bases: object

A verified synthetic dataset: inputs, optional labels, and the verifier that vouched for them.

Parameters:
inputs: list[Any]
labels: list[Any] | None = None
verify: Callable[[...], bool] | None = None
acceptance_rate: float = 1.0
n_rejected: int = 0
provenance: dict[str, Any]
pairs()[source]

(input, label) pairs – raises if the dataset is unlabeled.

Return type:

list[tuple[Any, Any]]

recheck()[source]

Re-run the attached verifier over every row.

Returns True when every row still passes, or when no verifier is attached.

Return type:

bool

synthesize(source, *, label=None, verify=None, n=100, max_tries=None, seed=0)[source]

Build a verified dataset of n accepted rows from a generative source (see module docstring).

source is a fitted model (sampled), a list of real inputs (a generator is inferred over them), or a callable draw function. label (optional) is the teacher applied to each input. verify (optional) accepts verify(x) or verify(x, label) and gates each row – rejected rows are resampled up to max_tries total draws. The verifier is attached to the returned Dataset so consumers can recheck() independently.

Parameters:
Return type:

Dataset