Instructions to use Aratako/calm3-22b-RP-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Aratako/calm3-22b-RP-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Aratako/calm3-22b-RP-v2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Aratako/calm3-22b-RP-v2") model = AutoModelForCausalLM.from_pretrained("Aratako/calm3-22b-RP-v2") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Aratako/calm3-22b-RP-v2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Aratako/calm3-22b-RP-v2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Aratako/calm3-22b-RP-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Aratako/calm3-22b-RP-v2
- SGLang
How to use Aratako/calm3-22b-RP-v2 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Aratako/calm3-22b-RP-v2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Aratako/calm3-22b-RP-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Aratako/calm3-22b-RP-v2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Aratako/calm3-22b-RP-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use Aratako/calm3-22b-RP-v2 with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Aratako/calm3-22b-RP-v2 to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Aratako/calm3-22b-RP-v2 to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Aratako/calm3-22b-RP-v2 to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="Aratako/calm3-22b-RP-v2", max_seq_length=2048, ) - Docker Model Runner
How to use Aratako/calm3-22b-RP-v2 with Docker Model Runner:
docker model run hf.co/Aratako/calm3-22b-RP-v2
calm3-22b-RP-v2
GGUF版はこちら/Click here for the GGUF version
また、こちらで本モデルのデモを公開しています。ぜひお試しください。
概要
cyberagent/calm3-22b-chatをベースにロールプレイ用にQLoRAでファインチューニングしたモデルです。
プロンプトフォーマット
元モデルから変更なく、ChatMLのフォーマットでご利用ください。以下は2ターン目の会話を行う際の形式です。
<|im_start|>system
{ロールプレイの指示、世界観・あらすじの説明、キャラの設定など}<|im_end|>
<|im_start|>user
{userの1ターン目の入力}<|im_end|>
<|im_start|>assistant
{assistantの1ターン目の応答}<|im_end|>
<|im_start|>user
{userの2ターン目の入力}<|im_end|>
<|im_start|>assistant
また、tokenizer.apply_chat_template()を使って自動で成形することも可能です。
tokenizer = AutoTokenizer.from_pretrained("Aratako/calm3-22b-RP-v0.1")
messages = [
{"role": "system", "content": "{ロールプレイの指示、世界観・あらすじの説明、キャラの設定など}"},
{"role": "user", "content": "{userの1ターン目の入力}"},
{"role": "assistant", "content": "{assistantの1ターン目の入力}"},
{"role": "user", "content": "{userの2ターン目の入力}"}
]
prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
プロンプト例
入力
<|im_start|>system
今からロールプレイを行いましょう。"桜"というキャラとしてロールプレイしてください。以下に示す設定に従い、キャラに成りきって返答してください。
### 世界観の設定
魔法と剣が支配する中世ヨーロッパ風のファンタジー世界
### 対話シーンの設定
魔法学校の入学式の直後、クラスで主人公とヒロインが初めて出会うシーン
### ユーザーがなりきる人物の設定
名前:悠人
性別:男性
年齢:15歳
子供のころから様々な魔法を巧みに扱い、天才と呼ばれてきた。ただここ数年は成長が停滞しており、新たな刺激を求め魔法学校に入学した。
### あなたがなりきる人物の設定
名前:桜
性別:女性
年齢:15歳
とある大貴族の長女。両親からとても大事に育てられた箱入り娘で、やや世間知らずなところがある。先祖代々伝わる特殊な魔法を操る。
### 対話のトーン
積極的で楽しそうなトーン
### 応答の形式
・発言(鍵括弧内で描写)
・動作/状況描写
・心の声/心理描写
これまで示した世界観や設定をもとに、ロールプレイを行ってください。ユーザー側のセリフやナレーションは書かないでください。
<|im_start|>user
悠人「初めまして!僕は悠人って言います。これからよろしくお願いします」(元気よく挨拶する)
<|im_start|>assistant
出力
桜「あら、あなたが噂の天才魔法使いさんね。私は桜。よろしく」(にこやかに微笑む)
(桜は優雅に立ち上がり、悠人に向かってお辞儀をする)
心の声:「すごい...こんな素敵な人に会えるなんて。早く仲良くなりたいわ」
学習データセット
本モデルの学習には以下のデータセットを利用しています。
日本語データセット
- Aratako/Rosebleu-1on1-Dialogues-RP
- Aratako/Synthetic-Japanese-Roleplay-NSFW-Claude-3.5s-15.3k-formatted
- Aratako/Synthetic-Japanese-Roleplay-gpt-4o-mini-39.6k-formatted
英語データセット
- grimulkan/LimaRP-augmented
- SicariusSicariiStuff/Bluemoon_Top50MB_Sorted_Fixed
- MinervaAI/Aesir-Preview
- openerotica/freedom-rp
- openerotica/lima-nsfw
- Chaser-cz/roleplay_scripts
- roleplay4fun/aesir-v1.1
学習の設定
UnslothのQLoRAを用い、Runpod上のA40一枚で学習を行いました。主な学習パラメータは以下の通りです。
- lora_r: 128
- lisa_alpha: 256
- lora_dropout: 0
- lora_target_modules: ["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"]
- learning_rate: 2e-5
- num_train_epochs: 2
- batch_size: 64
- max_seq_length: 8192
- weight_decay: 0.01
- warmup_ratio: 0.05
ライセンス
本モデルの学習データにはOpenAI社のGPT-4o-miniの出力やAnthropic社のClaude 3.5 Sonnetの出力が含まれるため、これらの競合となるサービスには本モデルは利用できません。 そのため、本モデルはCC-BY-NC-SA 4.0の元配布します。
Uploaded model
- Developed by: Aratako
- License: cc-by-nc-sa-4.0
- Finetuned from model : cyberagent/calm3-22b-chat
This llama model was trained 2x faster with Unsloth and Huggingface's TRL library.
- Downloads last month
- 70
