Update README.md
Browse files
README.md
CHANGED
|
@@ -36,7 +36,30 @@ This is the model card of a 🤗 transformers model that has been pushed on the
|
|
| 36 |
|
| 37 |
## Uses
|
| 38 |
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
### Direct Use
|
| 42 |
|
|
|
|
| 36 |
|
| 37 |
## Uses
|
| 38 |
|
| 39 |
+
### Use with transformers
|
| 40 |
+
|
| 41 |
+
Make sure to update your transformers installation via `pip install --upgrade transformers`.
|
| 42 |
+
|
| 43 |
+
```python
|
| 44 |
+
import torch
|
| 45 |
+
from transformers import pipeline
|
| 46 |
+
model_id = "meta-llama/Llama-3.2-3B-Instruct"
|
| 47 |
+
pipe = pipeline(
|
| 48 |
+
"text-generation",
|
| 49 |
+
model=model_id,
|
| 50 |
+
torch_dtype=torch.bfloat16,
|
| 51 |
+
device_map="auto",
|
| 52 |
+
)
|
| 53 |
+
messages = [
|
| 54 |
+
{"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
|
| 55 |
+
{"role": "user", "content": "Who are you?"},
|
| 56 |
+
]
|
| 57 |
+
outputs = pipe(
|
| 58 |
+
messages,
|
| 59 |
+
max_new_tokens=256,
|
| 60 |
+
)
|
| 61 |
+
print(outputs[0]["generated_text"][-1])
|
| 62 |
+
```
|
| 63 |
|
| 64 |
### Direct Use
|
| 65 |
|