目录

mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL

安装 mlx-lm

pip install mlx-lm

生成 SQL

python -m mlx_lm.generate --model mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL \
                          --max-tokens 50 \
                          --prompt "table: students
columns: Name, Age, School, Grade, Height, Weight
Q: Which school did Wang Junjian come from?
A: "
SELECT School FROM Students WHERE Name = 'Wang Junjian'

上传模型到 HuggingFace Hub

  1. 加入 MLX Community 组织

  2. 在 MLX Community 组织中创建一个新的模型 mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL

  3. 克隆仓库 mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL

git clone https://huggingface.co/mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL
  1. 将生成的模型文件(lora_fused_model 目录下的所有文件)复制到仓库目录下

  2. 上传模型到 HuggingFace Hub

git add .
git commit -m "Fine tuning Text2SQL based on Mistral-7B using LoRA on MLX" 
git push

git push 错误

  1. 不能 push

错误信息:

Uploading LFS objects:   0% (0/2), 0 B | 0 B/s, done.                                                                                                                                                                                              
batch response: Authorization error.
error: failed to push some refs to 'https://huggingface.co/mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL'

解决方法:

vim .git/config
[remote "origin"]
    url = https://wangjunjian:write_token@huggingface.co/mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL
    fetch = +refs/heads/*:refs/remotes/origin/*
  1. 不能上传大于 5GB 的文件

错误信息:

warning: current Git remote contains credentials                                                                                                                                                                                                   
batch response: 
You need to configure your repository to enable upload of files > 5GB.
Run "huggingface-cli lfs-enable-largefiles ./path/to/your/repo" and try again.

解决方法:

huggingface-cli longin
huggingface-cli lfs-enable-largefiles /Users/junjian/HuggingFace/mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL

参考资料