Knowledge Distillation for Closed-Source Language Models

Hongzhan Chen, Xiaojun Quan, Hehong Chen, Ming Yan, Ji Zhang · OpenReview

Abstract

Closed-source language models such as GPT-4 have achieved remarkable performance. Many recent studies focus on enhancing the capabilities of smaller models through knowledge distillation from closed-source language models. However, due to the incapability to directly access the weights, hidden states, and output distributions of these closed-source models, the distillation can only be performed by fine-tuning smaller models with data samples generated by closed-source language models, which constrains the effectiveness of knowledge distillation. In this paper, we propose to estimate the output distributions of closed-source language models within a Bayesian estimation framework, involving both prior and posterior estimation. The prior estimation aims to derive a prior distribution by utilizing the corpus generated by closed-source language models, while the posterior estimation employs a proxy model to update the prior distribution and derive a posterior distribution. By leveraging the estimated output distribution of closed-source language models, traditional knowledge distillation can be executed. Experimental results demonstrate that our method surpasses the performance of current models directly fine-tuned on data generated by closed-source language models.

Introduction

Knowledge Distillation (KD) is a critical technique for transferring the capabilities of large "teacher" models to smaller "student" models. In a traditional white-box setting, students benefit from access to the teacher's internal probability distributions (soft labels), which provide a richer learning signal than final text outputs (hard labels) alone. However, state-of-the-art models like GPT-4 are black-boxes, accessible only via APIs that withhold these distributions. Current black-box KD methods typically resort to simple fine-tuning on teacher-generated text, failing to capture the nuanced knowledge embedded in the teacher's decision-making process.

To address this, we introduce Proxy-KD, a framework that bridges the gap between proprietary black-box giants and open-source student models. By aligning a large open-source "proxy" model to the teacher's behavior, we can extract the soft labels necessary for high-fidelity distillation.

Methodology

The Proxy-KD framework operates in two primary stages:

  1. Proxy Model Alignment: A large open-source model (e.g., Llama-2-70B) is selected as a proxy. It is first fine-tuned on teacher outputs and then further refined using Direct Preference Optimization (DPO). This alignment ensures the proxy learns to mimic the teacher's style and logic, effectively acting as a "translator" that turns teacher text back into dense probability distributions.
  2. Student Knowledge Distillation: The student model (e.g., Llama-7B) is trained using a hybrid objective. It learns from the black-box teacher's hard labels and the aligned proxy's soft labels. To ensure robustness, a sample-level weighting mechanism prioritizes learning from samples where the proxy is most closely aligned with the teacher's response.
The Proxy-KD framework: Stage 1 aligns the proxy model to the black-box teacher, and Stage 2 uses the proxy to provide soft labels for student distillation.

Experimental Setup

We utilized a training corpus of 1 million samples from OpenOrca and Nectar, featuring GPT-4 generated instructions and comparisons. Evaluation was conducted across several challenging benchmarks, including BBH (reasoning), AGIEval (standardized tests), ARC-Challenge (science), MMLU (general knowledge), CSQA (commonsense), and GSM8K (math).

Key Results and Insights

Proxy-KD consistently outperforms vanilla black-box distillation and traditional white-box methods across all tested benchmarks.

Comparison of Proxy-KD against various white-box and black-box distillation baselines across six benchmarks.

As shown in the results table, a Llama-2-7B student trained via Proxy-KD achieved an average score of 56.78, a significant improvement over the 53.66 achieved by standard black-box fine-tuning. The gains were particularly pronounced in reasoning-heavy tasks like BBH, where the score jumped from 46.68 to 53.40.

Key insights from our experiments include:

  • Alignment is Crucial: Without DPO alignment, the proxy's internal logic differs too much from the teacher's, which can actually degrade student performance compared to simple fine-tuning.
  • Scaling the Proxy: Larger proxy models (e.g., 70B) are more effective at capturing teacher nuances than smaller ones (13B), leading to superior student performance.
  • Superiority over Open-Source Teachers: Proxy-KD even outperformed distilling directly from a Llama-2-70B-Chat white-box teacher, indicating that the knowledge "borrowed" from GPT-4 via the proxy is more valuable than the native knowledge of the open-source model.

Conclusion and Limitations

While Proxy-KD significantly advances black-box distillation, it introduces computational overhead due to the need for a large proxy model during training. Future work will explore the framework's effectiveness across diverse model architectures beyond the Llama series and investigate methods to reduce the inference costs associated with the proxy model during the distillation phase.

Summary updated

BibTeX
@misc{chen2024knowledge,
  author = {Hongzhan Chen and Xiaojun Quan and Hehong Chen and Ming Yan and Ji Zhang},
  title = {{Knowledge Distillation for Closed-Source Language Models}},
  year = {2024},
  eprint = {2401.07013},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2401.07013},
}
Figure