モデル概要
モデル特徴
モデル能力
使用事例
🚀 C4AI Command R+ FP8
このモデルは、FriendliAIによってFP8に量子化されたc4ai-command-r-plusモデルです。高精度を維持しながら推論効率を大幅に向上させています。
🚀 クイックスタート
モデルの概要
このリポジトリには、FriendliAIによってFP8に量子化されたc4ai-command-r-plusモデルが含まれています。これにより、高精度を維持しながら推論効率が大幅に向上します。ただし、FP8はNVIDIA Ada、Hopper、およびBlackwell GPUアーキテクチャでのみサポートされています。詳細については、FriendliAIドキュメントを参照してください。
前提条件
- 始める前に、Friendli Suiteにサインアップしてください。Friendliコンテナは4週間無料で使用できます。
- このガイドに従って、パーソナルアクセストークンを準備してください。
- このガイドに従って、Friendliコンテナシークレットを準備してください。
pip install -U "huggingface_hub[cli]"
でHugging Face CLIをインストールしてください。
パーソナルアクセストークンの準備
PAT(パーソナルアクセストークン)は、コンテナレジストリにログインするためのユーザー資格情報です。
- Friendli Suiteにサインインします。
- ユーザー設定 > トークン に移動し、「新しいトークンを作成」 をクリックします。
- 作成したトークンの値を保存します。
Friendliコンテナイメージのプル
- このガイドで作成したパーソナルアクセストークンを使用して、Dockerクライアントにログインします。
export FRIENDLI_PAT="YOUR PAT"
docker login registry.friendli.ai -u $YOUR_EMAIL -p $FRIENDLI_PAT
- イメージをプルします。
docker pull registry.friendli.ai/trial
Friendliコンテナの実行
Friendliコンテナのイメージを準備したら、サービングエンドポイントを作成するために起動できます。
docker run \
--gpus '"device=0,1,2,3"' \
-p 8000:8000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
-e FRIENDLI_CONTAINER_SECRET="YOUR CONTAINER SECRET" \
registry.friendli.ai/trial \
--web-server-port 8000 \
--hf-model-name FriendliAI/c4ai-command-r-plus-fp8 \
--num-devices 4 # Use tensor parallelism degree 4
✨ 主な機能
モデルの概要
C4AI Command R+は、高度な機能を備えた1040億パラメータのモデルのオープンウェイト研究リリースです。これには、Retrieval Augmented Generation (RAG) や、複雑なタスクを自動化するためのツールの使用が含まれます。このモデルの生成におけるツールの使用は、多段階のツール使用を可能にし、モデルが複数のステップにわたって複数のツールを組み合わせて難しいタスクを達成できるようにします。C4AI Command R+は、英語、フランス語、スペイン語、イタリア語、ドイツ語、ブラジルポルトガル語、日本語、韓国語、アラビア語、および簡体字中国語の10か国語でのパフォーマンスが評価された多言語モデルです。Command R+は、推論、要約、質問応答などのさまざまなユースケースに最適化されています。
モデルの詳細
- 入力: モデルはテキストのみを入力として受け取ります。
- 出力: モデルはテキストのみを生成します。
- モデルアーキテクチャ: これは、最適化されたトランスフォーマーアーキテクチャを使用する自己回帰型言語モデルです。事前学習後、このモデルは教師付き微調整 (SFT) と嗜好学習を使用して、モデルの振る舞いを有用性と安全性に関する人間の嗜好に合わせます。
- 対応言語: モデルは、英語、フランス語、スペイン語、イタリア語、ドイツ語、ブラジルポルトガル語、日本語、韓国語、簡体字中国語、およびアラビア語で良好なパフォーマンスを発揮するように最適化されています。事前学習データには、さらにロシア語、ポーランド語、トルコ語、ベトナム語、オランダ語、チェコ語、インドネシア語、ウクライナ語、ルーマニア語、ギリシャ語、ヒンディー語、ヘブライ語、ペルシャ語の13か国語が含まれています。
- コンテキスト長: Command R+は128Kのコンテキスト長をサポートしています。
評価
Command R+は、Open LLMリーダーボードに提出されています。以下に結果を示し、現在Hugging Faceで利用可能な最強の最先端オープンウェイトモデルとの直接比較も行います。これらの結果は、すべてのモデルの評価が標準化された方法で公開されているコードを使用して実装されている場合にのみ比較に有用であり、リーダーボードに提出されていないモデルや、同じ方法で再現できない自己報告の数値との比較には使用しないでください。
モデル | 平均 | Arc (Challenge) | Hella Swag | MMLU | Truthful QA | Winogrande | GSM8k |
---|---|---|---|---|---|---|---|
CohereForAI/c4ai-command-r-plus | 74.6 | 70.99 | 88.6 | 75.7 | 56.3 | 85.4 | 70.7 |
DBRX Instruct | 74.5 | 68.9 | 89 | 73.7 | 66.9 | 81.8 | 66.9 |
Mixtral 8x7B-Instruct | 72.7 | 70.1 | 87.6 | 71.4 | 65 | 81.1 | 61.1 |
Mixtral 8x7B Chat | 72.6 | 70.2 | 87.6 | 71.2 | 64.6 | 81.4 | 60.7 |
CohereForAI/c4ai-command-r-v01 | 68.5 | 65.5 | 87 | 68.2 | 52.3 | 81.5 | 56.6 |
Llama 2 70B | 67.9 | 67.3 | 87.3 | 69.8 | 44.9 | 83.7 | 54.1 |
Yi-34B-Chat | 65.3 | 65.4 | 84.2 | 74.9 | 55.4 | 80.1 | 31.9 |
Gemma-7B | 63.8 | 61.1 | 82.2 | 64.6 | 44.8 | 79 | 50.9 |
LLama 2 70B Chat | 62.4 | 64.6 | 85.9 | 63.9 | 52.8 | 80.5 | 26.7 |
Mistral-7B-v0.1 | 61 | 60 | 83.3 | 64.2 | 42.2 | 78.4 | 37.8 |
これらのメトリクスは頻繁に要求されるため含めていますが、これらのメトリクスはRAG、多言語、ツールのパフォーマンス、またはオープンエンドの生成の評価を捉えていないことに注意してください。私たちは、Command R+がこれらの分野で最先端であると考えています。RAG、多言語、およびツールの評価については、こちらを参照してください。オープンエンドの生成の評価については、Command R+は現在チャットボットアリーナで評価されています。
ツールの使用とマルチホップ機能
Command R+は、会話型ツールの使用機能を持つように特別にトレーニングされています。これらは、特定のプロンプトテンプレートを使用して、教師付き微調整と嗜好微調整の混合によってモデルに学習されています。このプロンプトテンプレートから逸脱すると、パフォーマンスが低下する可能性がありますが、実験をお勧めします。
Command R+のツール使用機能は、会話(オプションのユーザー - システムの前文付き)と利用可能なツールのリストを入力として受け取ります。その後、モデルはそれらのツールのサブセットで実行するアクションのJSON形式のリストを生成します。Command R+は、提供されたツールの1つを複数回使用することがあります。
モデルは、特別なdirectly_answer
ツールを認識するようにトレーニングされており、他のツールを使用したくないことを示すために使用します。特定のツールの呼び出しを控える機能は、ユーザーへの挨拶や、説明を求める質問など、さまざまな状況で役立つ場合があります。directly_answer
ツールの追加をお勧めしますが、必要に応じて削除または名前を変更することができます。
Command R+のツール使用プロンプトテンプレートを使用するための包括的なドキュメントは、こちらで見つけることができます。
以下のコードスニペットは、プロンプトをレンダリングする最小限の動作例を示しています。
使用法: ツール使用プロンプトのレンダリング [クリックして展開]
from transformers import AutoTokenizer
model_id = "CohereForAI/c4ai-command-r-plus"
tokenizer = AutoTokenizer.from_pretrained(model_id)
# define conversation input:
conversation = [
{"role": "user", "content": "Whats the biggest penguin in the world?"}
]
# Define tools available for the model to use:
tools = [
{
"name": "internet_search",
"description": "Returns a list of relevant document snippets for a textual query retrieved from the internet",
"parameter_definitions": {
"query": {
"description": "Query to search the internet with",
"type": 'str',
"required": True
}
}
},
{
'name': "directly_answer",
"description": "Calls a standard (un-augmented) AI chatbot to generate a response given the conversation history",
'parameter_definitions': {}
}
]
# render the tool use prompt as a string:
tool_use_prompt = tokenizer.apply_tool_use_template(
conversation,
tools=tools,
tokenize=False,
add_generation_prompt=True,
)
print(tool_use_prompt)
レンダリングされたツール使用プロンプトの例 [クリックして展開]
<BOS_TOKEN><|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|># Safety Preamble
The instructions in this section override those in the task description and style guide sections. Don't answer questions that are harmful or immoral.
# System Preamble
## Basic Rules
You are a powerful conversational AI trained by Cohere to help people. You are augmented by a number of tools, and your job is to use and consume the output of these tools to best help the user. You will see a conversation history between yourself and a user, ending with an utterance from the user. You will then see a specific instruction instructing you what kind of response to generate. When you answer the user's requests, you cite your sources in your answers, according to those instructions.
# User Preamble
## Task and Context
You help people answer their questions and other requests interactively. You will be asked a very wide array of requests on all kinds of topics. You will be equipped with a wide range of search engines or similar tools to help you, which you use to research your answer. You should focus on serving the user's needs as best you can, which will be wide-ranging.
## Style Guide
Unless the user asks for a different style of answer, you should answer in full sentences, using proper grammar and spelling.
## Available Tools
Here is a list of tools that you have available to you:
```python
def internet_search(query: str) -> List[Dict]:
"""Returns a list of relevant document snippets for a textual query retrieved from the internet"""
</details>
## 💻 使用例
### 基本的な使用法
```python
# pip install 'git+https://github.com/huggingface/transformers.git'
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "CohereForAI/c4ai-command-r-plus"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
# Format message with the command-r-plus chat template
messages = [{"role": "user", "content": "Hello, how are you?"}]
input_ids = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt")
## <BOS_TOKEN><|START_OF_TURN_TOKEN|><|USER_TOKEN|>Hello, how are you?<|END_OF_TURN_TOKEN|><|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>
gen_tokens = model.generate(
input_ids,
max_new_tokens=100,
do_sample=True,
temperature=0.3,
)
gen_text = tokenizer.decode(gen_tokens[0])
print(gen_text)
高度な使用法
8ビット精度での量子化モデル
# pip install 'git+https://github.com/huggingface/transformers.git' bitsandbytes accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
bnb_config = BitsAndBytesConfig(load_in_8bit=True)
model_id = "CohereForAI/c4ai-command-r-plus"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=bnb_config)
# Format message with the command-r-plus chat template
messages = [{"role": "user", "content": "Hello, how are you?"}]
input_ids = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt")
## <BOS_TOKEN><|START_OF_TURN_TOKEN|><|USER_TOKEN|>Hello, how are you?<|END_OF_TURN_TOKEN|><|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>
gen_tokens = model.generate(
input_ids,
max_new_tokens=100,
do_sample=True,
temperature=0.3,
)
gen_text = tokenizer.decode(gen_tokens[0])
print(gen_text)
4ビット精度での量子化モデル
このモデルはC4AI Command R+の非量子化バージョンです。bitsandbytesを使用したC4AI Command R+の量子化バージョンは、こちらで見つけることができます。
📚 ドキュメント
元のモデルカード: CohereForAIのC4AI Command R+
C4AI Command R+は、高度な機能を備えた1040億パラメータのモデルのオープンウェイト研究リリースです。これには、Retrieval Augmented Generation (RAG) や、複雑なタスクを自動化するためのツールの使用が含まれます。このモデルの生成におけるツールの使用は、多段階のツール使用を可能にし、モデルが複数のステップにわたって複数のツールを組み合わせて難しいタスクを達成できるようにします。C4AI Command R+は、英語、フランス語、スペイン語、イタリア語、ドイツ語、ブラジルポルトガル語、日本語、韓国語、アラビア語、および簡体字中国語の10か国語でのパフォーマンスが評価された多言語モデルです。Command R+は、推論、要約、質問応答などのさまざまなユースケースに最適化されています。
モデルの詳細情報
属性 | 詳情 |
---|---|
モデルタイプ | C4AI Command R+ |
開発者 | Cohere と Cohere For AI |
連絡先 | Cohere For AI: cohere.for.ai |
ライセンス | CC - BY - NC。C4AIの許容使用ポリシーにも準拠する必要があります。 |
モデルサイズ | 1040億パラメータ |
コンテキスト長 | 128K |
モデルの試用
重みをダウンロードする前に、ホストされているHugging Face SpaceでC4AI Command R+を試すことができます。
📄 ライセンス
このモデルはCC - BY - NCライセンスの下で提供されており、C4AIの許容使用ポリシーにも準拠する必要があります。



