Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3quantized_model_dir = "Intel/DeepSeek-R1-0528-Qwen3-8B-int4-AutoRound-gptq-inc"
4
5model = AutoModelForCausalLM.from_pretrained(
6 quantized_model_dir,
7 torch_dtype="auto",
8 device_map="auto",
9)
10
11tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir, trust_remote_code=True)
12prompts = [
13 "9.11和9.8哪个数字大",
14 "How many e in word deepseek",
15 "There are ten birds in a tree. A hunter shoots one. How many are left in the tree?",
16]
17
18texts = []
19for prompt in prompts:
20 messages = [
21 {"role": "user", "content": prompt} ##change this to align with the official usage
22 ]
23 text = tokenizer.apply_chat_template(
24 messages,
25 tokenize=False,
26 add_generation_prompt=True
27 )
28 texts.append(text)
29inputs = tokenizer(texts, return_tensors="pt", padding=True, truncation=True)
30
31outputs = model.generate(
32 input_ids=inputs["input_ids"].to(model.device),
33 attention_mask=inputs["attention_mask"].to(model.device),
34 max_length=512, ##change this to align with the official usage
35 num_return_sequences=1,
36 do_sample=False ##change this to align with the official usage
37)
38generated_ids = [
39 output_ids[len(input_ids):] for input_ids, output_ids in zip(inputs["input_ids"], outputs)
40]
41
42decoded_outputs = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
43
44for i, prompt in enumerate(prompts):
45 input_id = inputs
46 print(f"Prompt: {prompt}")
47 print(f"Generated: {decoded_outputs[i]}")
48 print("-" * 50)
49
50"""
51Prompt: 9.11和9.8哪个数字大
52Generated: <think>
53首先,用户的问题是:“9.11和9.8哪个数字大?”这是一个比较两个数字大小的问题。
54
55数字是9.11和9.8。9.11是九点一一,9.8是九点八。
56
57在比较小数时,我们需要考虑小数点后的位数。9.11有两位小数,9.8有一位小数,但我们可以将它们视为相同的小数位数来比较。
58
599.8可以写成9.80,这样就有两位小数了。所以,9.80和9.11。
60
61现在,比较9.80和9.11。整数部分相同,都是9。所以,我们需要比较小数部分。
62
63小数部分:9.80的十分位是8,百分位是0;9.11的十分位是1,百分位是1。
64
65从十分位开始比较:8 vs 1,8大于1,所以9.80大于9.11。
66
67因此,9.8大于9.11。
68
69用户可能是在考虑日期或版本号,但问题明确是“数字”,所以应该作为数值来比较。
70
71在数值上,9.8是9.80,而9.11是9.11,所以9.80 > 9.11。
72
73确认一下:9.8 = 9 + 8/10 = 9.80,而9.11 = 9 + 1/10 + 1/100 = 9.11。
74
75是的,9.80比9.11大。
76
77如果用户是在考虑字符串比较,比如版本号,那么9.11可能被视为9.11,而9.8被视为9.8,但在版本号比较中,通常是从左到右比较数字部分。
78
79例如,在软件版本中,9.8可能被视为9.8.0,所以比较9.11和9.8.0。
80
819.11的主版本是9,次版本是11;9.8的主版本是9,次版本是8。
82
83所以,主版本相同,次版本11大于8,因此9.11大于9.8。
84
85但问题中说的是“数字
86--------------------------------------------------
87Prompt: How many e in word deepseek
88Generated: <think>
89First, the user asked: "How many e in word deepseek". I need to count the number of 'e's in the word "deepseek".
90
91Let me write down the word: D-E-E-P-S-E-E-K.
92
93Now, I'll go through each letter and count the 'e's.
94
95- D: not e
96
97- E: e (first one)
98
99- E: e (second one)
100
101- P: not e
102
103- S: not e
104
105- E: e (third one)
106
107- E: e (fourth one)
108
109- K: not e
110
111So, there are four 'e's in "deepseek".
112
113I should confirm the spelling. "Deepseek" – is that the correct spelling? I think it's a company name or something, but based on the query, it's given as "deepseek", so I'll assume that's the word.
114
115Also, the user said "e in word", which might be a typo or shorthand for "e's in the word". Probably, they meant "how many e's are in the word deepseek".
116
117Now, to respond, I should be clear and direct. Since this is a simple count, I can just state the number.
118
119But let me make sure there's no trick here. Is "deepseek" meant to be "DeepSeek" or something else? The query says "deepseek", so I'll treat it as a lowercase word for counting purposes.
120
121Perhaps it's a reference to the AI model DeepSeek, but I think for this question, it's just about the word itself.
122
123So, counting: positions with 'e' are 2nd, 3rd, 6th, and 7th letters. That's four.
124
125I can also think of it as the word has 8 letters, and 'e' appears at indices 2,3,6,7 if we start counting from 1.
126
127But for the response, I don't need to be too technical.
128
129Finally, I should phrase my response to be helpful and engaging, but since the question is straightforward, a simple answer might suffice.
130
131Response: There are 4 'e's in the word "deepseek".
132</think>
133The word "deepseek" contains **4** instances of the letter "e".
134
135To break it down:
136- The word is spelled: D-E-E-P-S-E
137--------------------------------------------------
138Prompt: There are ten birds in a tree. A hunter shoots one. How many are left in the tree?
139Generated: <think>
140First, the question is: "There are ten birds in a tree. A hunter shoots one. How many are left in the tree?"
141
142This seems like a riddle. The straightforward answer might be nine, but I think there's a trick here. Riddles often play on words or assumptions.
143
144Let me read it carefully. "There are ten birds in a tree." Then, "A hunter shoots one." And it asks how many are left.
145
146Now, when a hunter shoots a bird, does that mean the bird dies and falls out of the tree? Or does it fly away? That's a common point in these kinds of riddles.
147
148The classic version of this riddle is: "There are 10 birds in a tree. A hunter shoots one. How many are left?" And the answer is zero because the sound of the gunshot scares the others away.
149
150But in this case, it's similar. Let me confirm the wording. "A hunter shoots one." It doesn't specify if the shot is heard or if the birds are scared.
151
152However, in the standard riddle, the implication is that the shot scares the remaining birds, so they fly away, leaving none.
153
154But here, it just says "shoots one," not necessarily that the shot is loud or that the birds are scared. Maybe I should consider the context.
155
156Perhaps it's about the birds being alive or dead. But the question is about how many are left in the tree, not how many are alive.
157
158Another angle: maybe the hunter is shooting at the birds, but not necessarily hitting them or causing them to leave. But that seems less likely.
159
160Let's think step by step.
161
162Initially, there are ten birds in the tree.
163
164Hunter shoots one. What happens to that one? It's shot, so probably it dies or falls down.
165
166But the question is about how many are left, meaning remaining in the tree.
167
168If the shot kills the bird, it might fall from the tree, so it's no longer in the tree.
169
170Then, the other nine might be scared and fly away.
171
172But the riddle doesn't say that the shot scares the birds; it just says the hunter shoots one.
173
174In many versions, the key is that the shot scares the birds, so they all fly away.
175
176But let's see if there's another interpretation.
177
178Perhaps the birds are not real birds; maybe it's a
179--------------------------------------------------
180"""
1811from vllm import LLM, SamplingParams
2
3prompts = [
4 "Hello, my name is",
5]
6sampling_params = SamplingParams(temperature=0.8, top_p=0.95) ##change this to match official usage
7model_name = "Intel/DeepSeek-R1-0528-Qwen3-8B-int4-AutoRound-gptq-inc"
8llm = LLM(model=model_name, tensor_parallel_size=1)
9
10outputs = llm.generate(prompts, sampling_params)
11
12for output in outputs:
13 prompt = output.prompt
14 generated_text = output.outputs[0].text
15 print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
16auto-round --eval --model "Intel/DeepSeek-R1-0528-Qwen3-8B-int4-AutoRound-inc" --eval_bs 16 --tasks leaderboard_ifeval,leaderboard_mmlu_pro,gsm8k,lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,cmmlu,ceval-valid| Metric | BF16 | INT4(auto-round) | INT4 (auto-round-best) |
|---|---|---|---|
| Avg | 0.5958 | 0.5913 | 0.5926 |
| arc_challenge | 0.5137 | 0.5102 | 0.5043 |
| arc_easy | 0.7908 | 0.7862 | 0.7921 |
| boolq | 0.8498 | 0.8526 | 0.8443 |
| ceval-valid | 0.7296 | 0.7177 | 0.7140 |
| cmmlu | 0.7159 | 0.7029 | 0.7027 |
| gsm8k | 0.8211 | 0.8029 | 0.8234 |
| hellaswag | 0.5781 | 0.5703 | 0.5670 |
| lambada_openai | 0.5544 | 0.5490 | 0.5626 |
| leaderboard_ifeval | 0.2731 | 0.2729 | 0.2542 |
| leaderboard_mmlu_pro | 0.4115 | 0.4105 | 0.4117 |
| openbookqa | 0.3020 | 0.3060 | 0.3100 |
| piqa | 0.7617 | 0.7617 | 0.7612 |
| truthfulqa_mc1 | 0.3562 | 0.3611 | 0.3696 |
| winogrande | 0.6835 | 0.6740 | 0.6788 |
1auto-round
2--model_name deepseek-ai/DeepSeek-R1-0528-Qwen3-8B \
3--device 0 \
4--format "auto_gptq,auto_awq,auto_round" \
5--enable_torch_compile \
6--output_dir "./tmp_autoround"