# 基于RAG的智能客服Agent系统 **Repository Path**: leke_code/rag_agent ## Basic Information - **Project Name**: 基于RAG的智能客服Agent系统 - **Description**: 面向电商/金融场景,构建可解释、高准确率的智能客服系统,需解决传统LLM幻觉问题,支持实时知识库更新(如商品规则/政策变更),并能在4060硬件上流畅运行。 - **Primary Language**: Python - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2026-03-18 - **Last Updated**: 2026-03-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Intelligent Customer Service Agent System Based on RAG #### Introduction Targeting e-commerce/financial scenarios, building an interpretable and highly accurate intelligent customer service system that addresses the traditional LLM illusion problem, supports real-time knowledge base updates (such as product rules/policy changes), and can run smoothly on 4060 hardware. #### 1. Software architecture 1. RAG module: Chroma vector database (lightweight, GPU accelerated)+custom retrieval strategy (mixed semantics+keyword retrieval) 2. Agent framework: LangGraph (state machine driven multi round dialogue)+custom tool calls (such as querying order system APIs) 3. Model layer: Lightweight LLM (such as Llama-8B-Instruct-4bit quantized version, 4060 memory friendly)+Prompt engineering (few sample examples+thought chain guidance) #### 2. Optimization points 1. Retrieval result relevance reordering (based on cross encoder) 2. Dialogue history compression (reducing context length) #### 3. Key implementation steps 1. Knowledge base construction: Crawl/organize business documents → Text segmentation (SentencePiece) → Embedding model (BGE-M3) vectorization → Chroma storage (supports incremental updates) 2. Optimization of retrieval module: Implement HybridRetriever (semantic retrieval+BM25 keyword retrieval fusion), dynamically adjust weights through relevances_store 3. Agent process design: Use LangGraph to define the State (including chat_ history/retrieved.docs/current step), with nodes including: user input parsing → retrieval enhancement → LLM generation → tool invocation (such as calculating shipping costs) → response verification (regular verification of phone numbers/order numbers) #### 4. Deployment optimization Model 4-bit quantization (GPTQ)+vLLM inference service (supporting dynamic batch processing), 4060 actual QPS ≥ 15 (single round dialogue) #### 5.architecture ``` rag_agent_system/ │ ├── knowledge_base/ # Knowledge base management │ ├── documents/ # Raw documents storage │ ├── vector_db/ # ChromaDB vector database storage │ └── knowledge_builder.py # Knowledge base construction module │ ├── retrieval/ # Document retrieval components │ ├── hybrid_retriever.py # Hybrid retrieval (vector + keyword) │ └── reranker.py # Result reranking module │ ├── agent/ # Agent core logic │ ├── agent_state.py # State management for conversation │ ├── langgraph_workflow.py # LangGraph conversation workflow │ ├── tools.py # Agent tools and utilities │ └── history.py # Conversation history compression │ ├── prompt/ # Prompt project │ ├── onstraints.txt # Constraint Settings │ └── thought_instructions.txt # Thinking Process Design │ ├── models/ # Model management │ └── setup_models.py # Model initialization and configuration │ ├── api/ # API interface │ └── main.py # FastAPI server implementation │ ├── utils/ # Utility functions │ └── document_loader.py # Document loading utilities │ └── requirements.txt # Python dependencies ```