# alibabaclouddocs/aliyun_acp_learning architecture

> Architecture diagram of the GitHub repository alibabaclouddocs/aliyun_acp_learning, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alibabaclouddocs/aliyun_acp_learning
- Repository: https://github.com/alibabaclouddocs/aliyun_acp_learning

## Overview

##### Project type and purpose
- This is an educational “project‐style” repository that walks learners through building, evaluating, tuning and deploying a Retrieval‑Augmented Generation (RAG)‑based question‑answering chatbot using large language models (LLMs).
- Its primary “production” system is the P2 chatbot: code modules and notebooks that implement data ingestion, prompt engineering, retrieval (via Llama‑Index), LLM inference, security checks, evaluation, fine‑tuning and deployment.

##### File structure
- Top level:
- config/load_key.py – centralized loader for API keys
- p1_课程准备 – environment setup notebooks
- p2_构造大模型问答系统 – the core chatbot project, with:
– chatbot/ (evaluate.py, llm.py, rag.py)
– config/load_key.py
– docs/ (PDFs/DOCs used as knowledge base)
– ragas_prompt/ (prompt templates)
– resources/ (JSONL data for testing, training, RAG slices)
– utils/ (custom LLM adapters, evaluation helpers, security sub‑packages: audio, image, text, kb_access_control, OSS service, security manager)
- p3_总结与展望 – wrap‑up notebooks
- Other: requirements.txt for dependencies; README.md for course description.

##### Extract architectural insights from README
- Technologies: Python, OpenAI (or Alicloud’s Baichuan), LangChain/LlamaIndex, JSONL datasets, RAGAS evaluation metrics, vLLM for deployment, Alibaba Cloud function/ECS/PAI.
- Workflow: build → optimize prompts → automate evaluation → extend via plugins → apply RAG → fine‑tune → deploy.

