🚀 RWKV-4 | 1B5パラメータチャットバージョン (Raven) モデルカード
RWKVはBo Pengによって主導されるプロジェクトです。モデルアーキテクチャの詳細については、Johan Windのブログ記事 こちら と こちら を参照してください。また、RWKVディスコードサーバー に参加することで、プロジェクトについてもっと学ぶことができます。

🚀 クイックスタート
目次
- 要約
- モデルの詳細
- 使用方法
- 引用方法
要約
以下はオリジナルリポジトリからの説明です。
RWKVは、トランスフォーマーレベルの大規模言語モデル(LLM)性能を持つRNNです。GPTのように直接学習することができます(並列化可能)。RNNとトランスフォーマーの良いところを兼ね備えています - 優れた性能、高速推論、VRAMの節約、高速学習、「無限」のctx_len、そして無料の文埋め込み。
モデルの詳細
アーキテクチャの詳細は、上記のブログ記事とHugging Faceの統合ブログ記事に記載されています。
使用方法
生の重みをHF形式に変換する
convert_rwkv_checkpoint_to_hf.py
スクリプトを使用して、元の重みのrepo_id、ファイル名、出力ディレクトリを指定することができます。また、オプションで --push_to_hub
フラグと --model_name
引数を渡すことで、変換したモデルを直接Hubにプッシュすることもできます。
python convert_rwkv_checkpoint_to_hf.py --repo_id RAW_HUB_REPO --checkpoint_file RAW_FILE --output_dir OUTPUT_DIR --push_to_hub --model_name dummy_user/converted-rwkv
テキスト生成
AutoModelForCausalLM
と AutoTokenizer
クラスを使用して、モデルからテキストを生成することができます。以下のセクションを展開して、さまざまなシナリオでモデルを実行する方法を理解してください。
"Raven" モデルは特定の方法でプロンプトを与える必要があります。詳細については 統合ブログ記事 を参照してください。
CPUでモデルを実行する
展開するにはクリック
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("RWKV/rwkv-raven-1b5")
tokenizer = AutoTokenizer.from_pretrained("RWKV/rwkv-raven-1b5")
prompt = "\nIn a shocking finding, scientist discovered a herd of dragons living in a remote, previously unexplored valley, in Tibet. Even more surprising to the researchers was the fact that the dragons spoke perfect Chinese."
inputs = tokenizer(prompt, return_tensors="pt")
output = model.generate(inputs["input_ids"], max_new_tokens=40)
print(tokenizer.decode(output[0].tolist(), skip_special_tokens=True))
単一のGPUでモデルを実行する
展開するにはクリック
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("RWKV/rwkv-raven-1b5").to(0)
tokenizer = AutoTokenizer.from_pretrained("RWKV/rwkv-raven-1b5")
prompt = "\nIn a shocking finding, scientist discovered a herd of dragons living in a remote, previously unexplored valley, in Tibet. Even more surprising to the researchers was the fact that the dragons spoke perfect Chinese."
inputs = tokenizer(prompt, return_tensors="pt").to(0)
output = model.generate(inputs["input_ids"], max_new_tokens=40)
print(tokenizer.decode(output[0].tolist(), skip_special_tokens=True))
半精度でGPU上でモデルを実行する
展開するにはクリック
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("RWKV/rwkv-raven-1b5", torch_dtype=torch.float16).to(0)
tokenizer = AutoTokenizer.from_pretrained("RWKV/rwkv-raven-1b5")
prompt = "\nIn a shocking finding, scientist discovered a herd of dragons living in a remote, previously unexplored valley, in Tibet. Even more surprising to the researchers was the fact that the dragons spoke perfect Chinese."
inputs = tokenizer(prompt, return_tensors="pt").to(0)
output = model.generate(inputs["input_ids"], max_new_tokens=40)
print(tokenizer.decode(output[0].tolist(), skip_special_tokens=True))
複数のGPUでモデルを実行する
展開するにはクリック
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("RWKV/rwkv-raven-1b5", device_map="auto")
tokenizer = AutoTokenizer.from_pretrained("RWKV/rwkv-raven-1b5")
prompt = "\nIn a shocking finding, scientist discovered a herd of dragons living in a remote, previously unexplored valley, in Tibet. Even more surprising to the researchers was the fact that the dragons spoke perfect Chinese."
inputs = tokenizer(prompt, return_tensors="pt").to(0)
output = model.generate(inputs["input_ids"], max_new_tokens=40)
print(tokenizer.decode(output[0].tolist(), skip_special_tokens=True))
引用
このモデルを使用する場合は、元のリポジトリ こちら の元の研究を引用することを検討してください。
データセット
Property |
Details |
データセット |
EleutherAI/pile |