Update README.md
Browse files
README.md
CHANGED
@@ -3,3 +3,31 @@ datasets:
|
|
3 |
- TinyPixel/orca-bad
|
4 |
---
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
- TinyPixel/orca-bad
|
4 |
---
|
5 |
|
6 |
+
## Usage
|
7 |
+
|
8 |
+
```python
|
9 |
+
!pip install -q -U trl transformers accelerate git+https://github.com/huggingface/peft.git
|
10 |
+
!pip install -q datasets bitsandbytes einops wandb sentencepiece transformers_stream_generator tiktoken
|
11 |
+
|
12 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
13 |
+
import torch
|
14 |
+
|
15 |
+
tokenizer = AutoTokenizer.from_pretrained("TinyPixel/qwen-1.8B-OrcaMini", trust_remote_code=True)
|
16 |
+
model = AutoModelForCausalLM.from_pretrained("TinyPixel/qwen-1.8B-OrcaMini", torch_dtype=torch.bfloat16, device_map="auto", trust_remote_code=True)
|
17 |
+
|
18 |
+
device = "cuda:0"
|
19 |
+
|
20 |
+
text = '''SYSTEM:
|
21 |
+
USER: what is the difference between a dog and a cat on a biological level?
|
22 |
+
ASSISTANT:'''
|
23 |
+
|
24 |
+
inputs = tokenizer(text, return_tensors="pt").to(device)
|
25 |
+
outputs = model.generate(**inputs,
|
26 |
+
max_new_tokens=512,
|
27 |
+
do_sample=True,
|
28 |
+
top_p=0.95,
|
29 |
+
temperature=0.7,
|
30 |
+
top_k=50)
|
31 |
+
|
32 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=False))
|
33 |
+
```
|