概述
本文的文檔助手就是:我們上傳一個文檔,然后在對話框中輸入問題,大模型會把問題的答案返回。
安裝步驟
- 先下載代碼到本地
LangChain調用llama模型的示例代碼:https://github.com/afaqueumer/DocQA(代碼不是本人寫的,尊重原創(chuàng))
git clone https://github.com/afaqueumer/DocQA.git
- 環(huán)境安裝
雙擊 setup_env.bat
- 如果沒反應可能是缺少環(huán)境,打開控制臺手動執(zhí)行一下,缺python或者pip的自己根據報錯下載一下
如果llama-cpp-python安裝報錯
(1)需要下載Visual Studio
(2)打開Visual Studio,工具,獲取工具和功能
(3)等待下載完,重新運行setup_env.bat
如果還有報錯【error C2061: 語法錯誤:】,那么可能是Visual Studio的版本太低了,我一開始用的是2019版本,后來換成了2022
更新為2022之后重復上面操作
- 下載一個靠譜的模型
https://huggingface.co/TheBloke/Llama-2-7B-GGUF
本文用的是:TheBloke/Llama-2-7B-GGUF中的最精簡版 - 進入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")
- 運行
雙擊run_app.bat
- 測試
準備好一個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.zghlxwxcb.cn/news/detail-764357.html
注意:別用中文問,這個模型好像不支持中文,換一個支持中文的模型就行了文章來源地址http://www.zghlxwxcb.cn/news/detail-764357.html
到了這里,關于本地搭建【文檔助手】大模型版(LangChain+llama+Streamlit)的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!