Mujojojo commited on
Commit
796c3d2
·
verified ·
1 Parent(s): fe5183d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +22 -0
README.md CHANGED
@@ -58,6 +58,28 @@ What is the Simplified Chinese translation of the sentence: The GRACE mission is
58
  <s>Assistant
59
  ```
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  ## Ethical Considerations:
62
  NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable development for a wide array of AI applications. When downloaded or used in accordance with our terms of service, developers should work with their internal model team to ensure this model meets requirements for the relevant industry and use case and addresses unforeseen product misuse.
63
 
 
58
  <s>Assistant
59
  ```
60
 
61
+ ## Usage
62
+ ```python
63
+ from transformers import AutoTokenizer, AutoModelForCausalLM
64
+
65
+
66
+ tokenizer = AutoTokenizer.from_pretrained("nvidia/Riva-Translate-4B-Instruct")
67
+ model = AutoModelForCausalLM.from_pretrained("nvidia/Riva-Translate-4B-Instruct").cuda()
68
+
69
+
70
+ # Use the prompt template
71
+ messages = [
72
+ {
73
+ "role": "system",
74
+ "content": "You are an expert at translating text from English to Simplified Chinese.",
75
+ },
76
+ {"role": "user", "content": "What is the Simplified Chinese translation of the sentence: The GRACE mission is a collaboration between the NASA and German Aerospace Center.?"},
77
+ ]
78
+ tokenized_chat = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(model.device)
79
+ outputs = model.generate(tokenized_chat, max_new_tokens=128, pad_token_id=tokenizer.eos_token_id)
80
+ print(tokenizer.decode(outputs[0]))
81
+ ```
82
+
83
  ## Ethical Considerations:
84
  NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable development for a wide array of AI applications. When downloaded or used in accordance with our terms of service, developers should work with their internal model team to ensure this model meets requirements for the relevant industry and use case and addresses unforeseen product misuse.
85