n1ck-guo commited on
Commit
a6e43b3
·
verified ·
1 Parent(s): 5277ea1

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +81 -1
README.md CHANGED
@@ -10,7 +10,87 @@ This model is a int4 model with group_size 128 and symmetric quantization of [de
10
  Please follow the license of the original model.
11
 
12
  ## How To Use
13
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  ### Generate the model
16
 
 
10
  Please follow the license of the original model.
11
 
12
  ## How To Use
13
+ ### INT4 Inference
14
+ ```python
15
+ from transformers import AutoModelForCausalLM, AutoTokenizer
16
+ import transformers
17
+ import torch
18
+ quantized_model_dir = "Intel/DeepSeek-V3.1-int4-mixed-AutoRound"
19
+
20
+ model = AutoModelForCausalLM.from_pretrained(
21
+ quantized_model_dir,
22
+ torch_dtype=torch.bfloat16,
23
+ device_map="auto",
24
+ )
25
+ tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir, trust_remote_code=True)
26
+ prompts = [
27
+ "strawberry中有几个r?",
28
+ "There is a girl who likes adventure,",
29
+ "Please give a brief introduction of DeepSeek company.",
30
+ ]
31
+
32
+ texts=[]
33
+ for prompt in prompts:
34
+ messages = [
35
+ {"role": "system", "content": "You are a helpful assistant."},
36
+ {"role": "user", "content": prompt}
37
+ ]
38
+ text = tokenizer.apply_chat_template(
39
+ messages,
40
+ tokenize=False,
41
+ add_generation_prompt=True
42
+ )
43
+ texts.append(text)
44
+ inputs = tokenizer(texts, return_tensors="pt", padding=True, truncation=True)
45
+
46
+ outputs = model.generate(
47
+ input_ids=inputs["input_ids"].to(model.device),
48
+ attention_mask=inputs["attention_mask"].to(model.device),
49
+ max_length=200, ##change this to align with the official usage
50
+ num_return_sequences=1,
51
+ do_sample=False ##change this to align with the official usage
52
+ )
53
+ generated_ids = [
54
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(inputs["input_ids"], outputs)
55
+ ]
56
+ decoded_outputs = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
57
+
58
+ for i, prompt in enumerate(prompts):
59
+ input_id = inputs
60
+ print(f"Prompt: {prompt}")
61
+ print(f"Generated: {decoded_outputs[i]}")
62
+ """
63
+ Prompt: strawberry中有几个r?
64
+ Generated: 在英文单词 "strawberry" 中,字母 "r" 出现了 **3 次**。
65
+ - 位置:第 3 个字母(s**t r**awberry)、第 6 个字母(stra**w b**erry 中的 "r" 实际是第 6 个字符,但注意 "w" 后是 "b",这里需要仔细数)
66
+ 实际上:
67
+ - 分解:s-t-r-a-w-b-e-r-r-y
68
+ - 字母 "r" 出现在第 3、第 8 和第 9 位(索引从 1 开始)。
69
+
70
+ 所以,**"strawberry" 包含 3 个 "r"**。
71
+ --------------------------------------------------
72
+ Prompt: There is a girl who likes adventure,
73
+ Generated: Of course! Here are a few ways to imagine what that could look like, from a simple story to a character profile.
74
+
75
+ ### A Short Story Snippet
76
+
77
+ The map was old, the edges frayed and the ink faded in places. Ella traced the route with her finger for the hundredth time, her heart beating a rhythm of pure excitement. It wasn't just a path to a hidden waterfall; it was a path to *discovery*.
78
+
79
+ She packed her bag not with fancy clothes, but with a well-worn compass, a rope, a water bottle, and her trusted journal. The forest welcomed her with the smell of damp earth and pine. Every rustle in the undergrowth was a mystery, every unfamiliar bird call a secret she was determined to learn.
80
+
81
+ As she reached the cliff face she needed to climb, a thrill, not fear, shot through her. She
82
+ --------------------------------------------------
83
+ Prompt: Please give a brief introduction of DeepSeek company.
84
+ Generated: Of course. Here is a brief introduction to DeepSeek.
85
+
86
+ **DeepSeek** is a leading Chinese AI research company focused on developing powerful artificial intelligence models, with a primary emphasis on large language models (LLMs) and multimodal systems.
87
+
88
+ Here are the key points about the company:
89
+
90
+ * **Core Focus:** They are best known for their **DeepSeek-V2** and the more recent **DeepSeek-V3** models, which are highly capable LLMs that compete with other top-tier models like GPT-4. They specialize in both closed and open-source AI.
91
+ * **Open-Source Contribution:** DeepSeak has made significant contributions to the open-source community. They have released powerful models like **DeepSeek-Coder** (focused on code generation and programming tasks) and the weights for earlier versions of their LLMs, allowing developers and researchers worldwide
92
+ --------------------------------------------------
93
+ """
94
 
95
  ### Generate the model
96