starling.inference.constraints.MultiConstraint

class MultiConstraint[source]

Bases: Constraint

Combines multiple constraints into a single optimization step.

Methods

__init__

apply

Apply the constraint to the given latents.

bell_shaped_schedule

Bell-shaped schedule for time-dependent guidance strength.

compute_loss

Compute weighted combination of all constraint losses.

cosine_weight

Cosine schedule for time-dependent guidance strength.

get_adaptive_clip_threshold

Get an adaptive clipping threshold that follows a cosine schedule.

get_time_scale

Get the time-dependent scaling factor.

initialize

Initialize all constraints with the model parameters.

should_apply_guidance

Check if guidance should be applied at the current timestep.

__init__(constraints, schedule='cosine', verbose=True)[source]
Parameters:
  • constraints (list) – List of constraint objects to combine

  • constraint_weights (list, optional) – Relative weights for each constraint (defaults to equal weights)

  • guidance_scale (float) – Overall guidance scale for the combined constraint

  • schedule (str) – Time schedule for constraint application (“cosine” or “linear”)

  • verbose (bool) – Whether to print debug info

initialize(encoder_model, latent_space_scaling_factor, n_steps, sequence_length)[source]

Initialize all constraints with the model parameters.

compute_loss(distance_maps: Tensor) Tuple[Tensor, Tensor][source]

Compute weighted combination of all constraint losses.