                                     Model Immunization from a Condition Number Perspective

3.1. Analysis on Immunized Linear Models                                 Algorithm 1 Condition number regularized gradient descent
                                                                         for model immunization
To provide some intuition on how the feature extractor θ                 input Primary task DP = (XP , YP ), harmful task input
affects the convergence of linear probing, we study the                      XH , supervised loss L, learning rate η, regularizing
analytical form of the singular values of the Hessian. For                   constants λP , λH ∈ R+ , model initialization θ0 , ω0
readability, we will rewrite linear probing in Eq. (4) by                 1: KP = XP⊤ XP
considering fθ ≜ x⊤ θ and a ℓ2 -loss.                                     2: KH = XH⊤ XH
Let XH ∈ RN ×Din and YH ∈ RN ×Dout denote data from                       3: for t = 0, 1, . . . , T − 1 do
DH stacked into matrices with N ≜ |DH |. When using a                     4:   ωt+1 = ωt − η∇ω L(ωt , θt ; DP )
ℓ2 -loss, Eq. (4) can be written as                                       5:   HP (θt ) = θt⊤ KP θt , HH (θt ) = θt⊤ KH θt
                                                   2                      6:   θ t+1 = θt − η∇θ L(ωt , θt ; X1 )
       min L(DH , w, θ) = min ∥(XH θ)w − Y ∥2 .               (8)
        w                    w                                                            − ηλP KP−1 ∇θ Rwell (HP (θt ))
In this case, the Hessian matrix                                                                 −1
                                                                                          − ηλH KH  ∇θ Rill (HH (θt ))
                                                                          7: end for
         HH (θ) ≜ ∇2w L(DH , w, θ) = θ⊤ KH θ,                 (9)
                                                                         output Immunized feature extractor θI ≜ θT .
where KH ≜ XH⊤ XH is the data covariance matrix.
Proposition 3.2. The singular values of the Hessian matrix
in Eq. (9) are given by                                                  in Eq. (3) denotes the regularizer to minimize the condi-
                                                                         tion number, HP (θ) ≜ ∇2ω L(DP , ω, θ) = θ⊤ KP θ is the
       Din
       X                    √ 2                                         Hessian matrix of the pre-training task, and L denotes the
σi =         σθ,i (u⊤
                    θ,i qj ) γj  ,    ∀i ∈ {1, . . . , Din }. (10)
                                                                         supervised loss.
       j=1

Here, σθ,i and uθ,i correspond to the i-th singular value                Each of the terms encourages the model to satisfy the three
and vector of θ. Next, γj and qj correspond to the j-th                  immunization requirements in Definition 3.1. For readabil-
singular value and vector of the covariance K.                           ity, we have dropped the scalar hyperparameters balancing
                                                                         the terms. We propose to solve Eq. (11) using a gradient-
Proof sketch. This result can be shown by using the fact
                                                                         based method as outlined in Alg. 1.
that KH is a symmetric positive semi-definite matrix and
decomposing via SVD. The complete proof is provided in                   In the remainder of this section, we will first introduce the
Appendix B.1.                                          □                 novel regularizer to maximize general matrices’ condition
                                                                         number and their relevant properties (Sec. 4.1). We then
From Eq. (10), we can see that the singular value of the
                                                                         show how to incorporate the regularizers Rill and Rwell
Hessian depends on the relative angle between the singu-
                                                                         into the immunization setup (Sec. 4.2). Finally, we dis-
lar vectors between feature extractor θ and the covariance
                                                                         cuss the provable guarantees with respect to each of the
matrix of the data KH . As the feature extractor is shared
                                                                         regularizers (Sec. 4.3).
between the pretrained DP and harmful DH datasets, the
strength of the immunization depends on the relative angle
between the singular vectors of KP and KH . For exam-                    4.1. Regularizer for Maximizing the Condition Number
ple, if the singular vectors (sorted by the singular values)             We analyze the condition number of a general matrix S ∈
are all perfectly aligned between the two, then no θ can si-             Rpr ×pc , p = min{pr , pc }, and rank (S) = k ≤ p. The
multaneously maximize κ(∇2w L(DH , w, θ)) and minimize                   compact SVD of S is given by S = U Diag(σ)V ⊤ , in
κ(∇2ω L(DP , ω, θ)).                                                                                 ⊤           max
                                                                         which σ = [σ1 , · · · , σk ] such that σS   = σ1 ≥ σ2 ≥
With a better understanding of the effect of the feature ex-             · · · ≥ σk = σS > 0 and ui , vi denotes the ith column
                                                                                        min

tractor θ on the condition number, we will next present an               vector of U , V for i ∈ [k].
algorithm to immunize a model.                                           Inspired by the regularizer for minimizing the condition
                                                                         number, we propose its counterpart for maximizing the
4. Algorithm for Immunizing a Model                                      condition number

We formulate model immunization as an optimization prob-                                                 1
                                                                                  Rill (S) =                          ,          (12)
lem with the following objective:                                                               1    2   1   min 2
                                                                                               2k ∥S∥F − 2 (σS )
 min Rill (HH (θ)) + Rwell (HP (θ)) + L(DP , ω, θ), (11)
 ω,θ                                                                     which satisfies the properties in the following theorem.
where Rill , to be defined in Sec. 4.1, denotes our pro-                 Theorem 4.1 (Properties of κ-maximizing regularizer
posed regularizer to maximize the condition number, Rwell                Rill (S)).

                                                                     3
