Skip to main content

AI Governance, Safety & Accuracy

The LearnWay AI ecosystem powers conversational tutoring, skill assessments, and code grading. To ensure that AI outputs are strictly grounded in curriculum facts, free of hallucinations, resilient to abuse, and ethically governed, LearnWay enforces a multi-tier AI governance framework.

AI Governance & Verification Pipeline


1. Strict Context Grounding & Anti-Hallucination (RAG)

LearnWay prevents generative hallucinations by enforcing strict Retrieval-Augmented Generation (RAG) boundaries:
  • Curriculum Slide Injection (buildContext):
    • The service retrieves all active, approved lesson slides directly from PostgreSQL (lessonRepo + slideRepo).
    • Assembles a structured context header containing Course Title, Lesson Title, and Difficulty Level (Beginner / Intermediate / Advanced) alongside verbatim slide text and code snippets.
  • Hard Negative Constraints (SYSTEM_PROMPT_TEMPLATE):
    • The system prompt locks the model into the provided lesson content:
      “Stay strictly focused on the lesson content provided below."
      "Never answer questions unrelated to the lesson."
      "If asked something unrelated to the lesson, respond only with: ‘That’s outside this lesson — I can only help with what we’re learning here.’”
  • Difficulty Level Tuning:
    • Ensures that explanations dynamically adjust terminology complexity to match the student’s designated learning level.

2. Input Guardrails & Jailbreak Prevention

  • Pre-Execution Profanity & Prompt Injection Filter (containsProfanity):
    • Custom user questions are evaluated against security filters before invocation.
    • Rejects prompt injection attempts, toxic language, and malicious payload manipulation.
    • Audit logs rejected attempts with status: 'rejected' for security monitoring.

3. Deterministic Caching & Content Consistency

  • 24-Hour Deterministic Cache (Redis TTL: 86,400s):
    • Standard prompt types (EXPLAIN_SIMPLY, SUMMARIZE, EXAMPLE, KEY_TAKEAWAYS) produce deterministic cache keys (ai:cache:<lessonId>:<promptType>).
    • Educational Consistency: Every student asking for an explanation on a specific lesson receives the exact same verified explanation.
  • Instant Cache Invalidation (bustLessonCache):
    • When curriculum creators update slide contents or code examples, the cache for that lesson is automatically purged to guarantee students always receive up-to-date guidance.

4. Quality Feedback Loop & Curriculum Auditing

  1. Granular User Feedback (submitFeedback):
    • Students can submit positive or negative feedback on any AI-generated response.
  2. Curriculum-Level Auditing (getCourseAnalytics):
    • Generates metrics for feedbackPositiveRate, avgLatencyMs, cacheHitRate, and top asked prompt types across 24h, 7d, and 30d sliding windows.
    • Highlights confusing lessons with low feedback scores, prompting curriculum teams to improve lesson slide clarity.

5. Resilience, Quotas & Circuit Breaker Governance