# rag_system **Repository Path**: joyamon/rag_system ## Basic Information - **Project Name**: rag_system - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-04-16 - **Last Updated**: 2026-04-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # RAG 智能问答系统 基于 LangChain + 本地文档(PDF、Word、PPT)+ 网页的智能问答系统 ## 功能特性 - 📄 **多格式支持**:PDF、Word(.docx)、PPT(.pptx)、网页(URL) - 🔍 **语义检索**:基于向量相似度的精准文档检索 - 💬 **智能问答**:结合检索结果生成准确答案 - 🎨 **Web UI**:友好的 Gradio 交互界面 - 🔄 **增量更新**:支持追加新文档,无需全量重建 ## 项目结构 ``` rag_system/ ├── config.yaml # 配置文件 ├── requirements.txt # Python 依赖 ├── run.py # 主启动脚本 ├── docs/ # 文档存放目录 ├── data/ # 向量数据库存储 │ └── vectorstore/ # FAISS 向量索引 ├── src/ │ ├── __init__.py │ ├── config.py # 配置管理 │ ├── document_loader.py # 文档加载器 │ ├── text_splitter.py # 文本分块 │ ├── embedding.py # 嵌入模型 │ ├── vectorstore.py # 向量存储 │ ├── rag_chain.py # RAG 问答链 │ └── ui.py # Gradio 界面 ``` ## 快速启动 ### 1. 安装依赖 ```bash pip install -r requirements.txt ``` ### 2. 配置文件 编辑 `config.yaml`,设置: - `llm.model_name`: LLM 模型名称(如 `qwen`、`gpt-4` 等) - `llm.api_base`: API 地址 - `llm.api_key`: 你的 API Key - `embeddings.model_name`: 嵌入模型名称 ### 3. 放置文档 将 PDF、Word、PPT 文件放入 `docs/` 目录 ### 4. 启动系统 ```bash python run.py ``` ## 使用说明 1. **首次运行**:系统会自动加载 `docs/` 目录下的所有文档,构建向量索引 2. **添加新文档**:放入新文档后,刷新页面即可自动更新索引 3. **提问**:在对话框中输入问题,系统会在文档中检索相关内容并生成答案 ## 支持的文档格式 | 格式 | 扩展名 | 依赖库 | |------|--------|--------| | PDF | .pdf | PyPDF2 / pdfplumber | | Word | .docx | python-docx | | PowerPoint | .pptx | python-pptx | | 网页 | URL | requests / BeautifulSoup4 | | 纯文本 | .txt | - | ## 技术栈 - **LangChain**: RAG 框架 - **FAISS**: 向量数据库 - **Gradio**: Web UI - **ChatGLM4 / Qwen / OpenAI**: LLM(可选)