


Nvidia 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-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.

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

- 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.
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.
以下の図 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:同様のサイズの整列モデルを備えたアライメントミニトロン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: 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!

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics





It is also a Tusheng video, but PaintsUndo has taken a different route. ControlNet author LvminZhang started to live again! This time I aim at the field of painting. The new project PaintsUndo has received 1.4kstar (still rising crazily) not long after it was launched. Project address: https://github.com/lllyasviel/Paints-UNDO Through this project, the user inputs a static image, and PaintsUndo can automatically help you generate a video of the entire painting process, from line draft to finished product. follow. During the drawing process, the line changes are amazing. The final video result is very similar to the original image: Let’s take a look at a complete drawing.

The open LLM community is an era when a hundred flowers bloom and compete. You can see Llama-3-70B-Instruct, QWen2-72B-Instruct, Nemotron-4-340B-Instruct, Mixtral-8x22BInstruct-v0.1 and many other excellent performers. Model. However, compared with proprietary large models represented by GPT-4-Turbo, open models still have significant gaps in many fields. In addition to general models, some open models that specialize in key areas have been developed, such as DeepSeek-Coder-V2 for programming and mathematics, and InternVL for visual-language tasks.

The AIxiv column is a column where this site publishes academic and technical content. In the past few years, the AIxiv column of this site has received more than 2,000 reports, covering top laboratories from major universities and companies around the world, effectively promoting academic exchanges and dissemination. If you have excellent work that you want to share, please feel free to contribute or contact us for reporting. Submission email: liyazhou@jiqizhixin.com; zhaoyunfeng@jiqizhixin.com The authors of this paper are all from the team of teacher Zhang Lingming at the University of Illinois at Urbana-Champaign (UIUC), including: Steven Code repair; Deng Yinlin, fourth-year doctoral student, researcher

If the answer given by the AI model is incomprehensible at all, would you dare to use it? As machine learning systems are used in more important areas, it becomes increasingly important to demonstrate why we can trust their output, and when not to trust them. One possible way to gain trust in the output of a complex system is to require the system to produce an interpretation of its output that is readable to a human or another trusted system, that is, fully understandable to the point that any possible errors can be found. For example, to build trust in the judicial system, we require courts to provide clear and readable written opinions that explain and support their decisions. For large language models, we can also adopt a similar approach. However, when taking this approach, ensure that the language model generates

Recently, the Riemann Hypothesis, known as one of the seven major problems of the millennium, has achieved a new breakthrough. The Riemann Hypothesis is a very important unsolved problem in mathematics, related to the precise properties of the distribution of prime numbers (primes are those numbers that are only divisible by 1 and themselves, and they play a fundamental role in number theory). In today's mathematical literature, there are more than a thousand mathematical propositions based on the establishment of the Riemann Hypothesis (or its generalized form). In other words, once the Riemann Hypothesis and its generalized form are proven, these more than a thousand propositions will be established as theorems, which will have a profound impact on the field of mathematics; and if the Riemann Hypothesis is proven wrong, then among these propositions part of it will also lose its effectiveness. New breakthrough comes from MIT mathematics professor Larry Guth and Oxford University

cheers! What is it like when a paper discussion is down to words? Recently, students at Stanford University created alphaXiv, an open discussion forum for arXiv papers that allows questions and comments to be posted directly on any arXiv paper. Website link: https://alphaxiv.org/ In fact, there is no need to visit this website specifically. Just change arXiv in any URL to alphaXiv to directly open the corresponding paper on the alphaXiv forum: you can accurately locate the paragraphs in the paper, Sentence: In the discussion area on the right, users can post questions to ask the author about the ideas and details of the paper. For example, they can also comment on the content of the paper, such as: "Given to

The AIxiv column is a column where this site publishes academic and technical content. In the past few years, the AIxiv column of this site has received more than 2,000 reports, covering top laboratories from major universities and companies around the world, effectively promoting academic exchanges and dissemination. If you have excellent work that you want to share, please feel free to contribute or contact us for reporting. Submission email: liyazhou@jiqizhixin.com; zhaoyunfeng@jiqizhixin.com. Introduction In recent years, the application of multimodal large language models (MLLM) in various fields has achieved remarkable success. However, as the basic model for many downstream tasks, current MLLM consists of the well-known Transformer network, which

Show the causal chain to LLM and it learns the axioms. AI is already helping mathematicians and scientists conduct research. For example, the famous mathematician Terence Tao has repeatedly shared his research and exploration experience with the help of AI tools such as GPT. For AI to compete in these fields, strong and reliable causal reasoning capabilities are essential. The research to be introduced in this article found that a Transformer model trained on the demonstration of the causal transitivity axiom on small graphs can generalize to the transitive axiom on large graphs. In other words, if the Transformer learns to perform simple causal reasoning, it may be used for more complex causal reasoning. The axiomatic training framework proposed by the team is a new paradigm for learning causal reasoning based on passive data, with only demonstrations
