Update README.md
Browse files
README.md
CHANGED
@@ -46,4 +46,29 @@ models:
|
|
46 |
merge_method: linear
|
47 |
dtype: float16
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
```
|
|
|
46 |
merge_method: linear
|
47 |
dtype: float16
|
48 |
|
49 |
+
```
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
+
```Python
|
54 |
+
|
55 |
+
!pip install -qU transformers
|
56 |
+
|
57 |
+
import transformers
|
58 |
+
import torch
|
59 |
+
|
60 |
+
from transformers import AutoTokenizer, MixtralForCausalLM
|
61 |
+
device = "cuda" # the device to load the model onto
|
62 |
+
|
63 |
+
model = "{{ username }}/{{ model_name }}"
|
64 |
+
imodel = MixtralForCausalLM.from_pretrained(model)
|
65 |
+
tokenizer = AutoTokenizer.from_pretrained(model)
|
66 |
+
|
67 |
+
|
68 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
69 |
+
|
70 |
+
# Generate
|
71 |
+
generate_ids = imodel.generate(inputs.input_ids, max_length=30)
|
72 |
+
tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
73 |
+
|
74 |
```
|