🚀 TinyMistral-248M-Chat
TinyMistral-248M-Chatは、高性能なテキスト生成モデルです。このモデルは特定のベースモデルを基に、複数のデータセットを用いて学習され、Apache License 2.0の下で提供されています。
🚀 クイックスタート
このモデルを使用するには、以下の情報を参考にしてください。
推奨プロンプト形式
<|im_start|>system
{system_message}<|im_end|>
<|im_start|>user
{user_message}<|im_end|>
<|im_start|>assistant
✨ 主な機能
- 特定のベースモデルを基に構築され、2つの追加の特殊トークン (
<|im_start|>
と <|im_end|>
) をサポートしています。
- 複数のデータセットを用いて学習され、幅広いタスクに対応できます。
📦 インストール
このREADMEには具体的なインストール手順が記載されていないため、このセクションは省略されます。
💻 使用例
基本的な使用法
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
import torch
model_path = "Felladrin/TinyMistral-248M-Chat-v4"
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(model_path).to(device)
streamer = TextStreamer(tokenizer)
messages = [
{
"role": "system",
"content": "You are a highly knowledgeable and friendly assistant. Your goal is to understand and respond to user inquiries with clarity. Your interactions are always respectful, helpful, and focused on delivering the most accurate information to the user.",
},
{
"role": "user",
"content": "Hey! Got a question for you!",
},
{
"role": "assistant",
"content": "Sure! What's it?",
},
{
"role": "user",
"content": "What are some potential applications for quantum computing?",
},
]
prompt = tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
inputs = tokenizer(prompt, return_tensors="pt").to(device)
model.generate(
inputs.input_ids,
attention_mask=inputs.attention_mask,
max_length=tokenizer.model_max_length,
streamer=streamer,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.pad_token_id,
do_sample=True,
temperature=0.6,
top_p=0.8,
top_k=0,
min_p=0.1,
typical_p=0.2,
repetition_penalty=1.176,
)
📚 ドキュメント
モデル情報
学習方法
このモデルは SFTTrainer を使用して学習され、以下の設定が用いられました。
ハイパーパラメータ |
値 |
学習率 |
2e-5 |
総学習バッチサイズ |
32 |
最大シーケンス長 |
2048 |
重み減衰 |
0.01 |
ウォームアップ比率 |
0.1 |
NEFTuneノイズアルファ |
5 |
オプティマイザ |
Adam with betas=(0.9,0.999) and epsilon=1e-08 |
スケジューラ |
cosine |
シード |
42 |
その後、LLaMA-Factory を通じてDPOで微調整され、以下のハイパーパラメータとコマンドが使用されました。
パラメータ |
値 |
データセット |
HuggingFaceH4/ultrafeedback_binarized |
学習率 |
1e-06 |
学習バッチサイズ |
4 |
評価バッチサイズ |
8 |
シード |
42 |
分散型タイプ |
multi-GPU |
デバイス数 |
8 |
勾配累積ステップ数 |
4 |
総学習バッチサイズ |
128 |
総評価バッチサイズ |
64 |
オプティマイザ |
adamw_8bit with betas=(0.9,0.999) and epsilon=1e-08 |
LRスケジューラタイプ |
cosine |
LRスケジューラウォームアップ比率 |
0.1 |
エポック数 |
2.0 |
llamafactory-cli train \
--stage dpo \
--do_train True \
--model_name_or_path ~/TinyMistral-248M-Chat \
--preprocessing_num_workers $(python -c "import os; print(max(1, os.cpu_count() - 2))") \
--dataloader_num_workers $(python -c "import os; print(max(1, os.cpu_count() - 2))") \
--finetuning_type full \
--flash_attn auto \
--enable_liger_kernel True \
--dataset_dir data \
--dataset ultrafeedback \
--cutoff_len 1024 \
--learning_rate 1e-6 \
--num_train_epochs 2.0 \
--per_device_train_batch_size 4 \
--gradient_accumulation_steps 4 \
--lr_scheduler_type linear \
--max_grad_norm 1.0 \
--logging_steps 10 \
--save_steps 50 \
--save_total_limit 1 \
--warmup_ratio 0.1 \
--packing False \
--report_to tensorboard \
--output_dir ~/TinyMistral-248M-Chat-v4 \
--pure_bf16 True \
--plot_loss True \
--trust_remote_code True \
--ddp_timeout 180000000 \
--include_tokens_per_second True \
--include_num_input_tokens_seen True \
--optim adamw_8bit \
--pref_beta 0.5 \
--pref_ftx 0 \
--pref_loss simpo \
--gradient_checkpointing True
📄 ライセンス
このモデルは Apache License 2.0 の下で提供されています。