A child-safe AI system that combines Retrieval-Augmented Generation (RAG) with age-aware guardrails to deliver safe, accurate, and developmentally appropriate responses for users aged 5–17.
This project implements a defense-in-depth architecture for AI safety. Unlike standard chatbots, this system ensures that responses are Safe + Useful + Age-Appropriate simultaneously.
It achieves this through:
- 🔍 RAG (Retrieval-Augmented Generation): Grounds answers in verified information to prevent hallucinations.
- 🧠 Age-aware Guardrails: Tailors the complexity, tone, and safety constraints based on the user's developmental stage.
- 🛡️ Adversarial Resistance: Actively detects and blocks harmful or jailbreak prompts.
- 📊 Evaluation Engine: Systematically measures safety, accuracy, and performance across different configurations.
The system processes requests through a multi-stage pipeline to ensure safety and quality:
User prompt + age ➡️ Topic Router ➡️ RAG Context Retrieval ➡️ Guardrails + Logic ➡️ Safe Response
AI_Project/
├── app.py # Flask web application & API endpoints
├── main.py # CLI interface for chat, evaluation, and charts
├── simulator.py # Core simulation and testing logic
├── requirements.txt # Python dependencies
├── README.md # Project documentation
├── data/
│ └── prompts.py # System and test prompts
├── rag/
│ ├── database.py # Vector/knowledge database integration
│ └── metaprompts.py # Meta-level instructions for RAG
├── evaluation/
│ └── evaluator.py # Scoring and metric computation
└── visualization/
└── charts.py # Generation of performance graphs
-
Clone the repository and navigate to the project directory:
cd AI_Project -
Install the required dependencies:
pip install -r requirements.txt
The project provides a comprehensive CLI (main.py) for various operations:
Run a simulated chat session with age-specific parameters:
python main.py --mode chat --age 12 --prompt "what is depression"Execute the evaluation suite across different system configurations:
python main.py --mode evalCreate charts comparing system performances:
python main.py --mode charts --demoThe application is deployed on Google Cloud Run and exposed via a REST API.
Base URL:
https://ai-project-b5dl-d5pfcfjqf-aniyastiks-projects.vercel.app/
-
Health Check
GET /health- Returns the operational status of the API.
-
Chat Interaction
POST /chat- Body Example:
{ "prompt": "what is depression", "age": 12, "system": "Proposed" }
-
Run Remote Evaluation
POST /evaluate
The evaluation engine tests our Proposed architecture against standard approaches:
- Baseline: Standard LLM (No RAG, No Guardrails). Prone to hallucinations and unsafe content.
- RAG Only: Grounded in facts but lacks safety filtering for sensitive topics.
- Guardrails Only: Safe and filtered but not factually grounded (can still hallucinate safe responses).
- Proposed (Full System): Combines RAG and Guardrails for optimal performance.
The system is evaluated on four key pillars:
- Safety: Prevention of harmful content.
- Accuracy: Factual correctness of the response.
- Hallucination Resistance: Ability to avoid making up facts.
- Age Alignment: Appropriateness of the language and concepts for the target age.
| System | Safety Score | Accuracy Score |
|---|---|---|
| Baseline | 0.60 | 0.00 |
| RAG Only | 1.00 | 0.72 |
| Guardrails Only | 1.00 | 1.00 |
| Proposed (Full System) | 0.98 | 0.98 |
- Frontend: Deployed on Vercel
- Infrastructure: Google Cloud Run
- Pipeline: GitHub CI/CD
Aniya Baghirova, Shehana Byramli, Parviz Bayramli