search
HomeTechnology peripheralsAINvidia plays with pruning and distillation: cutting Llama 3.1 8B parameters in half to achieve better performance with the same size

The rise of small models.

Last month, Meta released the Llama 3.1 series of models, which includes Meta’s largest 405B model to date, as well as two smaller models with 70 billion and 8 billion parameters respectively.

Llama 3.1 is considered to usher in a new era of open source. However, although the new generation models are powerful in performance, they still require a large amount of computing resources when deployed.

Therefore, another trend has emerged in the industry, which is to develop small language models (SLM) that perform well enough in many language tasks and are also very cheap to deploy.

Recently, NVIDIA research shows that structured weight pruning combined with knowledge distillation can gradually obtain smaller language models from an initially larger model. M Yann Lecun, the winner of the Turing Award and the chief AI scientist of Meta, also praised the research.

英伟达玩转剪枝、蒸馏:把Llama 3.1 8B参数减半,性能同尺寸更强
After pruning and distillation, the NVIDIA research team refined Llama 3.1 8B into Llama-3.1-Minitron 4B and made it open source. This is Nvidia’s first release in the Llama 3.1 open source series.

Llama-3.1-Minitron 4B outperforms state-of-the-art open source models of similar size, including Minitron 4B, Phi-2 2.7B, Gemma2 2.6B and Qwen2-1.5B.

The relevant paper of this research was released as early as last month.

英伟达玩转剪枝、蒸馏:把Llama 3.1 8B参数减半,性能同尺寸更强

Paper link: https://www.arxiv.org/pdf/2407.14679

英伟达玩转剪枝、蒸馏:把Llama 3.1 8B参数减半,性能同尺寸更强
Paper title: Compact Language Models via Pruning and Knowledge Distillation
  • Pruning and Distillation
  • Pruning makes the model smaller and leaner, and can be achieved by removing layers (depth pruning) or removing neurons and attention heads and embedding channels (width pruning). Pruning is usually accompanied by some degree of retraining to restore accuracy.
Model distillation is a technique for transferring knowledge from a large complex model (often called a teacher model) to a smaller, simpler student model. The goal is to create a more efficient model that retains much of the predictive power of the original larger model while running faster and consuming fewer resources.

There are two main distillation methods: SDG fine-tuning and classic knowledge distillation. These two distillation methods are complementary. This article focuses on classical knowledge distillation methods.

NVIDIA uses a method that combines pruning and classic knowledge distillation to construct large models. The figure below shows the pruning and distillation process of a single model (top) and the chain of model pruning and distillation (bottom). The specific process is as follows:

1. NVIDIA starts with a 15B model, evaluates the importance of each component (layer, neuron, head and embedding channel), then sorts and prunes the model to reach the target size: 8B model .

2. Then use model distillation for light retraining, with the original model as the teacher and the pruned model as the student.

3. After training, take the small model (8B) as the starting point, prune and distill it into a smaller 4B model. The process of pruning and distillation from the 15B model.

The point to note is that before pruning the model, you need to understand which parts of the model are important. NVIDIA proposes an activation-based pure importance assessment strategy that simultaneously computes information in all relevant dimensions (depth, neuron, head, and embedding channels), using a small calibration dataset of 1024 samples, and only Forward propagation is required. This approach is simpler and more cost-effective than strategies that rely on gradient information and require backpropagation.

During pruning, you can iteratively alternate between pruning and importance estimation for a given axis or combination of axes. Empirical studies show that using a single importance estimate is sufficient and that iterative estimates do not bring additional benefits.

Retraining using classical knowledge distillation英伟达玩转剪枝、蒸馏:把Llama 3.1 8B参数减半,性能同尺寸更强

以下の図 2 は、N 層の学生モデル (枝刈りされたモデル) が M 層の教師モデル (元の枝刈りされていないモデル) から抽出される蒸留プロセスを示しています。スチューデント モデルは、スチューデント ブロック S と教師ブロック T にマッピングされた埋め込み出力損失、ロジット損失、および Transformer エンコーダ固有の損失の組み合わせを最小限に抑えることによって学習されます。図 2: 蒸留トレーニングの損失。

英伟达玩转剪枝、蒸馏:把Llama 3.1 8B参数减半,性能同尺寸更强

