Mac下部署MLX大语言模型推理框架

1、创建、激活虚拟环境

uv venv
source .venv/bin/activate

2、安装依赖库

uv pip install sentencepiece -i https://pypi.tuna.tsinghua.edu.cn/simple

3、安装MLX

uv pip install mlx-lm -i https://pypi.tuna.tsinghua.edu.cn/simple

4、下载并运行LLM

mlx_lm.generate --model "mlx-community/Qwen3-14B-4bit-DWQ-053125" --prompt "您好"

5、启动连续对话模式

mlx_lm.chat --model "mlx-community/Qwen3-14B-4bit-DWQ-053125" --max-tokens 4096


对话结束后,输入 q 回车,则退出!

-------------------------------

查看mlx框架的模型列表:

https://huggingface.co/mlx-community/collections


--------------------------------

如果直接从huggingface或hf镜像站拉取模型文件速度慢,可以直接从modelscope阿里的魔搭社区去下载模型,然后再从本地.cache文件夹(隐藏文件夹)内的modelscope文件夹中的hub子文件夹里找到相应的模型文件拷贝到huggingface下的hub文件夹中即可!


------------------------------------------------------------------------------
******模型下载技巧******
------------------------------------------------------------------------------

A、设置huggingface的镜像站:

设置了镜像站之后,就不要再翻墙了,否则速度更慢!

export HF_ENDPOINT=https://hf-mirror.com

B、模型下载:

hf  download  mlx-community/HY-MT2-1.8B






评论

此博客中的热门博文

通过命令行在Github上发布项目的新版本

利用GitHub免费的静态页面托管空间发布网页

本地部署OpenAvatarChat实时交互数字人系统