Instructions to use nitky/Megac4ai-command-r-plus with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nitky/Megac4ai-command-r-plus with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nitky/Megac4ai-command-r-plus") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("nitky/Megac4ai-command-r-plus") model = AutoModelForCausalLM.from_pretrained("nitky/Megac4ai-command-r-plus", device_map="auto") 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use nitky/Megac4ai-command-r-plus with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nitky/Megac4ai-command-r-plus" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nitky/Megac4ai-command-r-plus", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nitky/Megac4ai-command-r-plus
- SGLang
How to use nitky/Megac4ai-command-r-plus 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 "nitky/Megac4ai-command-r-plus" \ --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": "nitky/Megac4ai-command-r-plus", "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 "nitky/Megac4ai-command-r-plus" \ --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": "nitky/Megac4ai-command-r-plus", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nitky/Megac4ai-command-r-plus with Docker Model Runner:
docker model run hf.co/nitky/Megac4ai-command-r-plus
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("nitky/Megac4ai-command-r-plus")
model = AutoModelForCausalLM.from_pretrained("nitky/Megac4ai-command-r-plus", device_map="auto")
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=256)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))Megac4ai-command-r-plus
๐จ This model is created using the special mergekit that supports c4ai-command-r-plus.
This is a 160b frankenmerge model created by interleaving layers of CohereForAI/c4ai-command-r-plus with itself using mergekit.
Output comparison
Test Case Details
Condition: temperature=0.3
<|START_OF_TURN_TOKEN|><|USER_TOKEN|>ใใฃใ : ใใใ่ชฟๅญใฏใฉใ๏ผ
ใญใ : ใใใใใใใใจใใฆใใใ ใใฉใใพใๅ
ๅปถใฐใใซใใกใใฃใใใ
ใใฃใ : ไฝใใใใใจใใฆใใใฎ๏ผ
ใญใ : ๅคงๅญฆใฎ่ชฒ้กใ ใใใฉใใซใใใๆฐใๅบใชใใฆใญใ
ใใฃใ : ้ไธญใงใใชใใชใใใใขใใผใญใปใใฏใใใฏใใใใจใใใใ
ใญใ : ไฝใใ๏ผ
ใใฃใ : 25ๅไฝๆฅญใใฆใ5ๅไผๆฉใใใฎใ็นฐใ่ฟใใใ ใใไธๅใใใใฎไฝๆฅญๆ้ใ็ญใใฆ้ไธญใงใใใใ
ใญใ : ใใผใใ้ไธญใฃใฆใใใใใใใชใใใ ใใญ
ใใฃใ : ใใใ1ๆฅใซ5ๅใ ใใงใใใใๆบใง่ชฒ้กใใใใฃใฆใใใฎใฏใฉใ๏ผ
ใญใ : 5ๅใใไฝใใงใใชใใชใ๏ผ
ใใฃใ : ็ญใๆ้ใงใใใใใๆบใงไฝๆฅญใใใฃใฆใใใฎใใใคใณใใชใใ ใใใใใใใฃใจใใใใใใใใใงๆญขใใฆใใใจๆฏๆฅ็ถใใใฃใจ้ทใๆ้ใงใใใใใซใชใใใ
ใญใ : ็ขบใใซใใใชใใงใใใใใใใใใจใ๏ผ
Q: ใญใ ใฏไฝใใใฃใฆใฟใใใจใใฆใใพใใ๏ผใพใไฝๆ
ใใใใใใใจใใฆใใพใใ๏ผ<|END_OF_TURN_TOKEN|><|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>
This task is included in elyza/ELYZA-tasks-100.
Output Example
| Model | Output |
|---|---|
| CohereForAI/c4ai-command-r-plus | ใญใ ใฏๅคงๅญฆใฎ่ชฒ้กใใใใใจใใฆใใพใใใใใใใใๆฐใ่ตทใใใๅ ๅปถใฐใใซใใฆใใพใฃใใใใงใใ |
| nitky/Megac4ai-command-r-plus | ใญใ ใฏๅคงๅญฆใฎ่ชฒ้กใใใใใจใใฆใใพใใใใๆฐใๅบใใ้ไธญใใฆไฝๆฅญใใใใจใใงใใชใใใใใใฃใ ใซใขใใใคในใๆฑใใฆใใพใใใใฃใ ใๆๆกใใใใขใใผใญใปใใฏใใใฏใใ1ๆฅใซ5ๅใ ใๆบใง่ชฒ้กใใใใจใใๆนๆณใ่ฉฆใใใจใงใ่ชฒ้กใซๅใ็ตใ็ฟๆ ฃใ่บซใซใคใใใใจใใฆใใพใใ |
Test environment
This model was tested using text-generation-webui. I use preset min_p and Null preset with temperature=0.3 for Generation.
Usage
Please install transformers from the source repository that includes the necessary changes for this model.
# pip install 'git+https://github.com/huggingface/transformers.git'
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "nitky/megac4ai-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)
Quantized model through bitsandbytes, 4-bit precision
# pip install 'git+https://github.com/huggingface/transformers.git' bitsandbytes accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
bnb_config = BitsAndBytesConfig(load_in_4bit=True)
model_id = "nitky/megac4ai-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)
Merge Details
Merge Method
This model was merged using the passthrough merge method.
Models Merged
The following models were included in the merge:
Configuration
The following YAML configuration was used to produce this model:
dtype: float16
merge_method: passthrough
slices:
- sources:
- layer_range: [0, 20]
model: CohereForAI/c4ai-command-r-plus
- sources:
- layer_range: [11, 31]
model: CohereForAI/c4ai-command-r-plus
- sources:
- layer_range: [22, 42]
model: CohereForAI/c4ai-command-r-plus
- sources:
- layer_range: [33, 53]
model: CohereForAI/c4ai-command-r-plus
- sources:
- layer_range: [44, 64]
model: CohereForAI/c4ai-command-r-plus
- Downloads last month
- 19
Model tree for nitky/Megac4ai-command-r-plus
Base model
CohereLabs/c4ai-command-r-plus
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nitky/Megac4ai-command-r-plus") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)