本地搭建【文档助手】大模型版(LangChain+llama+Streamlit)

news2024/10/1 12:11:31

概述

本文的文档助手就是:我们上传一个文档,然后在对话框中输入问题,大模型会把问题的答案返回。

安装步骤

  1. 先下载代码到本地

LangChain调用llama模型的示例代码:https://github.com/afaqueumer/DocQA(代码不是本人写的,尊重原创)

git clone https://github.com/afaqueumer/DocQA.git
  1. 环境安装
双击 setup_env.bat
  • 如果没反应可能是缺少环境,打开控制台手动执行一下,缺python或者pip的自己根据报错下载一下

如果llama-cpp-python安装报错
(1)需要下载Visual Studio
(2)打开Visual Studio,工具,获取工具和功能
请添加图片描述
(3)等待下载完,重新运行setup_env.bat

如果还有报错【error C2061: 语法错误:】,那么可能是Visual Studio的版本太低了,我一开始用的是2019版本,后来换成了2022
在这里插入图片描述
更新为2022之后重复上面操作

  1. 下载一个靠谱的模型
    https://huggingface.co/TheBloke/Llama-2-7B-GGUF
    本文用的是:TheBloke/Llama-2-7B-GGUF中的最精简版
    在这里插入图片描述
  2. 进入DocQA,修改app.py

原始

llm = LlamaCpp(model_path="./models/llama-7b.ggmlv3.q4_0.bin")
embeddings = LlamaCppEmbeddings(model_path="models/llama-7b.ggmlv3.q4_0.bin")

这里改成自己下载的模型地址,比如:llama-2-7b.Q2_K.gguf

llm = LlamaCpp(model_path="../llama.cpp/models/7B/llama-2-7b.Q2_K.gguf")
embeddings = LlamaCppEmbeddings(model_path="../llama.cpp/models/7B/llama-2-7b.Q2_K.gguf")
  1. 运行
双击run_app.bat

在这里插入图片描述

  1. 测试

准备好一个txt文档

As of October this year, there were nearly 2,500 geographical indication products in China
The reporter learned from the State Intellectual Property Office that in recent years, the quantity and quality of China's geographical indication products have risen rapidly. As of October this year, China has approved a total of 2,495 geographical indication products, and approved 7,013 geographical indications to be registered as collective trademarks and certification trademarks. In 2021, the direct output value of GI products exceeded 700 billion yuan.
In recent years, the State Intellectual Property Office has conscientiously implemented the decisions and arrangements of the CPC Central Committee and the State Council, actively and steadily promoted the unified acceptance channels, unified special signs, unified announcements, unified protection and supervision, unified foreign cooperation and other work, and further improved the system of protection, management and application of geographical indications.
In terms of institutional construction, the State Intellectual Property Office issued the "14th Five-Year Plan for the Protection and Use of Geographical Indications", formulated and issued a unified special indication for geographical indications, revised and issued the "Measures for the Protection of Foreign Geographical Indication Products", and launched the legislative work on geographical indications; In the year, a total of 1,416 cases of infringement of geographical indications were investigated and dealt with across the country, involving an amount of 9.28 million yuan and a fine of 13.023 million yuan

上传到页面中
在这里插入图片描述
没有GPU的痛苦,运行太慢了

注意:别用中文问,这个模型好像不支持中文,换一个支持中文的模型就行了
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1332877.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

自动驾驶规划算法

本文将讲解BFS,Dijstra,A*,动态规划的算法原理,不正之处望读者指正,希望有兴趣的读者能在评论区提出一些这些算法的面试考点,共同学习,一起进步 0 图论基础 图有三种:无向图、有向…

SRE 与 DevOps:你知道它们之间区别吗?

公众号「架构成长指南」,专注于生产实践、云原生、分布式系统、大数据技术分享 DevOps专注于消除阻碍开发和运维之间协作的隔阂,而SRE致力于设计和实施可扩展、可靠的系统,确保最大可靠性。 这篇文章将探讨DevOps和SRE之间的差异&#xff0c…

Podman配置mongodb

文章目录 查询镜像拉取镜像查看镜像运行容器创建root用户 查询镜像 podman search mongo拉取镜像 podman pull docker.io/library/mongo查看镜像 podman images运行容器 podman run -d -p 27017:27017 --namemongodb-test docker.io/library/mongo创建root用户 podman exe…

SSH秘钥登录服务器

一、查看本机 ssh 公钥,生成公钥 1.通过命令窗口 a. 打开你的 git bash 窗口 b. 进入 .ssh 目录:cd ~/.ssh c. 找到 id_rsa.pub 文件:ls d. 查看公钥:cat id_rsa.pub 或者 vim id_rsa.pub git–查看本机 ssh 公钥&#xff0c…

小白--将笔记本上的代码或者项目上传到github上去教程(使用git命令)

文章目录 一、操作教程二、常见问题1. 问题12. 问题2 三、注意 一、操作教程 https://blog.csdn.net/Elon15/article/details/125705706?ops_request_misc%257B%2522request%255Fid%2522%253A%2522170340591716800215092652%2522%252C%2522scm%2522%253A%252220140713.130102…

第六部分 集合论

目录 主要内容 集合的基本概念 集合的基本运算 集合恒等式 初级运算 文氏图 集合的广义并与广义交 广义运算的性质 例1 A{{a},{a,b}} 集合算律 例2 判断下列命题是否为真 例3 设 例4 判断以下命题的真假,并说明理由. 解题思路 主要内容 集合的基本概念 属于、包含…

