Update README.md
Browse files
README.md
CHANGED
@@ -1,86 +1,86 @@
|
|
1 |
-
---
|
2 |
-
language:
|
3 |
-
- ko
|
4 |
-
- en
|
5 |
-
license: apache-2.0
|
6 |
-
tags:
|
7 |
-
- text-generation
|
8 |
-
- qwen2.5
|
9 |
-
- korean
|
10 |
-
- instruct
|
11 |
-
- mlx
|
12 |
-
- 8bit
|
13 |
-
pipeline_tag: text-generation
|
14 |
-
---
|
15 |
-
|
16 |
-
## Qwen2.5-7B-Instruct-kowiki-qa-8bit mlx convert model
|
17 |
-
- Original model is [beomi/Qwen2.5-7B-Instruct-kowiki-qa](https://huggingface.co/beomi/Qwen2.5-7B-Instruct-kowiki-qa)
|
18 |
-
|
19 |
-
|
20 |
-
## Requirement
|
21 |
-
- `pip install mlx-lm`
|
22 |
-
|
23 |
-
## Usage
|
24 |
-
- [Generate with CLI](https://github.com/ml-explore/mlx-examples/blob/main/llms/README.md#command-line)
|
25 |
-
```bash
|
26 |
-
mlx_lm.generate --model
|
27 |
-
```
|
28 |
-
|
29 |
-
- [In Python](https://github.com/ml-explore/mlx-examples/blob/main/llms/README.md#python-api)
|
30 |
-
```python
|
31 |
-
from mlx_lm import load, generate
|
32 |
-
|
33 |
-
model, tokenizer = load(
|
34 |
-
"
|
35 |
-
tokenizer_config={"trust_remote_code": True},
|
36 |
-
)
|
37 |
-
|
38 |
-
prompt = "νλμ΄ νλ μ΄μ κ° λμΌ?"
|
39 |
-
|
40 |
-
messages = [
|
41 |
-
{"role": "system", "content": "λΉμ μ μΉμ² ν μ±λ΄μ
λλ€."},
|
42 |
-
{"role": "user", "content": prompt},
|
43 |
-
]
|
44 |
-
prompt = tokenizer.apply_chat_template(
|
45 |
-
messages,
|
46 |
-
tokenize=False,
|
47 |
-
add_generation_prompt=True,
|
48 |
-
)
|
49 |
-
|
50 |
-
text = generate(
|
51 |
-
model,
|
52 |
-
tokenizer,
|
53 |
-
prompt=prompt,
|
54 |
-
# verbose=True,
|
55 |
-
# max_tokens=8196,
|
56 |
-
# temp=0.0,
|
57 |
-
)
|
58 |
-
```
|
59 |
-
|
60 |
-
- [OpenAI Compitable HTTP Server](https://github.com/ml-explore/mlx-examples/blob/main/llms/mlx_lm/SERVER.md)
|
61 |
-
```bash
|
62 |
-
mlx_lm.server --model
|
63 |
-
```
|
64 |
-
|
65 |
-
```python
|
66 |
-
import openai
|
67 |
-
|
68 |
-
|
69 |
-
client = openai.OpenAI(
|
70 |
-
base_url="http://localhost:8080/v1",
|
71 |
-
)
|
72 |
-
|
73 |
-
prompt = "νλμ΄ νλ μ΄μ κ° λμΌ?"
|
74 |
-
|
75 |
-
messages = [
|
76 |
-
{"role": "system", "content": "λΉμ μ μΉμ ν μ±λ΄μ
λλ€.",},
|
77 |
-
{"role": "user", "content": prompt},
|
78 |
-
]
|
79 |
-
res = client.chat.completions.create(
|
80 |
-
model='
|
81 |
-
messages=messages,
|
82 |
-
temperature=0.2,
|
83 |
-
)
|
84 |
-
|
85 |
-
print(res.choices[0].message.content)
|
86 |
-
```
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- ko
|
4 |
+
- en
|
5 |
+
license: apache-2.0
|
6 |
+
tags:
|
7 |
+
- text-generation
|
8 |
+
- qwen2.5
|
9 |
+
- korean
|
10 |
+
- instruct
|
11 |
+
- mlx
|
12 |
+
- 8bit
|
13 |
+
pipeline_tag: text-generation
|
14 |
+
---
|
15 |
+
|
16 |
+
## Qwen2.5-7B-Instruct-kowiki-qa-8bit mlx convert model
|
17 |
+
- Original model is [beomi/Qwen2.5-7B-Instruct-kowiki-qa](https://huggingface.co/beomi/Qwen2.5-7B-Instruct-kowiki-qa)
|
18 |
+
|
19 |
+
|
20 |
+
## Requirement
|
21 |
+
- `pip install mlx-lm`
|
22 |
+
|
23 |
+
## Usage
|
24 |
+
- [Generate with CLI](https://github.com/ml-explore/mlx-examples/blob/main/llms/README.md#command-line)
|
25 |
+
```bash
|
26 |
+
mlx_lm.generate --model mlx-community/Qwen2.5-7B-Instruct-kowiki-qa-8bit --prompt "νλμ΄ νλ μ΄μ κ° λμΌ?"
|
27 |
+
```
|
28 |
+
|
29 |
+
- [In Python](https://github.com/ml-explore/mlx-examples/blob/main/llms/README.md#python-api)
|
30 |
+
```python
|
31 |
+
from mlx_lm import load, generate
|
32 |
+
|
33 |
+
model, tokenizer = load(
|
34 |
+
"mlx-community/Qwen2.5-7B-Instruct-kowiki-qa-8bit",
|
35 |
+
tokenizer_config={"trust_remote_code": True},
|
36 |
+
)
|
37 |
+
|
38 |
+
prompt = "νλμ΄ νλ μ΄μ κ° λμΌ?"
|
39 |
+
|
40 |
+
messages = [
|
41 |
+
{"role": "system", "content": "λΉμ μ μΉμ² ν μ±λ΄μ
λλ€."},
|
42 |
+
{"role": "user", "content": prompt},
|
43 |
+
]
|
44 |
+
prompt = tokenizer.apply_chat_template(
|
45 |
+
messages,
|
46 |
+
tokenize=False,
|
47 |
+
add_generation_prompt=True,
|
48 |
+
)
|
49 |
+
|
50 |
+
text = generate(
|
51 |
+
model,
|
52 |
+
tokenizer,
|
53 |
+
prompt=prompt,
|
54 |
+
# verbose=True,
|
55 |
+
# max_tokens=8196,
|
56 |
+
# temp=0.0,
|
57 |
+
)
|
58 |
+
```
|
59 |
+
|
60 |
+
- [OpenAI Compitable HTTP Server](https://github.com/ml-explore/mlx-examples/blob/main/llms/mlx_lm/SERVER.md)
|
61 |
+
```bash
|
62 |
+
mlx_lm.server --model mlx-community/Qwen2.5-7B-Instruct-kowiki-qa-8bit --host 0.0.0.0
|
63 |
+
```
|
64 |
+
|
65 |
+
```python
|
66 |
+
import openai
|
67 |
+
|
68 |
+
|
69 |
+
client = openai.OpenAI(
|
70 |
+
base_url="http://localhost:8080/v1",
|
71 |
+
)
|
72 |
+
|
73 |
+
prompt = "νλμ΄ νλ μ΄μ κ° λμΌ?"
|
74 |
+
|
75 |
+
messages = [
|
76 |
+
{"role": "system", "content": "λΉμ μ μΉμ ν μ±λ΄μ
λλ€.",},
|
77 |
+
{"role": "user", "content": prompt},
|
78 |
+
]
|
79 |
+
res = client.chat.completions.create(
|
80 |
+
model='mlx-community/Qwen2.5-7B-Instruct-kowiki-qa-8bit',
|
81 |
+
messages=messages,
|
82 |
+
temperature=0.2,
|
83 |
+
)
|
84 |
+
|
85 |
+
print(res.choices[0].message.content)
|
86 |
+
```
|