🚀 [ALMA-R]
ALMA-R は、ALMAモデルをベースに構築されています。ALMAで使用されている教師あり微調整ではなく、提案されたContrastive Preference Optimization (CPO) を用いてさらにLoRA微調整を行っています。CPO微調整には、嗜好学習のためにトリプレット嗜好データが必要です。ALMA-Rは、現在、GPT-4やWMTの優勝モデルと同等、あるいはそれを上回る性能を発揮することができます!
@misc{xu2024contrastive,
title={Contrastive Preference Optimization: Pushing the Boundaries of LLM Performance in Machine Translation},
author={Haoran Xu and Amr Sharaf and Yunmo Chen and Weiting Tan and Lingfeng Shen and Benjamin Van Durme and Kenton Murray and Young Jin Kim},
year={2024},
eprint={2401.08417},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
@misc{xu2023paradigm,
title={A Paradigm Shift in Machine Translation: Boosting Translation Performance of Large Language Models},
author={Haoran Xu and Young Jin Kim and Amr Sharaf and Hany Hassan Awadalla},
year={2023},
eprint={2309.11674},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
🚀 クイックスタート
このセクションでは、最良のシステムであるALMA-13B-Rを使った翻訳のクイックスタートを紹介します。「我爱机器翻译。」を英語に翻訳する例を示します。
import torch
from transformers import AutoModelForCausalLM
from transformers import AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("haoranxu/ALMA-13B-R", torch_dtype=torch.float16, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained("haoranxu/ALMA-13B-R", padding_side='left')
prompt="Translate this from Chinese to English:\nChinese: 我爱机器翻译。\nEnglish:"
input_ids = tokenizer(prompt, return_tensors="pt", padding=True, max_length=40, truncation=True).input_ids.cuda()
with torch.no_grad():
generated_ids = model.generate(input_ids=input_ids, num_beams=5, max_new_tokens=20, do_sample=True, temperature=0.6, top_p=0.9)
outputs = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
print(outputs)
✨ 主な機能
- ALMA-RはALMAモデルをベースに、CPOを用いたLoRA微調整を行っています。
- トリプレット嗜好データを用いた嗜好学習により、翻訳性能が向上しています。
- GPT-4やWMTの優勝モデルと同等、あるいはそれを上回る性能を発揮します。
📦 インストール
このREADMEには具体的なインストール手順が記載されていないため、このセクションを省略します。
💻 使用例
基本的な使用法
上記のクイックスタートで示したコードが基本的な使用例です。
📚 ドキュメント
詳細については、GitHubリポジトリを参照してください。
📄 ライセンス
このプロジェクトはMITライセンスの下で公開されています。
モデルとデータセットのダウンロード 🚀
論文で提示された6つの翻訳モデルをリリースしています。
- ALMA-7B
- ALMA-7B-LoRA
- ALMA-7B-R (NEW!):ALMA-7B-LoRAに対して、対照的嗜好最適化によるさらなるLoRA微調整を行ったもの。
- ALMA-13B
- ALMA-13B-LoRA
- ALMA-13B-R (NEW!):ALMA-13B-LoRAに対して、対照的嗜好最適化によるさらなるLoRA微調整を行ったもの(最良のモデル!)。
モデルのチェックポイントはHugging Faceで公開されています。
なお、ALMA-7B-Pretrain
と ALMA-13B-Pretrain
は翻訳モデルではありません。これらは段階1の単言語微調整のみを経ており(7Bモデルは20Bトークン、13Bモデルは12Bトークン)、LoRAモデルと組み合わせて使用する必要があります。
ALMAおよびALMA-Rで使用されるデータセットも、現在Hugging Faceで公開されています(NEW!)。