🚀 [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(-R)モデルとデータセットをダウンロードする方法や、翻訳システムを使った翻訳の始め方を説明します。
✨ 主な機能
- ALMA-RはALMAモデルをベースに、CPOを用いたLoRA微調整を行い、翻訳性能を向上させています。
- 複数の翻訳モデル(ALMA-7B、ALMA-7B-LoRA、ALMA-7B-R、ALMA-13B、ALMA-13B-LoRA、ALMA-13B-R)を公開しています。
- ヒューマンライテンの並列データやトリプレット嗜好データなどのデータセットを公開しています。
📦 インストール
このセクションでは、モデルとデータセットのダウンロード方法について説明します。
モデルのダウンロード
論文で提示された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モデルには200億トークン、13Bモデルには120億トークン)のみを経ており、LoRAモデルと組み合わせて利用する必要があります。
データセットのダウンロード
ALMAとALMA-Rで使用されるデータセットも現在Hugging Faceで公開されています(NEW!)。
💻 使用例
基本的な使用法
最良のシステム(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)
📚 ドキュメント
詳細については、GitHubリポジトリ を参照してください。
📄 ライセンス
このプロジェクトはMITライセンスの下で公開されています。