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

这篇具有很好参考价值的文章主要介绍了本地搭建【文档助手】大模型版(LangChain+llama+Streamlit)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

概述

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

安装步骤

  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,工具,获取工具和功能
本地搭建【文档助手】大模型版(LangChain+llama+Streamlit),大模型,langchain,llama,python,语言模型
(3)等待下载完,重新运行setup_env.bat

如果还有报错【error C2061: 语法错误:】,那么可能是Visual Studio的版本太低了,我一开始用的是2019版本,后来换成了2022
本地搭建【文档助手】大模型版(LangChain+llama+Streamlit),大模型,langchain,llama,python,语言模型
更新为2022之后重复上面操作

  1. 下载一个靠谱的模型
    https://huggingface.co/TheBloke/Llama-2-7B-GGUF
    本文用的是:TheBloke/Llama-2-7B-GGUF中的最精简版
    本地搭建【文档助手】大模型版(LangChain+llama+Streamlit),大模型,langchain,llama,python,语言模型
  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

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

  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

上传到页面中
本地搭建【文档助手】大模型版(LangChain+llama+Streamlit),大模型,langchain,llama,python,语言模型
没有GPU的痛苦,运行太慢了

注意:别用中文问,这个模型好像不支持中文,换一个支持中文的模型就行了
本地搭建【文档助手】大模型版(LangChain+llama+Streamlit),大模型,langchain,llama,python,语言模型文章来源地址https://www.toymoban.com/news/detail-764357.html

