init README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,98 @@
|
|
1 |
-
---
|
2 |
-
license: mit
|
3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
---
|
4 |
+
|
5 |
+
This is a quantized INT4 model based on Apple MLX Framework Phi-3.5-MoE-Instruct. You can deploy it on Apple Silicon devices.
|
6 |
+
|
7 |
+
Installation
|
8 |
+
|
9 |
+
```bash
|
10 |
+
|
11 |
+
pip install -U mlx-lm
|
12 |
+
|
13 |
+
```
|
14 |
+
|
15 |
+
Conversion
|
16 |
+
|
17 |
+
```bash
|
18 |
+
|
19 |
+
python -m mlx_lm.convert --hf-path microsoft/Phi-3.5-MoE-instruct -q
|
20 |
+
|
21 |
+
```
|
22 |
+
|
23 |
+
Samples
|
24 |
+
|
25 |
+
```python
|
26 |
+
|
27 |
+
from mlx_lm import load, generate
|
28 |
+
|
29 |
+
model, tokenizer = load("./phi-3.5-moe-mlx-int4")
|
30 |
+
|
31 |
+
sys_msg = """You are a helpful AI assistant, you are an agent capable of using a variety of tools to answer a question. Here are a few of the tools available to you:
|
32 |
+
|
33 |
+
- Blog: This tool helps you describe a certain knowledge point and content, and finally write it into Twitter or Facebook style content
|
34 |
+
- Translate: This is a tool that helps you translate into any language, using plain language as required
|
35 |
+
|
36 |
+
To use these tools you must always respond in JSON format containing `"tool_name"` and `"input"` key-value pairs. For example, to answer the question, "Build Muliti Agents with MOE models" you must use the calculator tool like so:
|
37 |
+
|
38 |
+
```json
|
39 |
+
|
40 |
+
{
|
41 |
+
"tool_name": "Blog",
|
42 |
+
"input": "Build Muliti Agents with MOE models"
|
43 |
+
}
|
44 |
+
|
45 |
+
```
|
46 |
+
|
47 |
+
Or to translate the question "can you introduce yourself in Chinese" you must respond:
|
48 |
+
|
49 |
+
```json
|
50 |
+
|
51 |
+
{
|
52 |
+
"tool_name": "Search",
|
53 |
+
"input": "can you introduce yourself in Chinese"
|
54 |
+
}
|
55 |
+
|
56 |
+
```
|
57 |
+
|
58 |
+
Remember just output the final result, ouput in JSON format containing `"agentid"`,`"tool_name"` , `"input"` and `"output"` key-value pairs .:
|
59 |
+
|
60 |
+
```json
|
61 |
+
|
62 |
+
[
|
63 |
+
|
64 |
+
|
65 |
+
{ "agentid": "step1",
|
66 |
+
"tool_name": "Blog",
|
67 |
+
"input": "Build Muliti Agents with MOE models",
|
68 |
+
"output": "........."
|
69 |
+
},
|
70 |
+
|
71 |
+
{ "agentid": "step2",
|
72 |
+
"tool_name": "Search",
|
73 |
+
"input": "can you introduce yourself in Chinese",
|
74 |
+
"output": "........."
|
75 |
+
},
|
76 |
+
{
|
77 |
+
"agentid": "final"
|
78 |
+
"tool_name": "Result",
|
79 |
+
"output": "........."
|
80 |
+
}
|
81 |
+
]
|
82 |
+
|
83 |
+
```
|
84 |
+
|
85 |
+
The users answer is as follows.
|
86 |
+
"""
|
87 |
+
|
88 |
+
query ='Write something about Generative AI with MOE , translate it to Chinese'
|
89 |
+
|
90 |
+
prompt = tokenizer.apply_chat_template(
|
91 |
+
[{"role": "system", "content": sys_msg},{"role": "user", "content": query}],
|
92 |
+
tokenize=False,
|
93 |
+
add_generation_prompt=True,
|
94 |
+
)
|
95 |
+
|
96 |
+
response = generate(model, tokenizer, prompt=prompt,max_tokens=1024, verbose=True)
|
97 |
+
|
98 |
+
```
|