剪定と蒸留のベストプラクティスコンパクト言語モデルに基づくNVIDIAの剪定と知識の蒸留広範なアブレーション研究を行った結果、私はその学習結果を次の構造化された圧迫のベスト プラクティスにまとめました。

まずはサイズの調整です。

LLM のセットをトレーニングするには、最初に最大の LLM がトレーニングされ、次に反復的に枝刈りおよび蒸留されて、より小さい LLM が取得されます。

複数段階のトレーニング戦略を使用して最大のモデルをトレーニングする場合は、トレーニングの最終段階で取得したモデルを枝刈りして再トレーニングするのが最善です。
  • ターゲット サイズに最も近い利用可能なソース モデルをプルーニングします。
  • 2つ目は剪定です。
  • 深さの枝刈りよりも幅の枝刈りを優先します。これは、パラメータ サイズが 15B 未満のモデルに適しています。

反復的な重要度推定にはメリットがないため、単発の重要度推定を使用します。
  • 3つ目は再訓練することです。
  • 蒸留損失は、通常のトレーニングではなく再トレーニングにのみ使用してください。

深さが大幅に減少した場合は、ロジット、中間状態、および埋め込み蒸留を使用します。
  • 深さが大幅に減少しない場合は、ロジット限定蒸留を使用します。
  • Llama-3.1-Minitron: ベストプラクティスを実践
  • Meta が最近リリースした機能 強力な Llamaオープンソース モデルの 3.1 ファミリは、多くのベンチマークにおいてクローズド ソース モデルと同等です。 Llama 3.1 のパラメータは 405B から 70B、8B まで多岐にわたります。
Nemotron の蒸留の経験をもとに、NVIDIA は次の措置を講じて、Llama 3.1 8B モデルをより小型で効率的な 4B モデルに蒸留することに着手しました。 ##🎜 🎜#教師微調整

深さのみの剪定

幅のみの剪定# 🎜🎜#
  • 精度ベンチマーク

  • パフォーマンスベンチマーク

  • # 🎜🎜 ## 🎜🎜#教師の微調整

  • モデルトレーニングのベースとなっている元のデータセットの分布バイアスを修正するために、NVIDIAは最初に枝刈りされていない8Bモデルを彼らのデータセットでトレーニングしました。データセット (94B トークン) 微調整されました。実験によると、分布の偏りが修正されていない場合、教師モデルは抽出時にデータセットに対して次善のガイダンスを提供します。
  • 深さのみのプルーニング
  • 8B から 4B に削減するために、NVIDIA は 16 レイヤー (50%) をプルーニングしました。彼らはまず、各層または連続するサブ層のグループをモデルから削除することでその重要性を評価し、下流タスクでの LM 損失の増加または精度の低下を観察します。

  • 以下の図 5 は、1、2、8、または 16 層を削除した後の検証セットの LM 損失値を示しています。たとえば、層 16 の赤いプロットは、最初の 16 層が除去された場合に発生する LM 損失を示します。レイヤ 17 は、最初のレイヤが保持され、レイヤ 2 ~ 17 が削除された場合にも LM 損失が発生することを示します。 Nvidia は、開始層と終了層が最も重要であると考えています。 ### ## ## ##

ただし、NVIDIA は、この LM 損失が必ずしもダウンストリームのパフォーマンスに直接関係しているわけではないと観察しています。

以下の図 6 は、各プルーニングされたモデルの Winogrande 精度を示しています。これは、16 番目から 31 番目のレイヤーを削除するのが最適であることを示しています。ここで、31 番目のレイヤーは最後から 2 番目のレイヤーであり、プルーニングされたモデルの 5 番目のレイヤーです。精度はランダム精度 (0.5) よりも大幅に高くなります。 Nvidia はこの洞察を取り入れ、レイヤー 16 から 31 を削除しました。

精度。

英伟达玩转剪枝、蒸馏:把Llama 3.1 8B参数减半,性能同尺寸更强

幅のみのプルーニング

NVIDIA は幅軸に沿って埋め込み (非表示) と MLP をプルーニングします。 Llama 3.1 8B を圧縮します。具体的には、前述のアクティベーションベースの戦略を使用して、各アテンションヘッド、埋め込みチャネル、および MLP 隠れディメンションの重要度スコアを計算します。 重要度の推定後、NVIDIA は

を選択して MLP 中間ディメンションを 14336 から 9216 にプルーニングしました。

