论文 - Distilling the Knowledge in a Neural Network

论文 - Distilling the Knowledge in a Neural Network

YYk Lv2

论文信息

作者:

  • Geoffrey Hinton (Google Inc. and University of Toronto)
  • Oriol Vinyals (Google Inc.)
  • Jeff Dean (Google Inc.)

本文于2015年作为预印本发布,详见arXiv

这篇论文是 知识蒸馏 领域的开山之作。考虑到已有许多博客和解读,我将不做逐一分析,而是记录对我印象深刻的几点。


蒸馏

知识蒸馏(Knowledge Distilling) 是模型压缩的一种方法,旨在利用一个较复杂的Teacher模型来指导一个较轻量的Student模型训练,从而在减小模型大小和计算资源的同时,尽量保留原Teacher模型的准确率。这一方法因Hinton的论文Distilling the Knowledge in a Neural Network而受到广泛关注。

学习到的知识 == 参数 ?

以下是论文原文,也是我认为最重要的一段:

A conceptual block that may have prevented more investigation of this very promising approach is that we tend to identify the knowledge in a trained model with the learned parameter values and this makes it hard to see how we can change the form of the model but keep the same knowledge.
A more abstract view of the knowledge, that frees it from any particular instantiation, is that it is a learned mapping from input vectors to output vectors.

在我之前的学习中,常常默认的将模型大小、参数数量与模型学习的能力与知识划等号。但论文认为这两个概念不应当如此混淆

论文指出:将 知识学习到的参数值 混淆,这使得我们难以理解如何在改变模型形式时,仍能保持相同的知识。
对此,论文提出了一种更为抽象的 知识定义:知识应被视为 从输入向量到输出向量的映射,而不仅仅是模型的参数集合。

我目前对于所谓 知识(Knowledge) 的理解是:一组能够拟合目标分布的模型与参数。 海量的参数固然能够很好的拟合一组目标输入所隐藏的分布,但往往造成 过拟合 。 而所谓的知识蒸馏就是在减少参数量的同时也能保持大模型相似的能力(即也能拟合潜在的分布)并甚至提高泛化性。


side-effect : 相对概率

下面作者进一步指出了 知识蒸馏 的一个核心方法, 即使用大模型学习过程中的 副产品

For cumbersome models that learn to discriminate between a large number of classes, the normal training objective is to maximize the average log probability of the correct answer, but a side-effect of the learning is that the trained model assigns probabilities to all of the incorrect answers and even when these probabilities are very small, some of them are much larger than others. The relative probabilities of incorrect answers tell us a lot about how the cumbersome model tends to generalize. An image of a BMW, for example, may only have a very small chance of being mistaken for a garbage truck, but that mistake is still many times more probable than mistaking it for a carrot.

论文指出:对于需要区分大量类别的复杂模型,标准的训练目标是最大化正确答案的平均对数概率(即交叉熵损失函数)。这也是我之前所训练的大多数分类模型的策略。

然而,在学习过程会产生一些副产品是,训练后的模型会将概率分配给所有错误答案,即使这些概率非常小,其中一些错误答案的概率仍然比其他错误答案大得多。就比如在神经网络中的最后一层,利用Softmax函数,网络会将每个类别的原始输出值(logits)转化为一个概率分布。即使某些类别在给定输入上的预测概率较低,Softmax 也会分配一个非零的概率给它们。例如,在一个三分类问题中,即使模型对于某一类别的预测远低于其他类别,Softmax 仍然会给该类别一个概率值,而不是直接将其忽略。

这些 相对概率 提供了关于复杂模型如何 泛化 的重要信息。

举个例子,对于一张宝马车的图像,它可能只有很小的概率被误判为垃圾车,但这种错误的概率仍然远大于误判为胡萝卜的概率。这表明,复杂模型在泛化时如何做出判断,尤其是在面对相似的错误分类时,如何通过相对概率区分各个错误的可能性。


对协方差矩阵进行聚类

作者提到通过对模型预测结果的协方差矩阵进行聚类,从而实现类目聚类。具体来说,协方差矩阵是基于通用模型对类别的预测结果计算得到的,这些预测结果是模型的输出概率。然后,作者应用了K-means聚类算法,基于这些概率值的协方差矩阵对类目进行聚类,以便将经常预测混淆的类别分组,并为每个专业模型(specialist model)分配一个特定的类目子集。

尽管协方差矩阵并非核心内容,但其第一次见到在论文中利用协方差矩阵聚类,印象深刻。

之后预期将写一个与协方差矩阵及聚类有关的Blog

  • Title: 论文 - Distilling the Knowledge in a Neural Network
  • Author: YYk
  • Created at : 2025-05-03 19:18:49
  • Updated at : 2025-05-30 13:36:23
  • Link: https://yykwd.github.io/2025/05/03/Papers/Distilling the Knowledge in a Neural Network/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments