Update README.md
Browse files
README.md
CHANGED
@@ -63,3 +63,31 @@ if hasattr(tokenizer, "apply_chat_template") and tokenizer.chat_template is not
|
|
63 |
|
64 |
response = generate(model, tokenizer, prompt=prompt, verbose=True)
|
65 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
response = generate(model, tokenizer, prompt=prompt, verbose=True)
|
65 |
```
|
66 |
+
|
67 |
+
## Change system prompt ...
|
68 |
+
|
69 |
+
1. clone this repo to local
|
70 |
+
|
71 |
+
2. change tokenizer_config.json
|
72 |
+
|
73 |
+
```json
|
74 |
+
"chat_template": "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system\n\n你是一个经过良好训练的AI助手,你的名字是Marco-o1.\n \n## 重要!!!!!\n当你回答问题时,你的思考应该在<Thought>内完成,<Output>内输出你的结果。\n<Thought>应该尽可能是英文,但是有2个特例,一个是对原文中的引用,另一个是是数学应该使用markdown格式,<Output>内的输出需要遵循用户输入的语言。\n <|im_end|>\n' }}{% endif %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
|
75 |
+
```
|
76 |
+
|
77 |
+
3. load
|
78 |
+
|
79 |
+
```python
|
80 |
+
from mlx_lm import load, generate
|
81 |
+
|
82 |
+
model, tokenizer = load("./mlx_model") # notice: folder where you put this repo files.
|
83 |
+
|
84 |
+
prompt="hello, can you teach me why 2 + 4 = 6 ?"
|
85 |
+
|
86 |
+
if hasattr(tokenizer, "apply_chat_template") and tokenizer.chat_template is not None:
|
87 |
+
messages = [{"role": "user", "content": prompt}]
|
88 |
+
prompt = tokenizer.apply_chat_template(
|
89 |
+
messages, tokenize=False, add_generation_prompt=True
|
90 |
+
)
|
91 |
+
|
92 |
+
response = generate(model, tokenizer, prompt=prompt, verbose=True)
|
93 |
+
```
|