Text Generation
Transformers
Safetensors
cohere
mergekit
Merge
conversational
text-generation-inference
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)# 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") 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 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
Which Mergekit did you use for this?
#1
by softwareweaver - opened
Which Mergekit did you use for this? The standard one did not work. Thanks.
That's completely correct.
Mergekit has two issues to merge CohereForAI/c4ai-command-r-plus.
- The layers added in
c4ai-command-r-plusis not supported. - The
lm_headsection on cohere.json causes an unsupported model in llama.cpp.
So I wrote a patch for these issues:
--- a/mergekit/_data/architectures/cohere.json
+++ b/mergekit/_data/architectures/cohere.json
@@ -12,13 +12,6 @@
"post_weights": [
{
"name": "model.norm.weight"
- },
- {
- "name": "lm_head.weight",
- "is_embed": true,
- "aliases": [
- "model.embed_tokens.weight"
- ]
}
],
"num_layers_config_key": "num_hidden_layers",
@@ -36,9 +29,15 @@
{
"name": "model.layers.${layer_index}.mlp.up_proj.weight"
},
+ {
+ "name": "model.layers.${layer_index}.self_attn.q_norm.weight"
+ },
{
"name": "model.layers.${layer_index}.self_attn.q_proj.weight"
},
+ {
+ "name": "model.layers.${layer_index}.self_attn.k_norm.weight"
+ },
{
"name": "model.layers.${layer_index}.self_attn.k_proj.weight"
},
This is a hack, but it works fine for c4ai-command-r-plus self-merging.
Thanks. I will try that. I was thinking of merging command-r with softwareweaver/Twilight-Miqu-146B
nitky changed discussion status to closed