Instructions to use trl-internal-testing/tiny-Cohere2ForCausalLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use trl-internal-testing/tiny-Cohere2ForCausalLM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="trl-internal-testing/tiny-Cohere2ForCausalLM") 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("trl-internal-testing/tiny-Cohere2ForCausalLM") model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-Cohere2ForCausalLM", 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 trl-internal-testing/tiny-Cohere2ForCausalLM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "trl-internal-testing/tiny-Cohere2ForCausalLM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "trl-internal-testing/tiny-Cohere2ForCausalLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/trl-internal-testing/tiny-Cohere2ForCausalLM
- SGLang
How to use trl-internal-testing/tiny-Cohere2ForCausalLM 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 "trl-internal-testing/tiny-Cohere2ForCausalLM" \ --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": "trl-internal-testing/tiny-Cohere2ForCausalLM", "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 "trl-internal-testing/tiny-Cohere2ForCausalLM" \ --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": "trl-internal-testing/tiny-Cohere2ForCausalLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use trl-internal-testing/tiny-Cohere2ForCausalLM with Docker Model Runner:
docker model run hf.co/trl-internal-testing/tiny-Cohere2ForCausalLM
Use 8-wide attention heads, as Flash Attention requires
#4
by qgallouedec HF Staff - opened
- config.json +1 -1
- model.safetensors +2 -2
- tokenizer_config.json +2 -3
config.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
| 9 |
"cache_implementation": "hybrid",
|
| 10 |
"dtype": "bfloat16",
|
| 11 |
"eos_token_id": 3,
|
| 12 |
-
"head_dim":
|
| 13 |
"hidden_act": "silu",
|
| 14 |
"hidden_size": 8,
|
| 15 |
"initializer_range": 0.02,
|
|
|
|
| 9 |
"cache_implementation": "hybrid",
|
| 10 |
"dtype": "bfloat16",
|
| 11 |
"eos_token_id": 3,
|
| 12 |
+
"head_dim": 8,
|
| 13 |
"hidden_act": "silu",
|
| 14 |
"hidden_size": 8,
|
| 15 |
"initializer_range": 0.02,
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2a1b32199d2c7c4ba87f768ac1800e1ba507d055b9057992f575f5ad83486068
|
| 3 |
+
size 4202376
|
tokenizer_config.json
CHANGED
|
@@ -202,8 +202,7 @@
|
|
| 202 |
"pad_token": "<PAD>",
|
| 203 |
"sp_model_kwargs": {},
|
| 204 |
"spaces_between_special_tokens": false,
|
| 205 |
-
"tokenizer_class": "
|
| 206 |
"unk_token": "<UNK>",
|
| 207 |
-
"use_default_system_prompt": false
|
| 208 |
-
"vocab_file": null
|
| 209 |
}
|
|
|
|
| 202 |
"pad_token": "<PAD>",
|
| 203 |
"sp_model_kwargs": {},
|
| 204 |
"spaces_between_special_tokens": false,
|
| 205 |
+
"tokenizer_class": "PreTrainedTokenizerFast",
|
| 206 |
"unk_token": "<UNK>",
|
| 207 |
+
"use_default_system_prompt": false
|
|
|
|
| 208 |
}
|