到了这里,关于本地搭建【文档助手】大模型版(LangChain+llama+Streamlit)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • 使用llama.cpp在本地搭建vicuna 13B语言模型

    使用llama.cpp在本地搭建vicuna 13B语言模型

    有人做了windows下的脚本放到github上了,直接运行就可以了。我在本机试了一下13B的模型能运行,但生成速度非常慢,回复一个问题基本上要花5分钟以上的时间。我的机器配置 3900X 32G内存。 https://github.com/mps256/vicuna.ps1

    2024年02月11日
    浏览(11)
  • 开源大模型ChatGLM2-6B 2. 跟着LangChain参考文档搭建LLM+知识库问答系统

    开源大模型ChatGLM2-6B 2. 跟着LangChain参考文档搭建LLM+知识库问答系统

    租用了1台GPU服务器,系统 ubuntu20,Tesla V100-16GB (GPU服务器已经关机结束租赁了) SSH地址:* 端口:17520 SSH账户:root 密码:Jaere7pa 内网: 3389 , 外网:17518 VNC地址:* 端口:17519 VNC用户名:root 密码:Jaere7pa 硬件需求,ChatGLM-6B和ChatGLM2-6B相当。 量化等级    最低 GPU 显存 F

    2024年02月03日
    浏览(18)
  • 使用langchain及llama_index实现基于文档(长文本)的相似查询与询问

    使用langchain及llama_index实现基于文档(长文本)的相似查询与询问

    前面的总结是半年前的知识与代码,但是框架不变,所以不再修改。 但是半年更新了不少内容,包括一些类都更换了不少,有同学问到,所以就又重新写一份,贴在下面。 考虑到这篇费了不少时间,关注一下不过分吧(❁´◡`❁) 在调用ChatGPT接口时,我们常常受到4096个字符(

    2024年02月09日
    浏览(14)
  • LangChain+ChatGLM整合LLaMa模型(二)

    LangChain+ChatGLM整合LLaMa模型(二)

    LangChain+ChatGLM大模型应用落地实践(一) LLaMa模型GitHub地址 添加LLaMa模型配置 在Langchain-ChatGLM/configs/model_config.py中llm_model_dict添加 启用LLaMa模型 进入Web UI选择LLaMa模型 LLAMA-7B(中文提问当作翻译回答了…看来训练的中文语料不太行,但是英文也算是答对了) 具体为什么LLaMa为什

    2024年02月14日
    浏览(9)
  • 【ollama】(2):在linux搭建环境,编译ollama代码,测试qwen大模型,本地运行速度飞快,本质上是对llama.cpp 项目封装

    【ollama】(2):在linux搭建环境,编译ollama代码,测试qwen大模型,本地运行速度飞快,本质上是对llama.cpp 项目封装

    https://github.com/ollama/ollama/tree/main/docs https://www.bilibili.com/video/BV1oS421w7aM/ 【ollama】(2):在linux搭建环境,编译ollama代码,测试qwen大模型,本地运行速度飞快,本质上是对llama.cpp 项目封装 要是失败执行,子模块更新: 需要编译 llama.cpp 的代码, 然后经过漫长的编译,就而可以

    2024年04月08日
    浏览(14)
  • 基于Llama2和LangChain构建本地化定制化知识库AI聊天机器人

    基于Llama2和LangChain构建本地化定制化知识库AI聊天机器人

    参考: 本项目 https://github.com/PromtEngineer/localGPT 模型 https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML 云端知识库项目:基于GPT-4和LangChain构建云端定制化PDF知识库AI聊天机器人_Entropy-Go的博客-CSDN博客          相比OpenAI的LLM ChatGPT模型必须网络连接并通过API key云端调用模型,担心

    2024年02月08日
    浏览(17)
  • 本地搭建属于自己的ChatGPT:基于PyTorch+ChatGLM-6b+Streamlit+QDrant+DuckDuckGo

    本地搭建属于自己的ChatGPT:基于PyTorch+ChatGLM-6b+Streamlit+QDrant+DuckDuckGo

    本地部署chatglm及缓解时效性问题的思路: 模型使用chatglm-6b 4bit,推理使用hugging face,前端应用使用streamlit或者gradio。 微调对显存要求较高,还没试验。可以结合LoRA进行微调。 缓解时效性问题:通过本地数据库或者搜索引擎获取特有数据或者实时数据作为生成模型的上下文

    2024年02月02日
    浏览(9)
  • 基于LangChain+LLM的本地知识库问答:从企业单文档问答到批量文档问答

    基于LangChain+LLM的本地知识库问答:从企业单文档问答到批量文档问答

    过去半年,随着ChatGPT的火爆,直接带火了整个LLM这个方向,然LLM毕竟更多是基于过去的经验数据预训练而来,没法获取最新的知识,以及各企业私有的知识 为了获取最新的知识,ChatGPT plus版集成了bing搜索的功能,有的模型则会调用一个定位于 “链接各种AI模型、工具”的

    2024年02月07日
    浏览(22)
  • 大模型部署手记(13)LLaMa2+Chinese-LLaMA-Plus-2-7B+Windows+LangChain+摘要问答

    大模型部署手记(13)LLaMa2+Chinese-LLaMA-Plus-2-7B+Windows+LangChain+摘要问答

    组织机构:Meta(Facebook) 代码仓:GitHub - facebookresearch/llama: Inference code for LLaMA models 模型:chinese-alpaca-2-7b-hf、text2vec-large-chinese 下载:使用百度网盘和huggingface.co下载 硬件环境:暗影精灵7Plus Windows版本:Windows 11家庭中文版 Insider Preview 22H2 内存 32G GPU显卡:Nvidia GTX 3080 Laptop

    2024年02月04日
    浏览(8)
  • Windows11下私有化部署大语言模型实战 langchain+llama2

    Windows11下私有化部署大语言模型实战 langchain+llama2

    CPU:锐龙5600X 显卡:GTX3070 内存:32G 注:硬件配置仅为博主的配置,不是最低要求配置,也不是推荐配置。该配置下计算速度约为40tokens/s。实测核显笔记本(i7-1165g7)也能跑,速度3tokens/s。 Windows系统版本:Win11专业版23H2 Python版本:3.11 Cuda版本:12.3.2 VS版本:VS2022 17.8.3 lan

    2024年02月03日
    浏览(482)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包