How noppakorn001/project-pdpa_assistant works
This repository is a Thai PDPA legal-assistant prototype with a documented six-step data and model workflow plus a Streamlit chat interface. The principal user path is query handling, retrieval and answer generation, then safety checks and a cited response. The README describes the intended integrated path, while the sampled app code includes mock PII/RAG engines; it does not establish that the UI invokes the separate production modules. Evaluation and model preparation are shown as separate branches. Some module connections are documented rather than visible in the partial excerpts.
Main entry points: step4_rag.py Hybrid RAG · step6_evaluation.py Evaluation framework · app.py Chat UI · pdpa_structured_chunks.json Structured chunks
Components 18
Chat experience
- Chat UI
app.py - Mock engines
app.py - Cited response
app.py
Legal knowledge
- PDPA source
PDPA.pdf - Legal chunking
step1_chunking.py - Structured chunks
pdpa_structured_chunks.json - Hybrid RAG
step4_rag.py - Chroma vector store
step4_rag.py
Model development
- Synthetic QA
step2_sdg.py - Training data
pdpa_synthetic_data.jsonl - QLoRA/GRPO
step3_finetune.py - Fine-tuned adapter
step3_finetune.py - LLM inference
step4_rag.py
Safety and evaluation
- Guardrails pipeline
step5_guardrails.py - Evaluation framework
step6_evaluation.py
Observability
- Request logging
logging_utils.py
Other components
- Questioner
- Gemini API
Connections 23
- Questioner → Chat UI: asks
- Chat UI → Mock engines: handles query
- Mock engines → Request logging: starts trace
- PDPA source → Legal chunking: extracts text
- Legal chunking → Structured chunks: writes chunks
- Structured chunks → Synthetic QA: provides context
- Synthetic QA → Gemini API: generates QA
- Synthetic QA → Training data: writes dataset
- Training data → QLoRA/GRPO: trains on
- QLoRA/GRPO → Fine-tuned adapter: saves adapter
- Structured chunks → Hybrid RAG: indexes legal text
- Hybrid RAG → Chroma vector store: embeds and stores
- Hybrid RAG → Chroma vector store: retrieves chunks
- Hybrid RAG → LLM inference: builds prompt
- LLM inference → Fine-tuned adapter: loads adapter
- LLM inference → Gemini API: none
- Chat UI → Guardrails pipeline: intended safety checks
- Guardrails pipeline → Cited response: filters answer
- Mock engines → Cited response: renders answer
- Cited response → Questioner: returns citations
- Evaluation framework → Hybrid RAG: evaluates retrieval
- Evaluation framework → Guardrails pipeline: red-teams safety
- Evaluation framework → Gemini API: judges answers