Instructions to use CohereLabs/tiny-aya-global with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CohereLabs/tiny-aya-global with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="CohereLabs/tiny-aya-global") 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("CohereLabs/tiny-aya-global") model = AutoModelForCausalLM.from_pretrained("CohereLabs/tiny-aya-global", 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 CohereLabs/tiny-aya-global with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "CohereLabs/tiny-aya-global" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CohereLabs/tiny-aya-global", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/CohereLabs/tiny-aya-global
- SGLang
How to use CohereLabs/tiny-aya-global 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 "CohereLabs/tiny-aya-global" \ --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": "CohereLabs/tiny-aya-global", "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 "CohereLabs/tiny-aya-global" \ --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": "CohereLabs/tiny-aya-global", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use CohereLabs/tiny-aya-global with Docker Model Runner:
docker model run hf.co/CohereLabs/tiny-aya-global
generation_config.json stops on <EOS_TOKEN> (id 3), but chat turns end with <|END_OF_TURN_TOKEN|> (id 6)
Hi, thanks for releasing Tiny Aya. I found a small mismatch in the stop token settings that wastes generation time.
What I see
generation_config.json and config.json set eos_token_id to 3 (<EOS_TOKEN>), but the tokenizer's EOS token is <|END_OF_TURN_TOKEN|> (id 6), which is what ends an assistant turn in the chat template.
from transformers import AutoTokenizer, GenerationConfig
m = "CohereLabs/tiny-aya-global"
print(GenerationConfig.from_pretrained(m).eos_token_id) # 3
print(AutoTokenizer.from_pretrained(m).eos_token_id) # 6
Checked on revision af89d219.
Effect
With model.generate(...) and the default generation config, generation only stops on token 3. In my runs with greedy decoding, the model finished its answer with token 6 and then kept emitting token 6 until max_new_tokens. The extra tokens are special tokens, so they disappear when decoding with skip_special_tokens=True and the text looks normal. The cost is hidden: every answer uses the full token budget, and a library that only returns decoded text cannot tell that the answer finished early.
After passing both ids as stop tokens, one batch of four answers went from about 30 s to about 7 s on my machine (768 new tokens allowed).
Workaround
model.generate(**inputs, eos_token_id=[3, 6], ...)
Suggested fix
Set "eos_token_id": [3, 6] in generation_config.json, so chat generation stops at the end of the turn by default. It may be worth checking the other Tiny Aya variants for the same setting.
Hey @Oakshat Thanks for the detailed report!
We couldn't reproduce the runaway generation. With transformers 5.23, using apply_chat_template(..., add_generation_prompt=True) and the default generation config, the model ends every turn with <|END_RESPONSE|><EOS_TOKEN> and stops on id 3, both greedy and sampled, single and batched. Could you share your full script, your transformers/torch versions, and the raw generated ids from one affected answer? Thanks!
Thanks @alexrs , you are right, and sorry for the noise. I reran it today and the base model stops correctly. My first report mixed up the base model with my own fine-tune.
Setup: transformers 5.19.0, torch 2.14.1, MPS, bf16, revision af89d219, apply_chat_template(..., add_generation_prompt=True), greedy, default generation config, max_new_tokens=200.
- Base model, "What is the capital of France?":
The capital of France is Paris.<|END_RESPONSE|><EOS_TOKEN>, last ids[..., 261001, 3], stops. - My LoRA fine-tune of tiny-aya-global (SFT on chat data), same prompt: ends with
<|END_RESPONSE|><|END_OF_TURN_TOKEN|>, then repeats id 6 untilmax_new_tokens(last ids[6, 6, 6, 6, 6, 6]).
I think the cause is the chat template. A finished assistant turn renders as <|START_RESPONSE|>Hello.<|END_RESPONSE|><|END_OF_TURN_TOKEN|>, so SFT on chat-template data teaches the model to end with id 6. The base model ends with id 3, and generation_config.json stops only on 3. tokenizer.eos_token is also id 6.
So this affects fine-tunes, not the released model. If it seems worth it, adding 6 to eos_token_id in generation_config.json would make such fine-tunes stop by default. Otherwise feel free to close this.
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
m = "CohereLabs/tiny-aya-global" # or the fine-tuned checkpoint
tok = AutoTokenizer.from_pretrained(m, revision="af89d219")
model = AutoModelForCausalLM.from_pretrained(m, revision="af89d219", dtype=torch.bfloat16).to("mps")
x = tok.apply_chat_template([{"role": "user", "content": "What is the capital of France?"}],
add_generation_prompt=True, return_tensors="pt", return_dict=True).to("mps")
out = model.generate(**x, do_sample=False, max_new_tokens=200)[0, x["input_ids"].shape[1]:].tolist()
print(len(out), out[-6:])
print(tok.decode(out, skip_special_tokens=False))
Thanks for following up and for tracking this down. We reproduced it: a LoRA fine-tune of tiny-aya-global on chat-template data learns to end turns with <|END_OF_TURN_TOKEN|> (id 6), and with the default generation config it never stops.
With eos_token_id: [3, 6] it stops right after the answer, and the released model's output is unchanged. We have added id 6 to generation_config.json for Global, Earth, Fire and Water. Adapters loaded on the base will pick it up automatically. Merged fine-tunes keep their own config, so set "eos_token_id": [3, 6] in theirs, or pass it to generate().