RAG for Local LLM, chat with PDF/doc/txt files, ChatPDF. 纯原生实现RAG功能,基于本地LLM、embedding模型、reranker模型实现,支持GraphRAG,无须安装任何第三方agent库。
854
stars
129
commits
Python
primary language
Apr 2, 2025
updated
local模式的关系图检索的文档问答rerank_model_name_or_path参数设置rerank模型num_expand_context_chunk参数设置命中的候选chunk扩展上下文窗口大小generate_model_name_or_path参数设置底模
在终端中输入下面的命令,然后回车即可。
pip install -r requirements.txt
如果您在使用Windows,建议通过WSL,在Linux上安装。如果您没有安装CUDA,并且不想只用CPU跑大模型,请先安装CUDA。
如果下载慢,建议配置豆瓣源。
请使用下面的命令。取决于你的系统,你可能需要用python或者python3命令。请确保你已经安装了Python。
CUDA_VISIBLE_DEVICES=0 python rag.py
output:
prompt: 基于以下已知信息,用专业知识回答用户的问题。用简体中文回答。
已知内容:
[1] "ReferencesPeter F Brown, John Cocke, Stephen A Della Pietra, Vincent J Della Pietra, Fredrick Jelinek, John DLafferty, Robert L Mercer, and Paul S Roossin. A statistical
[2] "Let be an encoder that infers the content zfor a given sentence xand a styley
...
问题:
自然语言中的非平行迁移是指什么?
---
回答:
自然语言中的非平行迁移是指在文本生成任务中,我们只能假设访问到非平行或单语的文本数据。这类任务包括翻译和摘要,其中所有问题都涉及这类任务。
['[1]\t "ReferencesPeter F Brown, John Cocke, Stephen A Della Pietra, Vincent J Della Pietra, Fredrick Jelinek, John DLafferty, Robert L Mercer, and Paul S Roossin. A statistical approach to machine translation.Computational linguistics
'[2]\t "LetE:X\x02Y!Z be an encoder that infers the content zfor a given sentence xand a styley, andG:Y\x02Z!X be a generator that generates a sentence xfrom a given style yand contentz.EandGform an auto-encoder ',
...
]
python webui.py
现在,你应该已经可以在浏览器地址栏中输入 http://localhost:8082 查看并使用 ChatPDF 了。
[!TIP]
Please set OpenAI API key in environment:
export OPENAI_API_KEY="sk-...".If you don't have LLM key, check out this graphrag._model.py that using
ollama.
python graphrag_demo.py
授权协议为 The Apache License 2.0,可免费用做商业用途。请在产品说明中附加ChatPDF的链接和授权协议。
项目代码还很粗糙,如果大家对代码有所改进,欢迎提交回本项目。
126 commits
3 commits
Python
100.0%
RAG for Local LLM, chat with PDF/doc/txt files, ChatPDF. 纯原生实现RAG功能,基于本地LLM、embedding模型、reranker模型实现,支持GraphRAG,无须安装任何第三方agent库。
854
stars
129
commits
Python
primary language
Apr 2, 2025
updated
local模式的关系图检索的文档问答rerank_model_name_or_path参数设置rerank模型num_expand_context_chunk参数设置命中的候选chunk扩展上下文窗口大小generate_model_name_or_path参数设置底模
在终端中输入下面的命令,然后回车即可。
pip install -r requirements.txt
如果您在使用Windows,建议通过WSL,在Linux上安装。如果您没有安装CUDA,并且不想只用CPU跑大模型,请先安装CUDA。
如果下载慢,建议配置豆瓣源。
请使用下面的命令。取决于你的系统,你可能需要用python或者python3命令。请确保你已经安装了Python。
CUDA_VISIBLE_DEVICES=0 python rag.py
output:
prompt: 基于以下已知信息,用专业知识回答用户的问题。用简体中文回答。
已知内容:
[1] "ReferencesPeter F Brown, John Cocke, Stephen A Della Pietra, Vincent J Della Pietra, Fredrick Jelinek, John DLafferty, Robert L Mercer, and Paul S Roossin. A statistical
[2] "Let be an encoder that infers the content zfor a given sentence xand a styley
...
问题:
自然语言中的非平行迁移是指什么?
---
回答:
自然语言中的非平行迁移是指在文本生成任务中,我们只能假设访问到非平行或单语的文本数据。这类任务包括翻译和摘要,其中所有问题都涉及这类任务。
['[1]\t "ReferencesPeter F Brown, John Cocke, Stephen A Della Pietra, Vincent J Della Pietra, Fredrick Jelinek, John DLafferty, Robert L Mercer, and Paul S Roossin. A statistical approach to machine translation.Computational linguistics
'[2]\t "LetE:X\x02Y!Z be an encoder that infers the content zfor a given sentence xand a styley, andG:Y\x02Z!X be a generator that generates a sentence xfrom a given style yand contentz.EandGform an auto-encoder ',
...
]
python webui.py
现在,你应该已经可以在浏览器地址栏中输入 http://localhost:8082 查看并使用 ChatPDF 了。
[!TIP]
Please set OpenAI API key in environment:
export OPENAI_API_KEY="sk-...".If you don't have LLM key, check out this graphrag._model.py that using
ollama.
python graphrag_demo.py
授权协议为 The Apache License 2.0,可免费用做商业用途。请在产品说明中附加ChatPDF的链接和授权协议。
项目代码还很粗糙,如果大家对代码有所改进,欢迎提交回本项目。
126 commits
3 commits
Python
100.0%