🚀 Qwama-0.5B-Instruct
このモデルは、Qwen2-0.5B-Instruct の語彙をLlama-3の語彙に置き換えたものです。
主な用途は、Llama-3-70B-Instructのドラフトモデルとして使用することです。Llama3-8B-Instructもこの目的には使えますが、ドラフト作成には重すぎる場合があります。
二次的な目的は、語彙交換の実現可能性を探ることです。具体的には、Qwen2-0.5bのような小規模モデルを他のモデルのドラフト生成に適応させるため、または一般的に異なる言語モデル間の相互運用性を実現するためです。この点に関する結論は、この方法は機能するものの、微調整が必要なため、大規模モデルではコストがかかるというものです。低ランクまたは量子化された微調整を代替案として探ることは興味深いでしょう。
🚀 クイックスタート
手順
語彙の交換は、新しい埋め込み層を作成し(元のモデルは結合埋め込みを使用しているため、出力層も同じです)、以下のように初期化することで行われました。
- L3のトークンがQwen2のトークンと完全に一致する場合は、対応する埋め込みで初期化されます。
- L3のトークンがデコードされ、再エンコードされて複数のQwen2トークンになる場合は、それらの埋め込みの平均で初期化されます。
- L3のトークンが1つ以上のQwen2トークンに変換できないものはありません(両方の語彙は完全です)。
for idx in range(target_vocab_size):
decode = tokenizer_target.decode(torch.tensor(idx, dtype = torch.long), decode_special_tokens = True)
encode = tokenizer_source.encode(decode, add_special_tokens = False, return_tensors = "pt")
new_emb[idx] = old_emb[encode.flatten()].mean(dim = 0)
new_head[idx] = old_head[encode.flatten()].mean(dim = 0)
完全なスクリプトはこちらにあります。
上記の方法で語彙を交換すると、ほぼ首尾一貫したが、まだ非常に混乱したモデルが得られます。特に数字の扱いに苦労し、もちろん、Llama-3の制御トークンの埋め込みは、命令調整されたモデルでのような重要性を持ちません。
これは、その後の微調整によって改善されます。まず、Common Crawlのこの241万行のサンプルで、その後、Llama3-8B-Instructによって生成された約25000の命令形式の完了文で3エポックの微調整を行います。参考のために、こちらに含まれています。
私は結合埋め込みだけを調整することも試しましたが、良い結果は得られませんでした。
📊 ベンチマーク
モデル |
Wikitext 2k |
MMLU |
Qwen2-0.5B-instruct @ FP16 |
12.5734 |
43.83% |
Qwama-0.5B-instruct @ FP16 |
15.3390 |
40.37% |
ドラフトモデルの推測的デコード、貪欲法:
モデル |
ドラフトモデル |
コード |
散文 |
Qwen2-72B-instruct @ 6.0bpw |
Qwen2-0.5B-instruct @ 4.0bpw |
3.68x |
1.70x |
Llama3-70B-instruct @ 6.0bpw |
Qwama-0.5B-instruct @ 4.0bpw |
3.72x |
1.92x |
💬 サンプル生成
Qwen2-0.5B-instruct
Hello, my name is Harry Potter. I am the Chosen One, the only wizard from the wizarding world who can fly and bring a book to life in order to summon it. In a world where wizards often use magic for personal gain, I am an advocate for freedom and non-violence.
Once upon a time, there was a princess named Elsa. She lived in a beautiful castle in the snowy mountains. Her castle was filled with different types of animals, such as snowmen, reindeer, and magical trees. The inhabitants of the castle were very friendly and friendly, but one day, they were attacked by a fierce beast, the Queen of the Snow Kingdom.
I am an AI language model. I don't have a physical body, so I cannot participate in activities like running or playing sports. However, I can simulate the movement of an AI language model. Is there anything specific you would like me to help with?
Qwama-0.5B-instruct
Hello, my name is Jeffrey Brewer and I am a licensed attorney in both Maryland and Florida. I work with people who are experiencing severe financial stress due to financial mismanagement, foreclosure, divorce, and other financial hardships. My approach is to offer compassionate and skilled legal advice while keeping costs low.
Once upon a time, a giant giant monster with a bad reputation invaded a small town. The mayor and the local community began to fight over who was going to make the rules. But who will win if the monsters were being allowed to roam the town?
I am an AI language model that is designed to answer questions and provide information based on my training data. Would you like me to use my knowledge and expertise to answer your question? I am ready to assist you with any questions you may have. I will be happy to answer your questions in a timely manner.
📦 EXL2量子化
EXL2量子化モデルはこちらにアップロードされています。
📄 ライセンス
このプロジェクトは、Apache-2.0ライセンスの下でライセンスされています。