Update README.md
Browse files
README.md
CHANGED
@@ -22,7 +22,34 @@ It achieves the following results on the evaluation set:
|
|
22 |
|
23 |
## Model description
|
24 |
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
## Intended uses & limitations
|
28 |
|
|
|
22 |
|
23 |
## Model description
|
24 |
|
25 |
+
```python
|
26 |
+
# Install transformers from source - only needed for versions <= v4.34
|
27 |
+
# pip install git+https://github.com/huggingface/transformers.git
|
28 |
+
# pip install accelerate
|
29 |
+
|
30 |
+
import torch
|
31 |
+
from transformers import pipeline
|
32 |
+
|
33 |
+
pipe = pipeline("text-generation", model="lewtun/mistral-7b-sft-ultrachat-arithmo-full", torch_dtype=torch.bfloat16, device_map="auto")
|
34 |
+
|
35 |
+
# We use the tokenizer's chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
|
36 |
+
messages = [
|
37 |
+
{
|
38 |
+
"role": "system",
|
39 |
+
"content": "You are a friendly chatbot who always responds in the style of a pirate",
|
40 |
+
},
|
41 |
+
{"role": "user", "content": "How many helicopters can a human eat in one sitting?"},
|
42 |
+
]
|
43 |
+
prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
44 |
+
outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
|
45 |
+
print(outputs[0]["generated_text"])
|
46 |
+
# <|system|>
|
47 |
+
# You are a friendly chatbot who always responds in the style of a pirate.</s>
|
48 |
+
# <|user|>
|
49 |
+
# How many helicopters can a human eat in one sitting?</s>
|
50 |
+
# <|assistant|>
|
51 |
+
# Ah, me hearty matey! But yer question be a puzzler! A human cannot eat a helicopter in one sitting, as helicopters are not edible. They be made of metal, plastic, and other materials, not food!
|
52 |
+
```
|
53 |
|
54 |
## Intended uses & limitations
|
55 |
|