一:原模型
1.下载ollama
2.下载模型
ollama run qwen2.5:7b-instruct # 下载完就运行(终端对话)
# ollama run qwen2.5:7b-instruct-q4_K_M
# 更小的量化模型
3.后续启动
ollama run qwen2.5:7b-instruct
补充:在ollama图形界面部署,点击"+",找到模型下载路径
二:微调后的大模型
1.合并
lora权重+底座模型
llamafactory-cli export \
--model_name_or_path /mnt/c/Users/hsp/.cache/modelscope/hub/models/Qwen/Qwen2.5-7B-Instruct \
--model_type qwen2 \
--template qwen \
--finetuning_type lora \
--lora_dir ./lora_qwen \
--export_dir ./full_model # 完整模型
2.Ollama 只认 GGUF
工具
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
make
转gguf
python convert-hf-to-gguf.py ../full_model --outtype q4_K_M --outfile qwen2.5-finetuned.gguf
创建模型
ollama create qwen2.5-mymodel -f- <<EOF
FROM qwen2.5-finetuned.gguf
TEMPLATE """{{ if .System }}<|im_start|>system
{{ .System }}<|im_end|>
{{ end }}<|im_start|>user
{{ .Prompt }}<|im_end|>
<|im_start|>assistant
{{ .Response }}<|im_end|>"""
PARAMETER temperature 0.7
PARAMETER num_ctx 8192
EOF
部署
ollama run qwen2.5-mymodel
三:删除模型
ollama
ollama list
ollama rm qwen2.5:7b-instruct
modelscop
rmdir /s /q C:\Users\hsp\.cache\modelscope # 所有模型
modelscope clear-cache --model Qwen/Qwen2.5-7B-Instruct
rm -rf ~/.cache/modelscope # 缓存