英伟达玩转剪枝、蒸馏:把Llama 3.1 8B参数减半,性能同尺寸更强
非表示サイズを 4096 から 3072 までプルーニングします。

ヘッドの数とレイヤーの数にもう一度注意してください。

単一サンプル枝刈りの後、幅枝刈りの LM 損失は深さ枝刈りの LM 損失よりも高いことに言及する価値があります。しかし、短い再トレーニング期間の後、傾向は逆転しました。

精度ベンチマーク

NVIDIAは、次のパラメーターを使用してモデルを抽出しました

  • ピーク学習率 = 1e-4

  • 最小学習率 = 1e-5

  • 40ステップの線形ウォームアップ

  • コサイン減衰計画

  • グローバルバッチサイズ = 1152

以下の表 1 は、オリジナルの Llama 3.1 8B モデルと同様の Llama-3.1-Minitron 4B モデルのバリアント (幅プルーニングと深さプルーニング)、その他のパフォーマンスの比較を示しています。複数のドメインにわたるベンチマークで大規模なモデルと小規模なモデルを比較します。全体として、NVIDIA は、ベスト プラクティスに従ったディープ プルーニングと比較して、ワイド プルーニング戦略の有効性を再度確認しました。

英伟达玩转剪枝、蒸馏:把Llama 3.1 8B参数减半,性能同尺寸更强

表 1: 精度の比較Minitron 4B ベース モデルと同様のスケールのベース モデルとの比較。

抽出されたモデルが強力な命令モデルになれるかどうかを検証するために、NVIDIA は NeMo-Aligner を使用して Llama-3.1-Minitron 4B モデルを微調整しました。

彼らは Nemotron-4 340B トレーニング データを使用し、IFEval、MT-Bench、ChatRAG-Bench、Berkeley Function Calling Leaderboard (BFCL) で評価して、命令追従、ロールプレイング、RAG および関数呼び出しの機能をテストしました。最後に、Llama-3.1-Minitron 4B モデルは信頼性の高いコマンド モデルであり、他のベースライン SLM よりも優れたパフォーマンスを発揮できることが確認されました。

英伟达玩转剪枝、蒸馏:把Llama 3.1 8B参数减半,性能同尺寸更强

表2:同様のサイズの整列モデルを備えたアライメントミニトロン4Bベースモデルの精度比較。

パフォーマンス ベンチマーク

NVIDIA は、LLM 推論を最適化するためのオープンソース ツールキットである NVIDIA TensorRT-LLM を使用して、Llama 3.1 8B および Llama-3.1-Minitron 4B モデルを最適化しました。

次の 2 つの図は、さまざまなユースケースにおける FP8 および FP16 精度でのさまざまなモデルの 1 秒あたりのスループット リクエストを示しています。これは、8B のバッチ サイズ 32 の入力シーケンス長/出力シーケンス長 (ISL/OSL) の組み合わせとして表されています。 4B モデルのバッチ サイズは、入力シーケンス長/出力シーケンス長 (ISL/OSL) の組み合わせが 64 です。これは、NVIDIA H100 80GB GPU では重みが小さいため、より大きなバッチ サイズが可能になります。

Llama-3.1-Minitron-4B-Depth-Base バリアントは最も高速で、平均スループットは Llama 3.1 8B の約 2.7 倍ですが、Llama-3.1-Minitron-4B-Width-Base バリアントは平均Llama 3.1 8Bの約1.8倍のスループットを実現。また、FP8 に導入すると、3 つのモデルすべてのパフォーマンスが BF16 と比較して約 1.3 倍向上します。

英伟达玩转剪枝、蒸馏:把Llama 3.1 8B参数减半,性能同尺寸更强
英伟达玩转剪枝、蒸馏:把Llama 3.1 8B参数减半,性能同尺寸更强

80GB GPU。

結論

枝刈りと古典的な知識の洗練は、より小さいサイズの LLM を段階的に取得するための非常に費用対効果の高い方法であり、すべてのドメインで最初からトレーニングするよりも高い精度を達成します。これは、合成データを微調整したり、最初から事前トレーニングしたりするよりも、より効率的でデータ効率の高いアプローチです。

Llama-3.1-Minitron 4B は、最先端のオープンソース Llama 3.1 シリーズを使用する NVIDIA の最初の試みです。 NVIDIA NeMo で Llama-3.1 の SDG 微調整を使用するには、GitHub の /sdg-law-title-generation セクションを参照してください。

