Skip to content

Multiply Difference

ljleb edited this page Jun 9, 2023 · 14 revisions

Multiply difference preserves the shared characteristics between two models $A$ and $B$, with respect to a third model $C$ used as the origin of the operation. It emphasizes the common traits between models $A$ and $B$, discarding weights that disagree.

The formulae for multiply difference is:

$$M = C + S(|A - C|^{1-\alpha} \times |B - C|^\alpha, (1 - \beta) \times A + \beta B - C)$$

Where $S(v, u)$ copies the signs of $u$ and applies them to $v$ element-wise.

When a particular parameter in $A$ has a very small difference with the corresponding parameter in $C$, then the multiplication ensures that the corresponding parameter difference between $B$ and $C$ becomes smaller. The same applies from $B$ to $A$. The multiplication between the two differences produces a squared difference, which the square root turns back into a linear difference.

A parallel with logic can be drawn for this method. In some contexts, addition and logical OR are used interchangeably. Similarly, multiplication and logical AND can sometimes have the same meaning. Looking at it this way, multiply difference can be seen as an AND operation on the traits of $A$ and $B$ relative to $C$.

Examples

$A$: GhostMix civitai

$B$: Lyriel civitai

$C$: Realistic Vision v2.0 civitai

$\alpha$: 0.5

$\beta$: 0.0

Generation params:

stellar night of sparkling micro explosions, end of the world, massive yzyoljxv, best quality, 8k, deep emotional catastrophe, masterpiece
Negative prompt: worst quality low resolution draft, monochrome, movie title
Steps: 30, Sampler: DPM++ 2M Karras, CFG scale: 7, Seed: 3027539060, Size: 512x512, Model hash: d7465e52e1, Model: ghostmix_v12, Denoising strength: 0.5, Hires upscale: 2, Hires steps: 20, Hires upscaler: 4x_DPED, Script: X/Y/Z plot, X Type: Checkpoint name, X Values: "ghostmix_v12.safetensors [d7465e52e1],lyriel_v16.safetensors [ec6f68ea63],Realistic_Vision_V1.4.safetensors [21c6d51e3e],wiki_muldif.safetensors"

image

Special Cases

C > B > A

If $C$ is a base of $B$ and $B$ is a base of $A$, then $B$ will filter any weight in $A$ that diverges from $C$. In this case, $B$ will act as a kind of filter on $A$.

A = B

By putting the same model for $A$ and $B$, we get $A$:

$$C + S(|A - C|^{1 - \alpha} \times |A - C|^\alpha, (1 - \beta) \times A + \beta A - C)$$

$$= C + S(|A - C|^{1 - \alpha + \alpha}, A - C)$$

$$= C + S(|A - C|, A - C)$$

$$= C + A - C$$

$$= A$$

Clone this wiki locally