How thu-keg/diakop works
Project Type and Purpose
• DiaKoP is a full-stack, microservice-style system for multi-turn Knowledge-Base Question Answering (KBQA).
• Frontend: two interactive interfaces
• A Gradio-based chat UI for dialogue with the KBQA engine
• A Vue.js “KoPL-vis” program-editing visualizer to inspect/correct parsed logic forms
• Backend: distributed workers handling LLM inference, a semantic-parser service, a dialogue manager, and integration with a KoPL execution engine.
High-Level Components
a. Frontend Cluster
• Gradio Web Server (scripts_bash/launch_gradio.sh + frontend-scripts/chat_*). Provides the chat UI.
• KoPL-vis (frontend-src/KoPL-vis/vis): Vue.js SPA for program visualization and editing.
b. Backend Cluster
• Controller Service (launch_controller.sh): orchestrates model workers.
• Model Worker Pool (launch_worker_vllm.sh): each is a Uvicorn-hosted vLLM Llama-3 inference service.
• Semantic Parser Service (launch_semantic_parser.sh): exposes semantic_parser.py via an HTTP/gRPC endpoint.
• Dialogue Manager (scripts/conv_state.py, conversation.py, chat_controllers.py, dialogue policy/history tracker).
• KoPL Execution Engine (external service to execute parsed programs).
c. Data & Knowledge
• Predefined Knowledge Base (external DB or graph store, referenced by the backend).
• Model artifacts: Llama-3 weights, KOPL semantic-parser checkpoint.
d. DevOps & Deployment
• Bash launch scripts for each microservice.
• requirements.txt, .env for API keys.
• Vue config & package.json for KoPL-vis.
Relationships & Interactions
• User → Gradio UI: inputs question or program corrections.
• Gradio UI → Controller Service: submits inference requests (via REST/gRPC).
• Controller → Model Workers: load-balanced routing of LLM inference tasks.
• Controller → Semantic Parser Service: logic-form parsing calls.
• Dialogue Manager → Knowledge Base: queries to fetch factual data.
• Backend → KoPL Execution Engine API: to run or validate edited logic forms.
Key Architectural Patterns & Principles
• Microservices with a master/worker pattern for scalable LLM inference.
• Clear separation between chat interface and program visualization UI.
• Stateless workers behind a controller for elasticity.
• Single-page app (SPA) frontend using Vue (MVVM pattern).
• Bash script–based orchestration for easy local/demo deployment.
Detailed Breakdown
Layer 1 (Presentation):
• User Browser → Gradio Web Server (Python + Flask/Starlette)
• User Browser → KoPL-vis SPA (Vue.js)
Layer 2 (API & Orchestration):
• Gradio → Controller (REST/gRPC)
• KoPL-vis → Semantic Parser / Execution Engine
Layer 3 (Compute & ML):
• Controller → Model Worker Pool (LLM inference)
• Controller → Semantic Parser Service
Layer 4 (Data & External Systems):
• Dialogue Manager → Knowledge Base (DB/Graph)
• Logic Forms → KoPL Execution Engine API