Instructions to use Unbabel/Tower-Plus-9B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Unbabel/Tower-Plus-9B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Unbabel/Tower-Plus-9B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Unbabel/Tower-Plus-9B") model = AutoModelForCausalLM.from_pretrained("Unbabel/Tower-Plus-9B") 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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Unbabel/Tower-Plus-9B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Unbabel/Tower-Plus-9B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Unbabel/Tower-Plus-9B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Unbabel/Tower-Plus-9B
- SGLang
How to use Unbabel/Tower-Plus-9B 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 "Unbabel/Tower-Plus-9B" \ --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": "Unbabel/Tower-Plus-9B", "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 "Unbabel/Tower-Plus-9B" \ --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": "Unbabel/Tower-Plus-9B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Unbabel/Tower-Plus-9B with Docker Model Runner:
docker model run hf.co/Unbabel/Tower-Plus-9B
Add pipeline tag
Browse filesThis PR adds the `pipeline_tag: text-generation` to the model card's metadata. This ensures that the model can be properly categorized and discovered on the Hugging Face Hub, appearing under searches for text generation models.
README.md
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
---
|
| 2 |
base_model: google/gemma-2-9b
|
| 3 |
-
license: cc-by-nc-sa-4.0
|
| 4 |
language:
|
| 5 |
- de
|
| 6 |
- nl
|
|
@@ -25,6 +24,8 @@ language:
|
|
| 25 |
- ro
|
| 26 |
- fi
|
| 27 |
library_name: transformers
|
|
|
|
|
|
|
| 28 |
---
|
| 29 |
|
| 30 |

|
|
@@ -71,7 +72,9 @@ sampling_params = SamplingParams(
|
|
| 71 |
max_tokens=8192,
|
| 72 |
)
|
| 73 |
llm = LLM(model="Unbabel/Tower-Plus-9B", tensor_parallel_size=1)
|
| 74 |
-
messages = [{"role": "user", "content": "Translate the following English source text to Portuguese (Portugal):
|
|
|
|
|
|
|
| 75 |
outputs = llm.chat(messages, sampling_params)
|
| 76 |
# Make sure your prompt_token_ids look like this
|
| 77 |
print (outputs[0].outputs[0].text)
|
|
@@ -89,7 +92,9 @@ from transformers import pipeline
|
|
| 89 |
|
| 90 |
pipe = pipeline("text-generation", model="Unbabel/Tower-Plus-9B", device_map="auto")
|
| 91 |
# We use the tokenizer’s chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
|
| 92 |
-
messages = [{"role": "user", "content": "Translate the following English source text to Portuguese (Portugal):
|
|
|
|
|
|
|
| 93 |
input_ids = pipe.tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True)
|
| 94 |
outputs = pipe(messages, max_new_tokens=256, do_sample=False)
|
| 95 |
print(outputs[0]["generated_text"])
|
|
|
|
| 1 |
---
|
| 2 |
base_model: google/gemma-2-9b
|
|
|
|
| 3 |
language:
|
| 4 |
- de
|
| 5 |
- nl
|
|
|
|
| 24 |
- ro
|
| 25 |
- fi
|
| 26 |
library_name: transformers
|
| 27 |
+
license: cc-by-nc-sa-4.0
|
| 28 |
+
pipeline_tag: text-generation
|
| 29 |
---
|
| 30 |
|
| 31 |

|
|
|
|
| 72 |
max_tokens=8192,
|
| 73 |
)
|
| 74 |
llm = LLM(model="Unbabel/Tower-Plus-9B", tensor_parallel_size=1)
|
| 75 |
+
messages = [{"role": "user", "content": "Translate the following English source text to Portuguese (Portugal):
|
| 76 |
+
English: Hello world!
|
| 77 |
+
Portuguese (Portugal): "}]
|
| 78 |
outputs = llm.chat(messages, sampling_params)
|
| 79 |
# Make sure your prompt_token_ids look like this
|
| 80 |
print (outputs[0].outputs[0].text)
|
|
|
|
| 92 |
|
| 93 |
pipe = pipeline("text-generation", model="Unbabel/Tower-Plus-9B", device_map="auto")
|
| 94 |
# We use the tokenizer’s chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
|
| 95 |
+
messages = [{"role": "user", "content": "Translate the following English source text to Portuguese (Portugal):
|
| 96 |
+
English: Hello world!
|
| 97 |
+
Portuguese (Portugal): "}]
|
| 98 |
input_ids = pipe.tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True)
|
| 99 |
outputs = pipe(messages, max_new_tokens=256, do_sample=False)
|
| 100 |
print(outputs[0]["generated_text"])
|