Instructions to use CohereLabs/aya-expanse-8b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CohereLabs/aya-expanse-8b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="CohereLabs/aya-expanse-8b") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("CohereLabs/aya-expanse-8b") model = AutoModelForCausalLM.from_pretrained("CohereLabs/aya-expanse-8b", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use CohereLabs/aya-expanse-8b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "CohereLabs/aya-expanse-8b" # 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/aya-expanse-8b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/CohereLabs/aya-expanse-8b
- SGLang
How to use CohereLabs/aya-expanse-8b 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/aya-expanse-8b" \ --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/aya-expanse-8b", "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/aya-expanse-8b" \ --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/aya-expanse-8b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use CohereLabs/aya-expanse-8b with Docker Model Runner:
docker model run hf.co/CohereLabs/aya-expanse-8b
First impression: Impressed
Seems to be a nice model if you need to learn languages or something :) Translate from one to another etc. A little problem is that i never know how to use promt format correctly in llama.cpp. This is how i use it : --in-prefix "<|START_OF_TURN_TOKEN|><|USER_TOKEN|><|END_OF_TURN_TOKEN|>" --in-suffix "<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>" -p "<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>You are Aya, a brilliant, sophisticated, multilingual AI-assistant trained to assist human users by providing thorough responses. You are able to interact and respond to questions in 23 languages and you are powered by a multilingual model built by Cohere For AI.<|END_OF_TURN_TOKEN|>"
The model seems to perform well :) But still maybe someone could correct this if i did it wrong.
PS: holy s... it even answered this pretty hard question, that very few models can answer :) : Sally (a girl) has 3 brothers. Each brother has 2 sisters. How many sisters does Sally have?
Let's analyze the relationships:
Sally is a girl with 3 brothers.
Each of her brothers has 2 sisters. Since siblings share the same parents, these 2 sisters must include Sally herself.
So, apart from Sally, there is one more sister besides her. Thus, Sally has 1 sister.
Also, looks like there is one annoying problem. Once you ask it to speak different language, or just translate something. How do you make it speak english again? :) Looks like its impossible to do. Doesn't matter how you tell it to speak english, it continues to speak that language.
Hi @urtuuuu , thank you for the great feedback. Glad you're liking the model!
Regarding prompt format, when prompting for generation the last two tokens should always be <|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>.
for example if the system preamble is "you are a multilingual assistant named mystery bot", and the prompt is "who are you?" the input should be
<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>you are a multilingual assistant named mystery bot<|END_OF_TURN_TOKEN|><|START_OF_TURN_TOKEN|><|USER_TOKEN|>who are you?<|END_OF_TURN_TOKEN|><|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>
if instead there is no system preamble (which is recommended btw), the input should be:
<|START_OF_TURN_TOKEN|><|USER_TOKEN|>who are you?<|END_OF_TURN_TOKEN|><|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>
if you're using transformers the recommended way to automatically do this is by passing in messages format to tokenizer.apply_chat_template which does this all for you. This is shown as an example in our model card readme.
Also, looks like there is one annoying problem. Once you ask it to speak different language, or just translate something. How do you make it speak english again? :) Looks like its impossible to do. Doesn't matter how you tell it to speak english, it continues to speak that language.
regarding this, we've made some fixes for this on our end but it's possible the model may still miss this sometimes. Would just recommend trying again with a different prompt.I would also recommend trying out the 32B...this issue is more or less solved for the 32B.