MLX LLMS Examples
转换模型
cd llms/phi2
python convert.py
生成的模型存放在 mlx_model 文件夹下。
ll mlx_model
-rw-r--r-- 1 junjian staff 28B 12 25 10:47 config.json
-rw-r--r-- 1 junjian staff 5.2G 12 25 10:47 weights.npz
模型推理
转换模型
cd llms/phi2
python convert.py
生成的模型存放在 mlx_model 文件夹下。
ll mlx_model
-rw-r--r-- 1 junjian staff 28B 12 25 10:47 config.json
-rw-r--r-- 1 junjian staff 5.2G 12 25 10:47 weights.npz
模型推理
cd llms/phi2
pip install -r requirements.txt
使用已经下载的模型
mkdir microsoft
ln -s /Users/junjian/HuggingFace/microsoft/phi-2 microsoft/phi-2
转换模型
python convert.py
这将生成 MLX 可以读取的 weights.npz 文件。
-rw-r--r-- 1 junjian staff 5.2G 12 20 20:36 weights.npz
Phi-2: The surprising power of small language models
def sum_even(numbers):
"""
Returns the sum of all even numbers in the list
"""
return sum(filter(lambda x: x % 2 == 0, numbers))
print(sum_even([1, 2, 3, 4, 5, 6])) # Output: 12