privategpt 处于概念验证(poc)阶段,至少证明可以完全在本地创建类似于 chatgpt 的大模型,可以预见这种 poc 转换为实际产品之后的潜力,可以让公司访问个性化、安全和私密的 chatgpt 来提高生产力。
页面链接,感兴趣的用户可以点击阅读。
在没有互联网连接的情况下,使用llm的力量对您的文档提出问题。 100%私有,任何时候都没有数据离开您的执行环境。您可以在没有互联网连接的情况下摄取文档和提问!
使用,,,和构建。
为了设置您的环境以运行此处的代码,请首先安装所有要求:
pip3 install -r requirements.txt
然后,下载llm模型并将其放在您选择的目录中:
- llm:默认为 。如果您更喜欢不同的 gpt4all-j 兼容型号,只需下载它并在您的文件中引用它。
.env
将模板复制到example.env.env
cp example.env .env
并在文件中适当地编辑变量。.env
model_type: supports llamacpp or gpt4all
persist_directory: is the folder you want your vectorstore in
model_path: path to your gpt4all or llamacpp supported llm
model_n_ctx: maximum token limit for the llm model
model_n_batch: number of tokens in the prompt that are fed into the model at a time. optimal value differs a lot depending on the model (8 works well for gpt4all, and 1024 is better for llamacpp)
embeddings_model_name: sentencetransformers embeddings model name (see https://www.sbert.net/docs/pretrained_models.html)
target_source_chunks: the amount of chunks (sources) that will be used to answer a question
注意:由于加载嵌入的方式,第一次运行脚本时,需要互联网连接才能下载嵌入模型本身。langchainsentencetransformers
测试数据集
此存储库使用作为示例。
引入自己的数据集的说明
将任何和所有文件放入目录中source_documents
支持的扩展包括:
.csv:.csv.docx:文字文档,.doc:文字文档,.enex:印象笔记,.eml:电子邮件.epub: epub,.html: html 文件,.md: 降价,.msg: 展望消息,.odt:打开文档文本,.pdf: 便携式文档格式 (pdf),.pptx:幻灯片文档,.ppt:幻灯片文档,.txt: 文本文件 (utf-8),
运行以下命令以引入所有数据。
python ingest.py
输出应如下所示:
creating new vectorstore
loading documents from source_documents
loading new documents: 100%|██████████████████████| 1/1 [00:01<00:00, 1.73s/it]
loaded 1 new documents from source_documents
split into 90 chunks of text (max. 500 tokens each)
creating embeddings. may take some minutes...
using embedded duckdb with persistence: data will be stored in: db
ingestion complete! you can now run privategpt.py to query your documents
它将创建一个包含本地向量存储的文件夹。每个文档需要 20-30 秒,具体取决于文档的大小。 您可以根据需要引入任意数量的文档,所有文档都将累积在本地嵌入数据库中。 如果要从空数据库开始,请删除该文件夹。dbdb
注意:在摄取过程中,没有数据离开您的本地环境。您可以在没有 internet 连接的情况下进行摄取,但首次运行采集脚本时下载嵌入模型除外。
在本地对您的文件提出问题!
要提出问题,请运行如下命令:
python privategpt.py
并等待脚本需要您的输入。
> enter a query:
按回车键。您需要等待 20-30 秒(具体取决于您的计算机),而 llm 模型会使用提示并准备答案。完成后,它将打印答案和它用作文档中上下文的 4 个来源;然后,您可以提出另一个问题而无需重新运行脚本,只需再次等待提示即可。
注意:您可以关闭互联网连接,脚本推理仍然有效。没有数据流出您的本地环境。
键入以完成脚本。exit
命令行界面
该脚本还支持可选的命令行参数来修改其行为。您可以通过在终端中运行命令来查看这些参数的完整列表。python privategpt.py --help
选择正确的本地模型和强大的功能可以在本地运行整个管道,而无需任何数据离开环境,并且性能合理。langchain
ingest.py使用工具解析文档并使用 () 在本地创建嵌入。然后,它使用向量存储将结果存储在本地矢量数据库中。langchainhuggingfaceembeddingssentencetransformerschromaprivategpt.py使用基于or的本地llm来理解问题并创建答案。答案的上下文是使用相似性搜索从本地向量存储中提取的,以从文档中找到正确的上下文。gpt4all-jllamacppgpt4all-j包装器是在 langchain 0.0.162 中引入的。
python version
要使用此软件,您必须安装 python 3.10 或更高版本。早期版本的 python 将无法编译。
c 编译器
如果在构建轮子的过程中遇到错误,则可能需要在计算机上安装c 编译器。pip install
对于windows 10/11
若要在 windows 10/11 上安装 c 编译器,请执行以下步骤:
- 安装 visual studio 2022。
- 确保选择了以下组件:
- 通用windows平台开发
- c 适用于windows的cmake工具
- 从。
- 运行安装程序并选择组件。
gcc
运行英特尔的 mac
当运行带有英特尔硬件(不是 m1)的 mac 时,您可能会遇到 clang: 错误:在 pip 安装期间,clang 编译器不支持“-march=native”。
如果是这样,请在 pip 安装期间设置您的主旗。例如:archflags=“-arch x86_64” pip3 install -r 要求.txt
未经允许不得转载:凯发k8国际真人 » 开源模型 privategpt