Instructions to use nvidia/Riva-Translate-4B-Instruct-v1.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/Riva-Translate-4B-Instruct-v1.1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nvidia/Riva-Translate-4B-Instruct-v1.1") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("nvidia/Riva-Translate-4B-Instruct-v1.1") model = AutoModelForMultimodalLM.from_pretrained("nvidia/Riva-Translate-4B-Instruct-v1.1") 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 nvidia/Riva-Translate-4B-Instruct-v1.1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nvidia/Riva-Translate-4B-Instruct-v1.1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nvidia/Riva-Translate-4B-Instruct-v1.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nvidia/Riva-Translate-4B-Instruct-v1.1
- SGLang
How to use nvidia/Riva-Translate-4B-Instruct-v1.1 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 "nvidia/Riva-Translate-4B-Instruct-v1.1" \ --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": "nvidia/Riva-Translate-4B-Instruct-v1.1", "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 "nvidia/Riva-Translate-4B-Instruct-v1.1" \ --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": "nvidia/Riva-Translate-4B-Instruct-v1.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nvidia/Riva-Translate-4B-Instruct-v1.1 with Docker Model Runner:
docker model run hf.co/nvidia/Riva-Translate-4B-Instruct-v1.1
Update README.md
Browse files
README.md
CHANGED
|
@@ -20,40 +20,6 @@ Training followed a multi-stage pipeline consisting of Continued Pre-Training (C
|
|
| 20 |
## License
|
| 21 |
GOVERNING TERMS: The NIM container is governed by the [NVIDIA Software License Agreement](https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-software-license-agreement/) and [Product-Specific Terms for AI Products](https://www.nvidia.com/en-us/agreements/enterprise-software/product-specific-terms-for-ai-products/). Use of this model is governed by the [NVIDIA Community Model License](https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-community-models-license/). ADDITIONAL INFORMATION: [Apache 2.0](https://huggingface.co/datasets/choosealicense/licenses/blob/main/markdown/apache-2.0.md). <br>
|
| 22 |
|
| 23 |
-
## Prompt Format:
|
| 24 |
-
|
| 25 |
-
Optimal performance is achieved when using the prompt shown below.
|
| 26 |
-
```
|
| 27 |
-
<s>System
|
| 28 |
-
{system prompt}</s>
|
| 29 |
-
<s>User
|
| 30 |
-
{user prompt}</s>
|
| 31 |
-
<s>Assistant\n
|
| 32 |
-
```
|
| 33 |
-
- Note that a newline character (\n) should be added after `<s>Assistant` as a generation prompt.
|
| 34 |
-
- Note that users are required to use the correct language name in the prompt:
|
| 35 |
-
'ar': 'Arabic',
|
| 36 |
-
'en': 'English',
|
| 37 |
-
'de': 'German',
|
| 38 |
-
'es-es': 'European Spanish',
|
| 39 |
-
'es-us': 'Latin American Spanish',
|
| 40 |
-
'fr': 'French',
|
| 41 |
-
'ja': 'Japanese',
|
| 42 |
-
'ko': 'Korean',
|
| 43 |
-
'ru': 'Russian',
|
| 44 |
-
'zh-cn': 'Simplified Chinese',
|
| 45 |
-
'zh-tw': 'Traditional Chinese',
|
| 46 |
-
'pt-br': 'Brazilian Portuguese'
|
| 47 |
-
|
| 48 |
-
For example, to translate an English sentence into Simplified Chinese:
|
| 49 |
-
```
|
| 50 |
-
<s>System
|
| 51 |
-
You are an expert at translating text from English to Simplified Chinese.</s>
|
| 52 |
-
<s>User
|
| 53 |
-
What is the Simplified Chinese translation of the sentence: The GRACE mission is a collaboration between the NASA and German Aerospace Center.?</s>
|
| 54 |
-
<s>Assistant
|
| 55 |
-
```
|
| 56 |
-
|
| 57 |
## Quick Start Guide
|
| 58 |
|
| 59 |
### How to Choose the Language Pair
|
|
|
|
| 20 |
## License
|
| 21 |
GOVERNING TERMS: The NIM container is governed by the [NVIDIA Software License Agreement](https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-software-license-agreement/) and [Product-Specific Terms for AI Products](https://www.nvidia.com/en-us/agreements/enterprise-software/product-specific-terms-for-ai-products/). Use of this model is governed by the [NVIDIA Community Model License](https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-community-models-license/). ADDITIONAL INFORMATION: [Apache 2.0](https://huggingface.co/datasets/choosealicense/licenses/blob/main/markdown/apache-2.0.md). <br>
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
## Quick Start Guide
|
| 24 |
|
| 25 |
### How to Choose the Language Pair
|