当前位置: 首页 > news >正文

本地/笔记本/纯 cpu 部署、使用类 gpt 大模型

文章目录

    • 1. 安装 web UI
      • 1.1. 下载代码库
      • 1.2. 创建 conda 环境
      • 1.3. 安装 pytorch
      • 1.4. 安装 pip 库
    • 2. 下载大模型
    • 3. 使用 web UI
      • 3.1. 运行 UI 界面
      • 3.2. 加载模型
      • 3.3. 进行对话

使用 web UI + 大模型文件,即可在笔记本上部署、使用类 gpt 大模型。

1. 安装 web UI

1.1. 下载代码库

https://github.com/oobabooga/text-generation-webui

1.2. 创建 conda 环境

conda create -n textgen python=3.11
conda activate textgen

1.3. 安装 pytorch

文档:https://github.com/oobabooga/text-generation-webui#2-install-pytorch

SystemGPUCommand
Linux/WSLNVIDIApip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
Linux/WSLCPU onlypip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
LinuxAMDpip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm5.6
MacOS + MPSAnypip3 install torch torchvision torchaudio
WindowsNVIDIApip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
WindowsCPU onlypip3 install torch torchvision torchaudio

1.4. 安装 pip 库

文档:https://github.com/oobabooga/text-generation-webui#3-install-the-web-ui

pip install -r <requirements file according to table below>
GPUCPUrequirements file to use
NVIDIAhas AVX2requirements.txt
NVIDIAno AVX2requirements_noavx2.txt
AMDhas AVX2requirements_amd.txt
AMDno AVX2requirements_amd_noavx2.txt
CPU onlyhas AVX2requirements_cpu_only.txt
CPU onlyno AVX2requirements_cpu_only_noavx2.txt
AppleIntelrequirements_apple_intel.txt
AppleApple Siliconrequirements_apple_silicon.txt

2. 下载大模型

TheBloke: https://huggingface.co/TheBloke

TheBloke 是 hugging face 社区的一个用户, ta 提供了许多预量化大模型的下载。

  • 量化:将模型权重中的 float 替换为 int 等数据类型,损失一小部分精度,但减少内存占用、计算开销。

在这里插入图片描述

在该用户的 model 库中搜索需要的模型,常用关键词是 7b-gguf

  • 其中 7b 代表模型的参数量 7 billion(常见参数量有 7b , 13b , 70b),参数量越大,模型精度越高,即对话质量越高。
  • gguf 是一个预量化大模型的格式,支持 cpu 、 gpu 共同加载模型,被广泛使用

在这里插入图片描述

在具体模型页面的 Provided files 部分可以看到该模型的不同量化版本、文件大小、预计内存占用、推荐与否。点击具体量化版本的模型即可下载。

3. 使用 web UI

3.1. 运行 UI 界面

打开 conda 命令行窗口,运行以下命令,并保持窗口开启:

conda activate textgen
cd text-generation-webui
python server.py

3.2. 加载模型

在这里插入图片描述

打开 127.0.0.1:7860 网页链接,model 页面,按上图进行模型加载即可(大概需要几十秒)。

具体文档:https://github.com/oobabooga/text-generation-webui/wiki/04-‐-Model-Tab#llamacpp

3.3. 进行对话

在这里插入图片描述

打开 chat 页面,即可进行对话。

  • 在对话框左侧菜单中有 “开始新对话” 等操作
  • 需注意,大部分模型默认语言为英文(可在模型页面查看详情)
  • 本地模型无法联网
http://www.lryc.cn/news/237658.html

相关文章:

  • 企企通亮相广东智能装备产业发展大会:以数字化采购促进智能装备产业集群高质量发展
  • pycharm安装教程
  • LeetCode【76】最小覆盖子串
  • 光谱图像超分辨率综述
  • Ubuntu apt-get换源
  • 磐舟CI-Web前端项目
  • Flink 运行架构和核心概念
  • 中间件安全:Apache Tomcat 文件上传.(CVE-2017-12615)
  • Linux 命令补充
  • HTTP常见面试题(小林coding版总结)
  • 一整个分析模型库,大数据分析工具都这么玩了吗?
  • 最新企业服务总线ESB的国内主要厂商和开源厂商排名,方案书价格多少
  • react重要知识点(面经)
  • 面试题-6
  • 九宫格 图片 自定义 路径
  • Leetcode经典题目之“双指针交换元素“类题目
  • 计算机基础知识54
  • 深度系统(Deepin)开机无法登录,提示等待一千五百分钟
  • 工具及方法 - 多邻国: Duolingo
  • Redis篇---第十一篇
  • linux CentOS7 安装git 配置秘钥公钥克隆代码
  • 深度学习之生成唐诗案例(Pytorch版)
  • 算法设计与分析算法实现——删数问题
  • 基于Vue+SpringBoot的超市账单管理系统 开源项目
  • 【Linux 内核分析课程作业 1】mmap 实现一个 key-valueMap
  • docker compose使用教程(docker-compose教程)
  • 印刷企业实施MES管理系统需要哪些硬件设施
  • Java JSON字符串替换其中对应的值
  • Android VSYNC发展历程
  • 外呼系统作用和优势有哪些okcc,ai源码