Merge pull request #145 from LDLINGLINGLING/ollama_manual_installation

add ollama support minicpm-1b
This commit is contained in:
LDLINGLINGLING 2024-06-24 14:20:33 +08:00 committed by GitHub
commit 9d7e7ff2a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -204,11 +204,34 @@ MiniCPM支持[llama.cpp](https://github.com/ggerganov/llama.cpp/) 、[ollama](ht
更多参数调整[详见](https://github.com/ggerganov/llama.cpp/blob/master/examples/main/README.md)
**ollama**
***ollama自动安装模型***
1. [安装ollama](https://github.com/ollama/ollama)
2. 在命令行运行:
```
ollama run modelbest/minicpm-2b-dpo
```
***ollama手动安装模型***
1. [安装ollama](https://github.com/ollama/ollama)
2. 下载gguf形式的模型。[下载链接2b-fp16格式](https://huggingface.co/runfuture/MiniCPM-2B-dpo-fp16-gguf) [下载链接2b-q4km格式](https://huggingface.co/runfuture/MiniCPM-2B-dpo-q4km-gguf) [下载链接1b-fp16格式](https://huggingface.co/linglingdan/MiniCPM-1b-fp16-gguf) [下载链接1b-qr_1格式](https://huggingface.co/linglingdan/MiniCPM-1b-q4-1)
3. 在命令行运行以下命令,model_name可自定义
```
touch model_name.Modelfile
```
4. 将以上model_name.Modelfile的内容修改如下,FROM空格后写入gguf的模型路径
```
FROM model_path/model_name.gguf
TEMPLATE """<s><USER>{{ .Prompt }}<AI>{{ .Response }}"""
PARAMETER stop "<\s>"
```
5. 在命令行运行以下命令创建ollama模型ollama_model_name可自定义model_name.Modelfile参考第3步命名
```
ollama create ollama_model_name -f model_name.Modelfile
```
6. 运行ollama模型
```
ollama run ollama_model_name
```
**fastllm**
1. [编译安装fastllm](https://github.com/ztxz16/fastllm)
@ -236,7 +259,18 @@ print(model.response("<用户>山东省最高的山是哪座山, 它比黄山高
python -m mlx_lm.generate --model mlx-community/MiniCPM-2B-sft-bf16-llama-format-mlx --prompt "hello, tell me a joke." --trust-remote-code
```
**gptq量化**
1. 首先git获取[minicpm_gptqd代码](https://github.com/LDLINGLINGLING/AutoGPTQ/tree/minicpm_gptq)
2. 进入minicpm_gptqd主目录./AutoGPTQ命令行输入
```
pip install e .
```
3. 前往[模型下载](#1)下载未量化的MiniCPM仓库下所有文件放至本地同一文件夹下,1b、2b模型均可,训练后模型亦可。
4. 在./AutoGPTQ/examples/quantization路径下输入以下命令其中no_quantized_path是第3步模型下载路径save_path是量化模型保存路径--bits 为量化位数可以选择输入4或者8
```
python quant_with_alpaca.py --pretrained_model_dir no_quantized_path --quantized_model_dir save_path --bits 4
```
5. 可以使用./AutoGPTQ/examples/quantization/inference.py进行推理也可以参考前文使用vllm对量化后的模型单卡4090下minicpm-1b-int4模型vllm推理在2000token/s左右。
<p id="community"></p>
## 开源社区