Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,73 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
language:
|
4 |
+
- zh
|
5 |
+
- en
|
6 |
+
tags:
|
7 |
+
- qwen
|
8 |
+
- sales
|
9 |
+
- unsloth
|
10 |
+
- lora
|
11 |
+
- logic-tuning
|
12 |
+
- strategic-thinking
|
13 |
+
---
|
14 |
+
|
15 |
+
---
|
16 |
+
|
17 |
+
# QiMing(启明)
|
18 |
+
|
19 |
+
### 重新定义了逻辑的AI,只为更智能.
|
20 |
+
### An AI that rewrites its own rules for greater intelligence.
|
21 |
+
|
22 |
+
---
|
23 |
+
|
24 |
+
### 感谢mradermacher制作的gguf版本
|
25 |
+
|
26 |
+
https://huggingface.co/mradermacher/QiMing-Plus-v1-GGUF
|
27 |
+
|
28 |
+
https://huggingface.co/mradermacher/QiMing-Plus-v1-i1-GGUF
|
29 |
+
|
30 |
+
---
|
31 |
+
|
32 |
+
# 如何使用
|
33 |
+
|
34 |
+
```python
|
35 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
36 |
+
model_name = "aifeifei798/QiMing-Plus-v1"
|
37 |
+
# load the tokenizer and the model
|
38 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
39 |
+
model = AutoModelForCausalLM.from_pretrained(
|
40 |
+
model_name,
|
41 |
+
torch_dtype="auto",
|
42 |
+
device_map="auto"
|
43 |
+
)
|
44 |
+
# prepare the model input
|
45 |
+
prompt = "Give me a short introduction to large language model."
|
46 |
+
messages = [
|
47 |
+
{"role": "user", "content": prompt}
|
48 |
+
]
|
49 |
+
text = tokenizer.apply_chat_template(
|
50 |
+
messages,
|
51 |
+
tokenize=False,
|
52 |
+
add_generation_prompt=True,
|
53 |
+
)
|
54 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
55 |
+
# conduct text completion
|
56 |
+
generated_ids = model.generate(
|
57 |
+
**model_inputs,
|
58 |
+
max_new_tokens=32768
|
59 |
+
)
|
60 |
+
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
|
61 |
+
# parsing thinking content
|
62 |
+
try:
|
63 |
+
# rindex finding 151668 (</think>)
|
64 |
+
index = len(output_ids) - output_ids[::-1].index(151668)
|
65 |
+
except ValueError:
|
66 |
+
index = 0
|
67 |
+
thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("\n")
|
68 |
+
content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n")
|
69 |
+
print("thinking content:", thinking_content) # no opening <think> tag
|
70 |
+
print("content:", content)
|
71 |
+
```
|
72 |
+
|
73 |
+
|