基于JAVA的超市账单管理系统 开源项目

目录 一、摘要1.1 项目介绍1.2 项目录屏 二、功能模块三、系统设计3.1 总体设计3.2 前端设计3.3 后端设计在这里插入图片描述 四、系统展示五、核心代码5.1 查询供应商5.2 查询商品5.3 新增超市账单5.4 编辑超市账单5.5 查询超市账单 六、免责说明 一、摘要 1.1 项目介绍 基于…

【Postman】以命令行形式执行Postman脚本(使用newman)

一、背景 ​ Postman的操作离不开客户端。但是在一些情况下可能无法使用客户端去进行脚本执行。比如在服务端进行接口测试。由此我们引入了Newman。Newman基于Node.js开发,它使您可以直接从命令行轻松运行和测试Postman测试集。它在构建时考虑了可扩展性&#xff0c…

身为Java“搬砖”程序员,你掌握了多线程吗?

摘要:互联网的每一个角落,无论是大型电商平台的秒杀活动,社交平台的实时消息推送,还是在线视频平台的流量洪峰,背后都离不开多线程技术的支持。在数字化转型的过程中,高并发、高性能是衡量系统性能的核心指…

STM32实现流水灯

led.c #include"led.h"void Led_Init(void) {GPIO_InitTypeDef GPIO_VALUE; //???RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);//???GPIO_VALUE.GPIO_ModeGPIO_Mode_Out_PP;//???? ????GPIO_VALUE.GPIO_PinGPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_…

stm32 pwm输出

PWM 技术原理 CUBEMX PWM配置 pwm初始化 MX_TIM2_Init(); HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_4);设置pwm //pwmVal 0 ~ 1000 __HAL_TIM_SetCompare(&htim2, TIM_CHANNEL_4, pwmVal);

2024苹果手机iOS管理软软件iMazing2.17永久免费版下载教程

iMazing2024是一款专业的苹果IOS设备管理器,强悍的性能远超苹果的iTunes,iMazing 能让广大果粉能已自己的方式管理苹果设备,无需iTunes即可畅快传输或者保存苹果设备中的音乐、消息、文件以及其他数据。 iMazing2Mac-最新绿色安装包下载如下&…

WORDPRESS付费会员插件Paid Memberships Pro v2.12.5 – Plugin + All Addons

WORDPRESS付费会员插件Paid Memberships Pro v2.12.5 – Plugin All Addons 简介: Paid Memberships Pro是一款功能强大的会员订阅和内容限制管理插件,适用于WordPress网站。它提供了丰富的特性和工具,帮助网站所有者轻松地创建和管理付费…

AndroidStudio无法新建aidl文件解决办法

我用的 AS 版本是 Android Studio Giraffe | 2022.3.1 Build #AI-223.8836.35.2231.10406996, built on June 29, 2023 右键新建 aidl 文件, 提示 (AIDL File)Requires setting the buildFeatures.aidl to true in the build file 解决办法 修改 app 的 build.…

【微服务】springboot整合kafka-stream使用详解

目录 一、前言 二、kafka stream概述 2.1 什么是kafka stream 2.2 为什么需要kafka stream 2.2.1 对接成本低 2.2.2 节省资源 2.2.3 使用简单 2.3 kafka stream特点 2.4 kafka stream中的一些概念 2.5 Kafka Stream应用场景 三、环境准备 3.1 搭建zk 3.1.1 自定义d…

基于Java SSM框架实现多人试卷批改考试命题系统项目【项目源码+论文说明】计算机毕业设计

基于java的SSM框架实现多人试卷批改考试命题系统演示 摘要 多人命题系统是高校为教师、学生试卷的重要组成部分,是实现人才培养目标、培养学生科研能力与创新思维、检验学生综合素质与实践能力的重要手段与综合性实践教学环节。我所在学院多采用半手工管理学生试卷…

10_并查集

10_并查集 并查集并查集结构并查集API设计UF(int N)构造方法实现union(int p,int q)合并方法实现代码 并查集应用举例UF_Tree算法优化UF_Tree API设计find(int p)查询方法实现union(int p,int q)合并方法实现代码优化后的性能分析 路径压缩UF_Tree_Weighted API设计代码 案例-畅…

10.3 uinput

uinput 简介 uinput 是一个内核驱动,应用程序通过它可以在内核中模拟一个输入设备,其设备文件名是 /dev/uinput 或 /dev/input/uinput。 uinput 使用 使用 uinput 时遵循以下步骤: 通过 open 打开 uinput 设备通过 ioctl 设置属性位图通过…

<avatar: frontiers of pandora>技术overview

https://www.eurogamer.net/digitalfoundry-2023-avatar-frontiers-of-pandora-and-snowdrop-the-big-developer-tech-interview https://www.youtube.com/watch?vLRI_qgVSwMY&t394s 主要来自euro gamer上digital foundry对于avatar的开发团队Massive工作室的采访&#xf…

STM32数码管

分类 按发光二极管单元连接方式可分为共阳极数码管和共阴极数码管。共阳数码管是指将所有发光二极管的阳极接到一起形成公共阳极(COM)的数码管,共阳数码管在应用时应将公共极COM接到5V,当某一字段发光二极管的阴极为低电平时,相应字段就点亮…