当前位置:   article > 正文

CPU上安装ollama和部署开源Llama2-chinese模型_ollama 中文模型

ollama 中文模型
即使没有GPU显卡,在CPU上借用ollama服务工具,也可以一键体验对话式语言模型。

  • ollama:一个开源的大型语言模型服务,提供了类似OpenAI的API接口和聊天界面,可以非常方便地部署最新版本的GPT模型并通过接口使用。支持热加载模型文件,无需重新启动即可切换不同的模型。
  • Llama2-chinese:Llama2预训练模型包含7B、13B和70B三个版本。Llama2-Chat模型基于预训练模型进行了监督微调,具备更强的对话能力。Llama2-chinese是基于中文指令数据集对Llama2-Chat模型进行的微调,使得Llama2模型有着更强的中文对话能力。 

环境介绍

硬件:AMD Ryzen 3

软件:WSL Debian (使用微软应用商店安装Debian)


安装ollama

官网:https://ollama.com/

简介:(摘自官网)

Get up and running with large language models, locally.
Run Llama 2, Code Llama, and other models. Customize and create your own.

下面以Linux环境为例,说明ollama的下载和安装命令:

curl -fsSL https://ollama.com/install.sh | sh

以上命令下载后,会自动安装,等待安装完成。


部署Llama2-chinese模型

安装ollama后,输入命令ollama,会提示命令格式和说明。

  1. ~$ ollama
  2. Usage:
  3. ollama [flags]
  4. ollama [command]
  5. Available Commands:
  6. serve Start ollama
  7. create Create a model from a Modelfile
  8. show Show information for a model
  9. run Run a model
  10. pull Pull a model from a registry
  11. push Push a model to a registry
  12. list List models
  13. cp Copy a model
  14. rm Remove a model
  15. help Help about any command
  16. Flags:
  17. -h, --help help for ollama
  18. -v, --version Show version information
  19. Use "ollama [command] --help" for more information about a command.

下载模型前,必须先开启ollama服务,命令如下:

ollama serve &

开启ollama服务后,可下载并运行模型Llama2-chinese,命令如下:

  1. ollama pull llama2-chinese
  2. ollama run llama2-chinese

运行模型后,会进入对话流程,输入问题即可开启聊天问答:

  1. ~$ ollama run llama2-chinese
  2. [GIN] 2024/03/01 - 00:47:32 | 200 | 30.418µs | 127.0.0.1 | HEAD "/"
  3. [GIN] 2024/03/01 - 00:47:32 | 200 | 366.398µs | 127.0.0.1 | POST "/api/show"
  4. [GIN] 2024/03/01 - 00:47:32 | 200 | 406.273µs | 127.0.0.1 | POST "/api/show"
  5. [GIN] 2024/03/01 - 00:47:32 | 200 | 446.069µs | 127.0.0.1 | POST "/api/chat"
  6. >>> 你好
  7. 名字:你好
  8. [GIN] 2024/03/01 - 00:47:41 | 200 | 1.65430645s | 127.0.0.1 | POST "/api/chat"
  9. >>> 你是谁
  10. 名字:你不知道吗?我是一个语言模型,用于回答问题和提供信息。
  11. [GIN] 2024/03/01 - 00:48:03 | 200 | 11.945286677s | 127.0.0.1 | POST "/api/chat"
  12. >>> Send a message (/? for help)

输入“ ctrl + d ” 可以结束聊天对话。


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/530223
推荐阅读
相关标签
  

闽ICP备14008679号