Update README.md
Browse files
README.md
CHANGED
@@ -102,6 +102,37 @@ outputs = model.generate(**inputs, max_new_tokens=20)
|
|
102 |
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
103 |
```
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
> [!TIP]
|
106 |
> Unlike previous Mistral models, Mistral Nemo requires smaller temperatures. We recommend to use a temperature of 0.3.
|
107 |
|
|
|
102 |
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
103 |
```
|
104 |
|
105 |
+
## Accelerator mode:
|
106 |
+
|
107 |
+
```py
|
108 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
109 |
+
from accelerate import Accelerator
|
110 |
+
|
111 |
+
# Initialize the accelerator
|
112 |
+
accelerator = Accelerator()
|
113 |
+
|
114 |
+
# Define the model ID
|
115 |
+
model_id = "EpistemeAI/Fireball-12B"
|
116 |
+
|
117 |
+
# Load the tokenizer
|
118 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
119 |
+
|
120 |
+
# Load the model and prepare it for distributed setup using accelerate
|
121 |
+
model = AutoModelForCausalLM.from_pretrained(model_id)
|
122 |
+
|
123 |
+
# Move the model to the appropriate device using accelerate
|
124 |
+
model, = accelerator.prepare(model)
|
125 |
+
|
126 |
+
# Prepare inputs
|
127 |
+
inputs = tokenizer("Hello my name is", return_tensors="pt").to(accelerator.device)
|
128 |
+
|
129 |
+
# Generate outputs with the model
|
130 |
+
outputs = model.generate(**inputs, max_new_tokens=20)
|
131 |
+
|
132 |
+
# Decode and print the outputs
|
133 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
134 |
+
```
|
135 |
+
|
136 |
> [!TIP]
|
137 |
> Unlike previous Mistral models, Mistral Nemo requires smaller temperatures. We recommend to use a temperature of 0.3.
|
138 |
|