


Nvidia plays with pruning and distillation: halving the parameters of Llama 3.1 8B 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 model to date, the 405B, as well as two smaller models, The parameter amounts are 70 billion and 8 billion 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. #🎜🎜 ##### 🎜🎜 ## 🎜🎜 ## 🎜🎜 ## 🎜🎜 ## 🎜🎜#, Meta chief AI scientist Jann LECun also praised the study.

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 related paper of this research was released as early as last month.

Paper link: https://www.arxiv.org/pdf/2407.14679
#🎜 🎜#
- Pruning and Distillation # 🎜🎜#
- Pruning makes the model smaller and leaner, which 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.
NVIDIA uses a method that combines pruning and classic knowledge distillation to construct large models. The following figure shows the pruning and distillation process of a single model (top) and the chain of model pruning and distillation ( Down). The specific process is as follows:
1. NVIDIA starts with the 15B model, evaluates the importance of each component (layer, neuron, head and embedding channel), and then sorts and prunes the model to make it Target size reached: 8B model. 2. Then light retraining was performed using model distillation, 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..

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

剪定と蒸留のベストプラクティスコンパクト言語モデルに基づくNVIDIAの剪定と知識の蒸留広範なアブレーション研究を行った結果、私はその学習結果を次の構造化された圧迫のベスト プラクティスにまとめました。
まずはサイズの調整です。LLM のセットをトレーニングするには、最初に最大の LLM がトレーニングされ、次に反復的に枝刈りおよび蒸留されて、より小さい LLM が取得されます。 複数段階のトレーニング戦略を使用して最大のモデルをトレーニングする場合は、トレーニングの最終段階で取得したモデルを枝刈りして再トレーニングするのが最善です。
- ターゲット サイズに最も近い利用可能なソース モデルをプルーニングします。
- 2つ目は剪定です。
- 深さの枝刈りよりも幅の枝刈りを優先します。これは、パラメータ サイズが 15B 未満のモデルに適しています。
- 3つ目は再訓練することです。
- 蒸留損失は、通常のトレーニングではなく再トレーニングにのみ使用してください。
- 深さが大幅に減少しない場合は、ロジット限定蒸留を使用します。
- Llama-3.1-Minitron: ベストプラクティスを実践
- Meta が最近リリースした機能 強力な Llamaオープンソース モデルの 3.1 ファミリは、多くのベンチマークにおいてクローズド ソース モデルと同等です。 Llama 3.1 のパラメータは、405B から 70B、8B までの範囲に及びます。
深さのみの剪定 幅のみの剪定# 🎜🎜#
精度ベンチマーク
パフォーマンスベンチマーク
- # 🎜🎜 ## 🎜🎜#教師の微調整 モデルトレーニングのベースとなっている元のデータセットの分布バイアスを修正するために、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 を削除しました。
精度。
NVIDIA は、幅軸に沿って埋め込み (非表示) と MLP をプルーニングします。 Llama 3.1 8B を圧縮します。具体的には、前述のアクティベーションベースの戦略を使用して、各アテンションヘッド、埋め込みチャネル、および MLP 隠れディメンションの重要度スコアを計算します。 重要度の推定後、NVIDIA は
を選択して MLP 中間ディメンションを 14336 から 9216 にプルーニングしました。

ヘッドの数とレイヤーの数に注意を再教育してください。
単一サンプル枝刈りの後、幅枝刈りの LM 損失は深さ枝刈りの LM 損失よりも高いことに言及する価値があります。しかし、短い再トレーニング期間の後、傾向は逆転しました。
精度ベンチマーク
NVIDIAは、次のパラメーターを使用してモデルを抽出しました
ピーク学習率 = 1e-4
最小学習率 = 1e-5
-
40ステップの線形ウォームアップ
コサイン減衰計画
グローバルバッチサイズ = 1152
以下の表 1 は、オリジナルの Llama 3.1 8B モデルと同様の Llama-3.1-Minitron 4B モデルのバリアント (幅プルーニングと深さプルーニング)、その他のパフォーマンスの比較を示しています。複数のドメインにわたるベンチマークで大規模なモデルと小規模なモデルを比較します。全体として、NVIDIA は、ベスト プラクティスに従ったディープ プルーニングと比較して、ワイド プルーニング戦略の有効性を再度確認しました。

表 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 を上回る信頼性の高い命令モデルとなり得ることが確認されました。

表 2:整列した Minitron 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 倍向上します。


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: halving the parameters of Llama 3.1 8B to achieve better performance with the same size. For more information, please follow other related articles on the PHP Chinese website!

The legal tech revolution is gaining momentum, pushing legal professionals to actively embrace AI solutions. Passive resistance is no longer a viable option for those aiming to stay competitive. Why is Technology Adoption Crucial? Legal professional

Many assume interactions with AI are anonymous, a stark contrast to human communication. However, AI actively profiles users during every chat. Every prompt, every word, is analyzed and categorized. Let's explore this critical aspect of the AI revo

A successful artificial intelligence strategy cannot be separated from strong corporate culture support. As Peter Drucker said, business operations depend on people, and so does the success of artificial intelligence. For organizations that actively embrace artificial intelligence, building a corporate culture that adapts to AI is crucial, and it even determines the success or failure of AI strategies. West Monroe recently released a practical guide to building a thriving AI-friendly corporate culture, and here are some key points: 1. Clarify the success model of AI: First of all, we must have a clear vision of how AI can empower business. An ideal AI operation culture can achieve a natural integration of work processes between humans and AI systems. AI is good at certain tasks, while humans are good at creativity and judgment

Meta upgrades AI assistant application, and the era of wearable AI is coming! The app, designed to compete with ChatGPT, offers standard AI features such as text, voice interaction, image generation and web search, but has now added geolocation capabilities for the first time. This means that Meta AI knows where you are and what you are viewing when answering your question. It uses your interests, location, profile and activity information to provide the latest situational information that was not possible before. The app also supports real-time translation, which completely changed the AI experience on Ray-Ban glasses and greatly improved its usefulness. The imposition of tariffs on foreign films is a naked exercise of power over the media and culture. If implemented, this will accelerate toward AI and virtual production

Artificial intelligence is revolutionizing the field of cybercrime, which forces us to learn new defensive skills. Cyber criminals are increasingly using powerful artificial intelligence technologies such as deep forgery and intelligent cyberattacks to fraud and destruction at an unprecedented scale. It is reported that 87% of global businesses have been targeted for AI cybercrime over the past year. So, how can we avoid becoming victims of this wave of smart crimes? Let’s explore how to identify risks and take protective measures at the individual and organizational level. How cybercriminals use artificial intelligence As technology advances, criminals are constantly looking for new ways to attack individuals, businesses and governments. The widespread use of artificial intelligence may be the latest aspect, but its potential harm is unprecedented. In particular, artificial intelligence

The intricate relationship between artificial intelligence (AI) and human intelligence (NI) is best understood as a feedback loop. Humans create AI, training it on data generated by human activity to enhance or replicate human capabilities. This AI

Anthropic's recent statement, highlighting the lack of understanding surrounding cutting-edge AI models, has sparked a heated debate among experts. Is this opacity a genuine technological crisis, or simply a temporary hurdle on the path to more soph

India is a diverse country with a rich tapestry of languages, making seamless communication across regions a persistent challenge. However, Sarvam’s Bulbul-V2 is helping to bridge this gap with its advanced text-to-speech (TTS) t


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

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),

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download
The most popular open source editor

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Chinese version
Chinese version, very easy to use
