在 MLX 上使用 LoRA / QLoRA 微调 Text2SQL(三):分享微调后的模型到 HuggingFace Hub
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
- 
    
加入 MLX Community 组织
 - 
    
在 MLX Community 组织中创建一个新的模型 mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL
 
git clone https://huggingface.co/mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL
- 
    
将生成的模型文件(
lora_fused_model目录下的所有文件)复制到仓库目录下 - 
    
上传模型到 HuggingFace Hub
 
git add .
git commit -m "Fine tuning Text2SQL based on Mistral-7B using LoRA on MLX" 
git push
git push 错误
- 不能 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/*
- 不能上传大于 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