n1ck-guo commited on
Commit
7a17864
·
verified ·
1 Parent(s): 8e96186

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +91 -1
README.md CHANGED
@@ -12,7 +12,97 @@ Please follow the license of the original model.
12
 
13
  ## How To Use
14
 
15
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  ### Generate the model
18
 
 
12
 
13
  ## How To Use
14
 
15
+ ```python
16
+ from transformers import AutoModelForCausalLM, AutoTokenizer
17
+ import transformers
18
+ import torch
19
+ quantized_model_dir = "Intel/DeepSeek-V3.1-int4-mixed-AutoRound"
20
+
21
+ model = AutoModelForCausalLM.from_pretrained(
22
+ quantized_model_dir,
23
+ torch_dtype=torch.bfloat16,
24
+ device_map="auto",
25
+ )
26
+ tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir, trust_remote_code=True)
27
+ prompts = [
28
+ "9.11和9.8哪个数字大",
29
+ "strawberry中有几个r?",
30
+ "There is a girl who likes adventure,",
31
+ "Please give a brief introduction of DeepSeek company.",
32
+ ]
33
+
34
+ texts=[]
35
+ for prompt in prompts:
36
+ messages = [
37
+ {"role": "system", "content": "You are a helpful assistant."},
38
+ {"role": "user", "content": prompt}
39
+ ]
40
+ text = tokenizer.apply_chat_template(
41
+ messages,
42
+ tokenize=False,
43
+ add_generation_prompt=True
44
+ )
45
+ texts.append(text)
46
+ inputs = tokenizer(texts, return_tensors="pt", padding=True, truncation=True)
47
+
48
+ outputs = model.generate(
49
+ input_ids=inputs["input_ids"].to(model.device),
50
+ attention_mask=inputs["attention_mask"].to(model.device),
51
+ max_length=200, ##change this to align with the official usage
52
+ num_return_sequences=1,
53
+ do_sample=False ##change this to align with the official usage
54
+ )
55
+ generated_ids = [
56
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(inputs["input_ids"], outputs)
57
+ ]
58
+ decoded_outputs = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
59
+
60
+ for i, prompt in enumerate(prompts):
61
+ input_id = inputs
62
+ print(f"Prompt: {prompt}")
63
+ print(f"Generated: {decoded_outputs[i]}")
64
+
65
+ """
66
+ Prompt: 9.11和9.8哪个数字大
67
+ Generated: 9.11 和 9.8 比较时,9.11 更大。
68
+ - 因为 9.11 相当于 9 + 0.11,而 9.8 相当于 9 + 0.8,但注意这里 0.11 实际上小于 0.8(0.11 < 0.8),所以 9.8 更大。
69
+ - 重新确认:9.11 是 9.11,9.8 是 9.80,因此 9.80 > 9.11。
70
+
71
+ **答案:9.8 更大。**
72
+ --------------------------------------------------
73
+ Prompt: strawberry中有几个r?
74
+ Generated: 在英文单词 "strawberry" 中,字母 "r" 出现了 **3 次**。
75
+ - 位置:第 3 个字母(s**t**r**a**w**b**e**r**r**y,注意:第 1 个 "r" 是第 3 字符,第 2 个 "r" 是第 6 字符,第 3 个 "r" 是第 7 字符)。
76
+
77
+ 如果需要进一步解释或其他问题,请随时告知! 😊
78
+ --------------------------------------------------
79
+ Prompt: There is a girl who likes adventure,
80
+ Generated: Of course! A girl who likes adventure is a fantastic starting point for a story, a character, or a real-life inspiration. Here are a few ways to explore that idea:
81
+
82
+ ### As a Character Profile:
83
+
84
+ **Name:** Let's call her **Elara**.
85
+
86
+ **Traits:**
87
+ * **Curious:** She asks "why" and "what if" more than anyone else. She sees a hidden path in the woods and has to know where it leads.
88
+ * **Resourceful:** She's the one with a multi-tool in her pocket, who knows how to read a map (and the stars), and can build a fire.
89
+ * **Brave, not fearless:** She feels the fear of climbing the tall cliff or exploring the dark cave, but her curiosity and determination are stronger.
90
+ * **Resilient:** She doesn't see a wrong turn
91
+ --------------------------------------------------
92
+ Prompt: Please give a brief introduction of DeepSeek company.
93
+ Generated: Of course. Here is a brief introduction to DeepSeek:
94
+
95
+ **DeepSeek** is a leading Chinese AI research company focused on developing powerful artificial general intelligence (AGI). The company is best known for creating state-of-the-art large language models (LLMs).
96
+
97
+ **Key Highlights:**
98
+
99
+ * **Core Product:** Their flagship product is the **DeepSeek-V2** language model, a powerful and efficient AI known for its strong performance in coding, mathematics, and general reasoning.
100
+ * **Open-Source Commitment:** DeepSeek has gained significant recognition for open-sourcing its earlier models (like DeepSeek-Coder and DeepSeek-LLM 67B), making them freely available for research and commercial use. This has helped foster innovation and build a strong developer community.
101
+ * **Specialization in Coding:** They are particularly renowned for their models' exceptional capabilities
102
+ --------------------------------------------------
103
+
104
+ """
105
+ ```
106
 
107
  ### Generate the model
108