🚀 Orca_alpaca_3b
説明調整データセットで学習されたOpen_LLaMA - 3Bモデルです。Alpacaデータセットの命令と入力を使用し、Orca研究論文のデータセット構築アプローチを適用して作成されています。
🚀 クイックスタート
Orca_alpaca_3bは、説明調整データセットを用いて学習されたOpen_LLaMA - 3Bベースのモデルです。このモデルは、Alpacaデータセットの命令と入力を元に、Orca研究論文の手法を取り入れて開発されています。
✨ 主な機能
- 説明調整データセットを使用した学習により、思考プロセスを学習しやすくなっています。
- 独自の微調整スクリプトとOpenAlpacaリポジトリのコードを活用し、DeepSpeedとZero - 3アプローチでGPU並列学習を行っています。
📦 インストール
このREADMEには具体的なインストール手順が記載されていないため、このセクションをスキップします。
📚 ドキュメント
データセット
Alpacaデータセット ~52Kを、Orca研究論文のアプローチを用いて構築しました。Orca研究論文に記載されている15のシステム命令をすべて利用してカスタムデータセットを生成しています。これにより、このモデルは教師モデルであるChatGPT(gpt - 3.5 - turbo - 0301バージョン)から「思考」プロセスを学習することができます。
学習
学習の設定は以下の表に示します。学習は4台のA600(50G)GPUを使用し、約20時間かかり、Lambda Labsを利用して約66ドルのコストで行われました。独自の微調整スクリプトを書き、素晴らしいOpenAlpacaリポジトリの一部のモデル学習コードを活用して、DeepSpeedとZero - 3アプローチでGPU並列学習を行いました。
パラメータ |
値 |
batch_size |
16 |
train_micro_batch_size_per_gpu |
2 |
gradient_accumulation_steps |
2 |
Learning rate |
2e - 5 |
Max length |
1024 |
Epochs |
3 |
💻 使用例
基本的な使用法
以下はalpaca_orca_open_llama_3bの使用例です。
import torch
from transformers import LlamaForCausalLM, LlamaTokenizer
model_path = 'psmathur/alpaca_orca_open_llama_3b'
tokenizer = LlamaTokenizer.from_pretrained(model_path)
model = LlamaForCausalLM.from_pretrained(
model_path, torch_dtype=torch.float16, device_map='auto',
)
def generate_text(system, instruction, input=None):
if input:
prompt = f"### System:\n{system}\n\n#\n\n### User:\n{instruction}\n\n### Input:\n{input}\n\n### Response:\n"
else:
prompt = f"### System:\n{system}\n\n#\n\n### User:\n{instruction}\n\n### Response:\n"
tokens = tokenizer.encode(prompt)
tokens = torch.LongTensor(tokens).unsqueeze(0)
tokens = tokens.to('cuda')
instance = {'input_ids': tokens,'top_p': 1.0, 'temperature':0.7, 'generate_len': 1024}
length = len(tokens[0])
with torch.no_grad():
rest = model.generate(
input_ids=tokens,
max_length=length+instance['generate_len'],
use_cache=True,
do_sample=True,
top_p=instance['top_p'],
temperature=instance['temperature']
)
output = rest[0][length:]
string = tokenizer.decode(output, skip_special_tokens=True)
print(f'[!] Response: {string}')
system = 'You are an AI assistant. User will you give you a task. Your goal is to complete the task as faithfully as you can. While performing the task think step-by-step and justify your steps.'
instruction = 'Use the given data to calculate the median.'
input = '[5,2,3,4,1]'
generate_text(system, instruction, input)
今後の目標
- より多くのデータ(Dolly V2、WizardLMなど)を試す(提案を歓迎します)
- より大きなOpenLLaMAモデル(7Bと13B)を試す
- より良いGPUで学習を試す(8xA100 (40GB)が手に入らず、需要が高いようです)
- テキスト生成UIのオプションを増やす(例: https://github.com/oobabooga/text - generation - webui)
- 4bitのGGML/GPTQ量子化モデルを提供する(TheBlokeが助けてくれるかもしれません)
引用
もしalpaca_orca_open_llama_3bがあなたの研究やアプリケーションで役立った場合、以下のBibTeXを使用して引用してください。
@misc{alpaca_orca_open_llama_3b,
author = {Pankaj Mathur},
title = {alpaca_orca_open_llama_3b: A custom explain tuned Alpaca Model Based On OpenLLaMA},
year = {2023},
publisher = {GitHub, HuggingFace},
journal = {GitHub repository, HuggingFace repository},
howpublished = {\url{https://github.com/pankajarm/alpaca_orca_open_llama_3b}, \url{https://https://huggingface.co/psmathur/alpaca_orca_open_llama_3b}},
}
@software{openlm2023openllama,
author = {Xinyang Geng and Hao Liu},
title = {OpenLLaMA: An Open Reproduction of LLaMA},
month = May,
year = 2023,
url = {https://github.com/openlm-research/open_llama}
}
@misc{openalpaca,
author = {Yixuan Su and Tian Lan and Deng Cai},
title = {OpenAlpaca: A Fully Open-Source Instruction-Following Model Based On OpenLLaMA},
year = {2023},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/yxuansu/OpenAlpaca}},
}
@misc{alpaca,
author = {Rohan Taori and Ishaan Gulrajani and Tianyi Zhang and Yann Dubois and Xuechen Li and Carlos Guestrin and Percy Liang and Tatsunori B. Hashimoto },
title = {Stanford Alpaca: An Instruction-following LLaMA model},
year = {2023},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/tatsu-lab/stanford_alpaca}},
}
📄 ライセンス
このプロジェクトはcc - by - nc - sa - 4.0ライセンスの下で公開されています。