Update README.md
Browse files
README.md
CHANGED
@@ -4,7 +4,7 @@ language:
|
|
4 |
- zh
|
5 |
- en
|
6 |
tags:
|
7 |
-
-
|
8 |
- sales
|
9 |
- unsloth
|
10 |
- lora
|
@@ -15,7 +15,7 @@ tags:
|
|
15 |
|
16 |
**Model ID:** aifeifei798/QiMing-Gemma-3-4b
|
17 |
|
18 |
-
**Base Model:**
|
19 |
|
20 |
<br>
|
21 |
|
@@ -57,58 +57,6 @@ It is this internal "synergistic operation" that fills Qiming's responses with *
|
|
57 |
|
58 |
---
|
59 |
|
60 |
-
## 🚀 How to Use
|
61 |
-
|
62 |
-
```python
|
63 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
64 |
-
|
65 |
-
model_name = "aifeifei798/QiMing-Gemma-3-4b"
|
66 |
-
|
67 |
-
# load the tokenizer and the model
|
68 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
69 |
-
model = AutoModelForCausalLM.from_pretrained(
|
70 |
-
model_name,
|
71 |
-
torch_dtype="auto",
|
72 |
-
device_map="auto"
|
73 |
-
)
|
74 |
-
|
75 |
-
# prepare the model input
|
76 |
-
prompt = "My son is in the fifth grade. He's very smart, but he's lost interest in all of his school subjects, and his grades have been slipping. Recently, he's become obsessed with a very complex sandbox game where he builds all sorts of intricate machines. I'm very anxious. On one hand, I'm worried about his academic performance; on the other, I have a gut feeling that I shouldn't crush his creativity. What on earth should I do?"
|
77 |
-
messages = [
|
78 |
-
{"role": "system", "content": "You are a helpful assistant."},
|
79 |
-
{"role": "user", "content": prompt}
|
80 |
-
]
|
81 |
-
text = tokenizer.apply_chat_template(
|
82 |
-
messages,
|
83 |
-
tokenize=False,
|
84 |
-
add_generation_prompt=True,
|
85 |
-
)
|
86 |
-
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
87 |
-
|
88 |
-
# conduct text completion
|
89 |
-
generated_ids = model.generate(
|
90 |
-
**model_inputs,
|
91 |
-
max_new_tokens=32768
|
92 |
-
)
|
93 |
-
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
|
94 |
-
|
95 |
-
# parsing thinking content
|
96 |
-
try:
|
97 |
-
# rindex finding 151668 (</think>)
|
98 |
-
index = len(output_ids) - output_ids[::-1].index(151668)
|
99 |
-
except ValueError:
|
100 |
-
index = 0
|
101 |
-
|
102 |
-
thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("\n")
|
103 |
-
content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n")
|
104 |
-
|
105 |
-
print("thinking content:", thinking_content) # no opening <think> tag
|
106 |
-
print("content:", content)
|
107 |
-
|
108 |
-
```
|
109 |
-
|
110 |
-
---
|
111 |
-
|
112 |
## Showcase: An S-Class Maiden Voyage
|
113 |
|
114 |
To validate Qiming's capabilities, we presented it with an exceptionally complex, real-world dilemma that blends education, psychology, and family dynamics.
|
@@ -224,60 +172,6 @@ Its methodology, training data, and origin story are open-source, in the hope of
|
|
224 |
|
225 |
---
|
226 |
|
227 |
-
## 🚀 使用方法 (How to Use)
|
228 |
-
|
229 |
-
本模型是使用 `unsloth` 进行LoRA微调的。为了获得最佳效果,建议使用 `unsloth` 加载模型。
|
230 |
-
|
231 |
-
```python
|
232 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
233 |
-
|
234 |
-
model_name = "aifeifei798/QiMing-Gemma-3-4b"
|
235 |
-
|
236 |
-
# load the tokenizer and the model
|
237 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
238 |
-
model = AutoModelForCausalLM.from_pretrained(
|
239 |
-
model_name,
|
240 |
-
torch_dtype="auto",
|
241 |
-
device_map="auto"
|
242 |
-
)
|
243 |
-
|
244 |
-
# prepare the model input
|
245 |
-
prompt = "我的孩子今年上五年级,他非常聪明,但对学校的所有科目都失去了兴趣,成绩一直在下滑。最近他迷上了玩一款很复杂的沙盒游戏,在里面建造各种精巧的机器。我非常焦虑,我一方面担心他的学业,另一方面又隐约觉得不该扼杀他的创造力。我到底该怎么办?"
|
246 |
-
messages = [
|
247 |
-
{"role": "system", "content": "You are a helpful assistant."},
|
248 |
-
{"role": "user", "content": prompt}
|
249 |
-
]
|
250 |
-
text = tokenizer.apply_chat_template(
|
251 |
-
messages,
|
252 |
-
tokenize=False,
|
253 |
-
add_generation_prompt=True,
|
254 |
-
)
|
255 |
-
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
256 |
-
|
257 |
-
# conduct text completion
|
258 |
-
generated_ids = model.generate(
|
259 |
-
**model_inputs,
|
260 |
-
max_new_tokens=32768
|
261 |
-
)
|
262 |
-
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
|
263 |
-
|
264 |
-
# parsing thinking content
|
265 |
-
try:
|
266 |
-
# rindex finding 151668 (</think>)
|
267 |
-
index = len(output_ids) - output_ids[::-1].index(151668)
|
268 |
-
except ValueError:
|
269 |
-
index = 0
|
270 |
-
|
271 |
-
thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("\n")
|
272 |
-
content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n")
|
273 |
-
|
274 |
-
print("thinking content:", thinking_content) # no opening <think> tag
|
275 |
-
print("content:", content)
|
276 |
-
|
277 |
-
```
|
278 |
-
|
279 |
-
---
|
280 |
-
|
281 |
## 案例展示:一次S级的首航任务
|
282 |
|
283 |
为了验证“启明”的能力,我们向它提出了一个极其复杂的、融合了教育、心理和家庭关系的真实困境。
|
|
|
4 |
- zh
|
5 |
- en
|
6 |
tags:
|
7 |
+
- gemma
|
8 |
- sales
|
9 |
- unsloth
|
10 |
- lora
|
|
|
15 |
|
16 |
**Model ID:** aifeifei798/QiMing-Gemma-3-4b
|
17 |
|
18 |
+
**Base Model:** google/gemma-3-4b-it-qat-q4_0-unquantized (Fine-tuned on a consumer-grade GPU by injecting structural logic)
|
19 |
|
20 |
<br>
|
21 |
|
|
|
57 |
|
58 |
---
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
## Showcase: An S-Class Maiden Voyage
|
61 |
|
62 |
To validate Qiming's capabilities, we presented it with an exceptionally complex, real-world dilemma that blends education, psychology, and family dynamics.
|
|
|
172 |
|
173 |
---
|
174 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
## 案例展示:一次S级的首航任务
|
176 |
|
177 |
为了验证“启明”的能力,我们向它提出了一个极其复杂的、融合了教育、心理和家庭关系的真实困境。
|