LLMs之RAG:LangChain-ChatGLM-Webui(一款基于本地知识库(各种文本文档)的自动问答的GUI界面实现)的简介、安装、使用方法之详细攻略

目录

LangChain-ChatGLM-Webui的简介

1、支持的模型

LangChain-ChatGLM-Webui的安装

1、安装

T1、直接安装​

环境准备

启动程序

T2、Docker安装

(1)、Docker 基础环境运行

(2)、Docker 小白运行

2、开启服务:Jina Serving API

(1)、启动服务

(2)、执行curl初始化模型命令

(3)、执行curl构建向量库命令

(4)、执行curl发送指令

(5)、Docker API 服务快速启动

LangChain-ChatGLM-Webui的使用方法

LLMs之RAG:基于LangChain-ChatGLM-Webui项目+云端Docker部署(OpenI启智开源社区)、在线测试—实现基于本地知识库(各种类型文本文档)的自动问答的GUI界面—图文教程之详细攻略


LangChain-ChatGLM-Webui的简介

2023年5月份,LangChain-ChatGLM-Webui项目实现了基于本地知识库(各种文本文档)的自动问答的GUI界面实现,受到langchain-ChatGLM启发, 利用LangChain和ChatGLM-6B系列模型制作的Webui,提供基于本地知识的大模型应用。目前支持上传 txt、docx、md、pdf等文本格式文件, 提供包括ChatGLM-6B系列、Belle系列等模型文件以及GanymedeNil/text2vec-large-chinese、nghuyong/ernie-3.0-base-zh、nghuyong/ernie-3.0-nano-zh等Embedding模型。

GitHub地址:GitHub – thomas-yanxin/LangChain-ChatGLM-Webui: 基于LangChain和ChatGLM-6B等系列LLM的针对本地知识库的自动问答

1、支持的模型

若存在网络问题可在此找到本项目涉及的所有模型:

large language model

Embedding model

ChatGLM-6B

text2vec-large-chinese

ChatGLM-6B-int8

ernie-3.0-base-zh

ChatGLM-6B-int4

ernie-3.0-nano-zh

ChatGLM-6B-int4-qe

ernie-3.0-xbase-zh

Vicuna-7b-1.1

simbert-base-chinese

Vicuna-13b-1.1

paraphrase-multilingual-MiniLM-L12-v2

BELLE-LLaMA-7B-2M

BELLE-LLaMA-13B-2M

internlm-chat-7b-8k

internlm-chat-7b-v1_1

internlm-chat-7b

LangChain-ChatGLM-Webui的安装

视频教程:【免费算力+国产大模型】5分钟手把手带你搭建基于本地知识库的自动问答_哔哩哔哩_bilibili

1、安装

T1、直接安装​

环境准备

项目需要Python>=3.8.1, 默认已安装torch

  1. git clone本项目, 您可以在自己的terminal中执行:git clone https://github.com/thomas-yanxin/LangChain-ChatGLM-Webui.git. 若国内用户访问Github存在网络问题, 也可以执行:https://openi.pcl.ac.cn/Learning-Develop-Union/LangChain-ChatGLM-Webui.git
  2. 进入本项目目录:cd LangChain-ChatGLM-Webui
  3. 安装依赖包:pip install -r requirements.txt, 国内用户可设置清华源加速下载.

另: 若您想要安装测试ModelScope版本, 需要额外安装ModelScope包:pip install modelscope==1.4.3 -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html

OpenI启智社区部署推荐的Docker镜像:dockerhub.pcl.ac.cn:5000/user-images/openi:LangChain-ChatLLM-2.0

启动程序
  • Huggingface版本

在terminal中执行命令:python3 app.py

  • ModelScope版本
  1. 进入modelscope文件目录:cd modelscope
  2. 执行命令:python3 app.py

T2、Docker安装

(1)、Docker 基础环境运行
  1. 运行镜像:docker run -it --rm --runtime=nvidia --gpus all --network host registry.cn-beijing.aliyuncs.com/public-development-resources/langchain-chatglm-webui:Base bash
  2. git clone项目:git clone https://github.com/thomas-yanxin/LangChain-ChatGLM-Webui.git
  3. 进入本项目目录:cd LangChain-ChatGLM-Webui
  4. 安装依赖包:pip3 install -r requirements.txt
  5. 执行app.py:python3 app.py

(2)、Docker 小白运行
  1. 运行镜像:docker run -d --name langchain-ChatGLM-webui --runtime=nvidia --gpus all --network host registry.cn-beijing.aliyuncs.com/public-development-resources/langchain-chatglm-webui:latest

  2. 访问服务:http://ip:7860

  3. 运行环境,镜像大小约14G。

  4. nvidia-runtime 请参考:container-toolkit

  5. 本地模型放置目录:
    BELLE-LLaMA-Local:/pretrainmodel/belle
    Vicuna-Local:/pretrainmodel/vicuna
    ChatGLM-Local:/pretrainmodel/chatglm

  6. 挂载cache目录,容器重启或更新无需重新下载相关模型。
    -v langchain-ChatGLM-webui-cache:/root/.cache/

2、开启服务:Jina Serving API

(1)、启动服务

lc-serve deploy local jina_serving

(2)、执行curl初始化模型命令

curl -X 'POST' \ 'http://localhost:8080/reinit_model' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{"large_language_model": "ChatGLM-6B-int8","embedding_model": "text2vec-base" }'

(3)、执行curl构建向量库命令

curl -X 'POST' \ 'http://localhost:8080/vector_store' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{"file_path": "./README.md" }'

(4)、执行curl发送指令

curl -X 'POST' \ 'http://localhost:8080/predict' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{"input": "ChatGLM-6B的具体局限性?""use_web": true, "top_k": 3, "history_len": 1, "temperature": 0.01, "top_p": 0.1, "history": [] }'

(5)、Docker API 服务快速启动

docker run -d --name LangChain-ChatGLM-Webui --runtime=nvidia --gpus all --network host registry.cn-beijing.aliyuncs.com/public-development-resources/langchain-chatglm-webui:api

LangChain-ChatGLM-Webui的使用方法

LLMs之RAG:基于LangChain-ChatGLM-Webui项目+云端Docker部署(OpenI启智开源社区)、在线测试—实现基于本地知识库(各种类型文本文档)的自动问答的GUI界面—图文教程之详细攻略

https://yunyaniu.blog.csdn.net/article/details/133981047