##### Final advice
- Explicitly how data moves from raw documents → retrieval → LLM → evaluation → deployment.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Orchestration Layer
    subgraph "Orchestration Layer"
        direction TB
        SetupNotebooks["Environment Setup Notebooks"]:::data
        OrchestrationNotebooks["Orchestration Notebooks"]:::code
        Notebook28["Deployment Notebook: 2_8_部署模型.ipynb"]:::code
        Notebook29["Deployment Notebook: 2_9_大模型应用生产实践.ipynb"]:::code
        WrapUpNotebooks["Wrap‑up Notebooks"]:::data
    end

    %% Pipeline Start
    OrchestrationNotebooks -->|invokes| UserQuery["User Query"]

    %% Configuration
    ConfigurationService["Configuration Service"]:::code

    UserQuery -->|loads keys| ConfigurationService

    %% Security Layer
    subgraph "Security Layer"
        direction TB
        SecurityManager["Security Manager"]:::code
        TextSecurity["Text Security Check"]:::code
        ImageSecurity["Image Security Check"]:::code
        AudioSecurity["Audio Security Check"]:::code
        KBAccessControl["KB Access Control Filter"]:::code
        OSSService["OSS Service Adapter"]:::code
        SecurityManager --> TextSecurity
        SecurityManager --> ImageSecurity
        SecurityManager --> AudioSecurity
        SecurityManager --> KBAccessControl
        SecurityManager --> OSSService
    end

    UserQuery -->|pre-filter| SecurityManager

    %% Retrieval and Prompt
    RetrievalEngine["Retrieval Engine"]:::code
    KnowledgeDocs["Local Documents KB"]:::data
    KBShards["RAG Data Shards"]:::data
    PromptManager["Prompt Manager"]:::code

    SecurityManager -->|passes| RetrievalEngine
    RetrievalEngine -->|reads| KnowledgeDocs
    RetrievalEngine -->|reads| KBShards
    RetrievalEngine --> PromptManager

    %% LLM Inference
    LLMInference["LLM Inference Service"]:::code
    PromptManager -->|assembles prompt| LLMInference
    LLMInference -->|raw response| SecurityManager

    SecurityManager --> Response["Response to User"]

    %% Evaluation & Fine‑tuning
    subgraph "Evaluation & Fine‑tuning"
        direction TB
        EvaluationRunner["Chatbot Evaluation Runner"]:::code
        RAGASEval["RAGAS Metrics Helper"]:::code
        TrainingJSON1["Training Data: train_1k.jsonl"]:::data
        TrainingJSON2["Training Data: train_100.jsonl"]:::data
        FineTune["Fine‑tuning Module"]:::code
        Response --> EvaluationRunner
        EvaluationRunner --> RAGASEval
        TrainingJSON1 --> FineTune
        TrainingJSON2 --> FineTune
        FineTune --> UpdatedModel["Updated Model"]
    end

    %% Deployment Platform
    subgraph "Deployment Platform"
        direction TB
        vLLM["vLLM Service"]:::external
        CloudInfra["ECS/Function/PAI"]:::external
        UpdatedModel --> vLLM
        vLLM --> CloudInfra
    end

    %% Connections from Orchestration to Deployment Notebooks
    OrchestrationNotebooks --> Notebook28
    OrchestrationNotebooks --> Notebook29

    %% Click Events
    click ConfigurationService "https://github.com/alibabaclouddocs/aliyun_acp_learning/blob/main/大模型ACP认证教程/config/load_key.py"
    click KnowledgeDocs "https://github.com/alibabaclouddocs/aliyun_acp_learning/tree/main/大模型ACP认证教程/p2_构造大模型问答系统/docs/"
    click KBShards "https://github.com/alibabaclouddocs/aliyun_acp_learning/tree/main/大模型ACP认证教程/p2_构造大模型问答系统/resources/"
    click RetrievalEngine "https://github.com/alibabaclouddocs/aliyun_acp_learning/blob/main/大模型ACP认证教程/p2_构造大模型问答系统/chatbot/rag.py"
    click PromptManager "https://github.com/alibabaclouddocs/aliyun_acp_learning/blob/main/大模型ACP认证教程/p2_构造大模型问答系统/ragas_prompt/chinese_prompt.py"
    click LLMInference "https://github.com/alibabaclouddocs/aliyun_acp_learning/blob/main/大模型ACP认证教程/p2_构造大模型问答系统/chatbot/llm.py"
    click AudioSecurity "https://github.com/alibabaclouddocs/aliyun_acp_learning/blob/main/大模型ACP认证教程/p2_构造大模型问答系统/utils/security/audio_security.py"
    click ImageSecurity "https://github.com/alibabaclouddocs/aliyun_acp_learning/blob/main/大模型ACP认证教程/p2_构造大模型问答系统/utils/security/image_security.py"
    click TextSecurity "https://github.com/alibabaclouddocs/aliyun_acp_learning/blob/main/大模型ACP认证教程/p2_构造大模型问答系统/utils/security/text_security.py"
    click KBAccessControl "https://github.com/alibabaclouddocs/aliyun_acp_learning/blob/main/大模型ACP认证教程/p2_构造大模型问答系统/utils/security/kb_access_control/kb_filter.py"
    click OSSService "https://github.com/alibabaclouddocs/aliyun_acp_learning/blob/main/大模型ACP认证教程/p2_构造大模型问答系统/utils/security/oss_service.py"
    click SecurityManager "https://github.com/alibabaclouddocs/aliyun_acp_learning/blob/main/大模型ACP认证教程/p2_构造大模型问答系统/utils/security/security_manager.py"
    click EvaluationRunner "https://github.com/alibabaclouddocs/aliyun_acp_learning/blob/main/大模型ACP认证教程/p2_构造大模型问答系统/chatbot/evaluate.py"
    click RAGASEval "https://github.com/alibabaclouddocs/aliyun_acp_learning/blob/main/大模型ACP认证教程/p2_构造大模型问答系统/utils/ragas_evaluate.py"
    click TrainingJSON1 "https://github.com/alibabaclouddocs/aliyun_acp_learning/blob/main/大模型ACP认证教程/p2_构造大模型问答系统/resources/2_7/train_1k.jsonl"
    click TrainingJSON2 "https://github.com/alibabaclouddocs/aliyun_acp_learning/blob/main/大模型ACP认证教程/p2_构造大模型问答系统/resources/2_7/train_100.jsonl"
    click Notebook28 "https://github.com/alibabaclouddocs/aliyun_acp_learning/blob/main/大模型ACP认证教程/p2_构造大模型问答系统/2_8_部署模型.ipynb"
    click Notebook29 "https://github.com/alibabaclouddocs/aliyun_acp_learning/blob/main/大模型ACP认证教程/p2_构造大模型问答系统/2_9_大模型应用生产实践.ipynb"
    click SetupNotebooks "https://github.com/alibabaclouddocs/aliyun_acp_learning/tree/main/大模型ACP认证教程/p1_课程准备/"
    click WrapUpNotebooks "https://github.com/alibabaclouddocs/aliyun_acp_learning/tree/main/大模型ACP认证教程/p3_总结与展望/"
    click OrchestrationNotebooks "https://github.com/alibabaclouddocs/aliyun_acp_learning/tree/main/大模型ACP认证教程/p2_构造大模型问答系统/"

    %% Styles
    classDef code fill:#D0E6FF,stroke:#1E3A8A;
    classDef data fill:#D1FAE5,stroke:#065F46;
    classDef external fill:#FFE4B5,stroke:#C2410C;
```
