mzbac commited on
Commit
6626591
1 Parent(s): 824657d

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +36 -0
README.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ A Moe model built on top of Qwen1.5-7B-Chat, Qwen1.5-7B and Crystalcareai/CrystalQwen-1.5-7B.
2
+
3
+ ```
4
+ from transformers import AutoModelForCausalLM, AutoTokenizer
5
+ import torch
6
+
7
+ model_id = "mzbac/qwen-1.5-2x3-hf"
8
+
9
+ model = AutoModelForCausalLM.from_pretrained(
10
+ model_id,
11
+ torch_dtype=torch.bfloat16,
12
+ load_in_4bit=True,
13
+ trust_remote_code=True,
14
+ )
15
+
16
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
17
+
18
+ chat = [
19
+ {"role": "user", "content": "how backpropagation works?"},
20
+ {"role": "assistant", "content": "\n"},
21
+ ]
22
+
23
+ text = tokenizer.apply_chat_template(chat, tokenize=False)
24
+
25
+ inputs = tokenizer.encode(text, return_tensors="pt").to("cuda")
26
+
27
+ generate_kwargs = dict(
28
+ input_ids=inputs,
29
+ temperature=0.6,
30
+ max_new_tokens=500,
31
+ do_sample=True,
32
+ )
33
+
34
+ outputs = model.generate(**generate_kwargs)
35
+ print(tokenizer.decode(outputs[0]))
36
+ ```