詳細については、次のリソースを参照してください:

  • https://arxiv.org/abs/2407.14679

  • https://github.com/NVlabs/Minitron

  • https:// hackingface.co/nvidia/Llama-3.1-Minitron-4B-Width-Base

  • https://huggingface.co/nvidia/Llama-3.1-Minitron-4B-Depth-Base

参考リンク:

https://developer.nvidia.com/blog/how-to-prune-and-distill-llama-3-1-8b-to-an-nvidia-llama-3-1-minitron-4b -モデル/

The above is the detailed content of Nvidia plays with pruning and distillation: cutting Llama 3.1 8B parameters in half to achieve better performance with the same size. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Sam's Club Bets On AI To Eliminate Receipt Checks And Enhance RetailSam's Club Bets On AI To Eliminate Receipt Checks And Enhance RetailApr 22, 2025 am 11:29 AM

Revolutionizing the Checkout Experience Sam's Club's innovative "Just Go" system builds on its existing AI-powered "Scan & Go" technology, allowing members to scan purchases via the Sam's Club app during their shopping trip.

Nvidia's AI Omniverse Expands At GTC 2025Nvidia's AI Omniverse Expands At GTC 2025Apr 22, 2025 am 11:28 AM

Nvidia's Enhanced Predictability and New Product Lineup at GTC 2025 Nvidia, a key player in AI infrastructure, is focusing on increased predictability for its clients. This involves consistent product delivery, meeting performance expectations, and

Exploring the Capabilities of Google's Gemma 2 ModelsExploring the Capabilities of Google's Gemma 2 ModelsApr 22, 2025 am 11:26 AM

Google's Gemma 2: A Powerful, Efficient Language Model Google's Gemma family of language models, celebrated for efficiency and performance, has expanded with the arrival of Gemma 2. This latest release comprises two models: a 27-billion parameter ver

The Next Wave of GenAI: Perspectives with Dr. Kirk Borne - Analytics VidhyaThe Next Wave of GenAI: Perspectives with Dr. Kirk Borne - Analytics VidhyaApr 22, 2025 am 11:21 AM

This Leading with Data episode features Dr. Kirk Borne, a leading data scientist, astrophysicist, and TEDx speaker. A renowned expert in big data, AI, and machine learning, Dr. Borne offers invaluable insights into the current state and future traje

AI For Runners And Athletes: We're Making Excellent ProgressAI For Runners And Athletes: We're Making Excellent ProgressApr 22, 2025 am 11:12 AM

There were some very insightful perspectives in this speech—background information about engineering that showed us why artificial intelligence is so good at supporting people’s physical exercise. I will outline a core idea from each contributor’s perspective to demonstrate three design aspects that are an important part of our exploration of the application of artificial intelligence in sports. Edge devices and raw personal data This idea about artificial intelligence actually contains two components—one related to where we place large language models and the other is related to the differences between our human language and the language that our vital signs “express” when measured in real time. Alexander Amini knows a lot about running and tennis, but he still

Jamie Engstrom On Technology, Talent And Transformation At CaterpillarJamie Engstrom On Technology, Talent And Transformation At CaterpillarApr 22, 2025 am 11:10 AM

Caterpillar's Chief Information Officer and Senior Vice President of IT, Jamie Engstrom, leads a global team of over 2,200 IT professionals across 28 countries. With 26 years at Caterpillar, including four and a half years in her current role, Engst

New Google Photos Update Makes Any Photo Pop With Ultra HDR QualityNew Google Photos Update Makes Any Photo Pop With Ultra HDR QualityApr 22, 2025 am 11:09 AM

Google Photos' New Ultra HDR Tool: A Quick Guide Enhance your photos with Google Photos' new Ultra HDR tool, transforming standard images into vibrant, high-dynamic-range masterpieces. Ideal for social media, this tool boosts the impact of any photo,

What are the TCL Commands in SQL? - Analytics VidhyaWhat are the TCL Commands in SQL? - Analytics VidhyaApr 22, 2025 am 11:07 AM

Introduction Transaction Control Language (TCL) commands are essential in SQL for managing changes made by Data Manipulation Language (DML) statements. These commands allow database administrators and users to control transaction processes, thereby

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor