EPTansuo / RAG-system

Using LLM and RAG to build a Q-A system based on specific knowledge. GUI is implemented by Streamlit.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RAG system

Using LLM and RAG to build a Q-A system based on specific knowledge. GUI is implemented by Streamlit.

Author: Kevin Stark, Jiarui Feng, Bowen Wang

Date: 2024/07/07

Version: 1.4

overview

Getting Started

conda create -n rag-system python=3.10
conda activate rag-system
pip install streamlit, PyPDF2, sentence_transformers, faiss-cpu, requests, langchain, dashscope # dashscope for qianwen

Put the files to be read under ./documents/ directory manually, or upload them in GUI.

Run it by streamlit run app.py (Using default model: gpt)

Run it by streamlit run app.py qwen (Using model: qian wen)

running

File Structure

.
├── app.py
├── llmapi.py
├── cache
│   ├── cache_of_documents # Cache of loaded files
│   │   └── cache_of_documents.json
│   └── cache_of_embeddings # Cache of embeddings files
│   │   ├── cache_of_embeddings_batch_1.npy
│   │   ├── cache_of_embeddings_batch_2.npy
│   │   ├── etc.
│       └── cache_of_embeddings.npy
├── documents # Put the files manually here, or upload them in GUI.
│   ├── documents_1.pdf
│   └── etc.
└── README.md

Developing Log

v1.4:感谢@EPTansuo 的PR,增加Qwen LLM的支持。修正README的错误,faiss的库安装需要pip install faiss-cpu或者pip install faiss-gpu,而不是单独安装faiss。

v1.3: 更新缓存检查机制和命名规范;调整GUI,增加侧边栏,因为随着交互内容增加,想上传新文件/查看已上传文件信息要翻很久,如果有侧边栏/冻结首栏比较好。embeddings的缓存增量更新还没做。

v1.2: 添加上传文件功能。

v1.1: 添加多个注释方便阅读;优化函数preprocess_documents名改为split_text_chunks;在GUI里增加各步骤执行成功的反馈;考虑添加local llm;Streamlit里对'''多行注释'''好像有些独特用法,st.markdown (TD)
v1.0: 增加文档载入和向量嵌入的缓存机制;添加向量嵌入的批处理操作避免内存占用过大;暂时没有添加“上传文档”按钮,没有做文件更新缓存变动检查。

About

Using LLM and RAG to build a Q-A system based on specific knowledge. GUI is implemented by Streamlit.


Languages

Language:Python 100.0%