paper(OneBit: Towards Extremely Low-bit Large Language Models)

rank-1 approximation

奇异值分解

取最大的奇异值(),和最大的奇异值对应的左奇异向量和右奇异向量

(《Foundations of Data Science》的3.5节证明了这样分解是Frobenius范数下最好的秩1分解,证明我还没看)

,其中 ,(符号和绝对值的 Hadamard 积)

(把绝对值矩阵做秩 1 分解)

proposition 1


这个命题的是为了得到想到的网络结构。其中赋给模型架构里的,赋给。操作表示对进行广播(是一个行向量,广播的意思就是把一行一行重复地排列下去,直到和X的形状一样。),然后和X作hadamard积。

proof

, where is the element of . Hence we have

lemma 1

Let denote the -th biggest singular value of matrix . The following inequality holds:

Proof

According to the definition of induced norm, there are

Note that for and we have

因为我们总是可以让y取x的绝对值,所以:

This lemma is proved.

proposition 2

Given matrices and , . We decompose these matrices in the way and , where denotes the error matrices. In terms of the Frobenius-norm, the SVID is closer to the original matrix :

这个命题主要想说,在Frobenius范数意义下,先取绝对值再分解比直接分解的误差小。

proof

Here we consider SVD to prove it. For SVD, the norm of the error matrix in the rank1 approximation is the sum of the squares of all singular values except for the largest one. We have

u和v是U和V里的奇异向量,, 且u和v都是单位向量。,所以

然后使用迹技巧

所以

因为矩阵的Frobenius范数的平方等于矩阵的所有奇异值的平方和,即

所以误差矩阵的Frobenius范数的平方等于除了最大奇异值的其他所有奇异值的平方和。

Based on , we have

According to Lemma 1, we can conclude

From the equation in this proposition, we can formulate

Hence we have

Therefore

where is the element of . Hence the inequation in this proposition is proved.

知识蒸馏

这里就是用命题1得到的Y的表达式。

where denotes the number of classes and denotes the number of training samples in the current batch. and are the teacher model and student model, respectively. The error of hidden states is defined as

where denotes the number of layers and denotes the hidden state. Hence the final objective function can be formulated as

使得学生模型在输出上接近教师模型。
使得学生模型在隐藏状态上接近教师模型。