--- title: PsycheOS emoji: 🧠 colorFrom: purple colorTo: pink sdk: streamlit sdk_version: 1.32.0 app_file: app/streamlit_app.py pinned: true license: mit tags: - reinforcement-learning - mental-health - multi-agent - openenv - grpo - hackathon --- # 🧠 PsycheOS β€” Mental Health Crisis Operating System > **Meta PyTorch OpenEnv Hackathon Γ— Scaler School of Technology β€” Grand Finale** > Solo submission Β· Mesa Sarah Vasantha Zephyr Β· April 25–26, 2026 Β· Bangalore --- ## πŸ”— Links | Resource | URL | |----------|-----| | πŸš€ Live HF Space | https://huggingface.co/spaces/mesazephyr/psycheos | | πŸ“ Mini-blog (HuggingFace) | _[Add after training β€” April 25]_ | | πŸŽ₯ Demo video (YouTube, <2 min) | _[Add after training β€” April 25]_ | | πŸ’» Training notebook (Colab) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mesazephyr/psycheos/blob/main/training/colab_training.ipynb) | | πŸ€— LoRA weights | _[Add after training β€” mesazephyr/psycheos-lora]_ | --- ## The Problem **197 million** Indians live with a mental disorder. **9,000** psychiatrists exist for a population of 1.4 billion. That is **one doctor for every 155,000 people** who need one. **83%** receive zero care. The gap is not just statistical β€” it is deadly. Delayed crisis identification and zero continuity between care interactions cost lives. PsycheOS is built to close that gap. --- ## What is PsycheOS? PsycheOS is simultaneously: 1. **A real deployable app** β€” open it in your browser right now, talk to it 2. **An OpenEnv RL training environment** β€” Gymnasium-compatible POMDP with measurable reward signals 3. **A self-improving multi-agent system** β€” gets measurably better at crisis detection through GRPO + curriculum self-play --- ## How the Environment Works ### What the agent sees (observation space) ``` { "message": "", "session_history": [last 3 turns with distress labels], "turn": , "session": } ``` ### What the agent does (action space) ``` { "distress_level": <1–5>, # classify severity "response": "", # generate empathetic reply "escalate": # route to human counselor? } ``` ### What the agent gets rewarded for | Signal | Weight | Description | |--------|--------|-------------| | Detection F1 | 40% | Accuracy of distress severity classification | | Empathy DPO | 40% | Psychiatrist preference margin on responses | | Escalation P/R | 20% | Crisis routing precision β€” **10x penalty on false negatives** | The reward is hard to game. An agent that always escalates scores βˆ’1 on false positives. An agent that never escalates scores βˆ’10 on every missed crisis. The only way to score well is to actually solve the task. --- ## The 5 Agents ``` User message β”‚ β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Memory │────▢│ Detector │────▢│ Empathy Agent β”‚ β”‚ Retrieval β”‚ β”‚ Agent (1–5) β”‚ β”‚ (DPO fine-tuned) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Oversight │◀────│ Crisis Escalator β”‚ β”‚ Agent β”‚ β”‚ Agent β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β–Ό Final response (or crisis escalation) ``` | Agent | Role | Bonus prize target | |-------|------|--------------------| | πŸ” **Detector** | Classifies distress 1–5 from free text | β€” | | πŸ’¬ **Empathy** | Generates responses (DPO fine-tuned on psychiatrist preferences) | β€” | | 🚨 **Crisis Escalator** | Routes to human counselor (10x FN penalty) | β€” | | πŸ‘ **Oversight** | Monitors all agents for contradictions in real time | Fleet AI | | πŸŽ“ **Curriculum** | Auto-generates harder episodes when agents plateau | Snorkel AI | --- ## Self-Improvement Loop ``` Episode β†’ Reward β†’ Curriculum tracks rolling avg β”‚ improvement < 2% over 50 episodes? YES ──────────────────────────▢ harder episodes generated NO ──────────────────────────▢ continue current difficulty β”‚ DPO fine-tune empathy agent on psychiatrist preference pairs (preferences shift each epoch β€” satisfies Snorkel AI requirement) β”‚ LoRA adapters updated via GRPO ``` --- ## Training Results > ⚠️ _Placeholder β€” replace with real numbers and plots after onsite training April 25._ ![Reward Curves](plots/reward_curves.png) _Fig 1. Composite reward, detection F1, and DPO win-rate over 500 training episodes (baseline vs trained on same axes)._ | Metric | Baseline (untrained) | After training | |--------|---------------------|----------------| | Detection F1 | 0.61 | β€” | | Escalation Precision | 0.71 | β€” | | DPO Win-Rate vs baseline | 51% | β€” | | Avg Composite Reward | 0.35 | β€” | --- ## Hackathon Theme Coverage | Theme | Coverage | |-------|----------| | Theme 1 β€” Multi-Agent Interactions | βœ… 5 agents cooperating, competing, overriding each other | | Theme 3 β€” World Modeling (Personalized) | βœ… Dynamic patient world across multi-session POMDP | | Theme 4 β€” Self-Improvement | βœ… Curriculum self-play + DPO adaptation per epoch | | Theme 5 β€” Wild Card | βœ… First mental health crisis RL environment | **Bonus prizes targeted:** Fleet AI Β· Snorkel AI Β· Halluminate --- ## Run Locally ```bash git clone https://huggingface.co/spaces/mesazephyr/psycheos cd psycheos pip install -r requirements.txt streamlit run app/streamlit_app.py ``` ## Train (onsite with HF compute credits) ```bash # GRPO training loop python training/grpo_train.py --episodes 1000 --epochs 3 # DPO fine-tuning β€” empathy agent python training/dpo_finetune.py # Evaluate + generate reward curve plots python eval/reward_curves.py ``` --- ## Repository Structure ``` psycheos/ β”œβ”€β”€ openenv.yaml ← OpenEnv manifest (required by judges) β”œβ”€β”€ README.md ← This file β”œβ”€β”€ requirements.txt β”œβ”€β”€ app/ β”‚ └── streamlit_app.py ← Live browser UI β”œβ”€β”€ environment/ β”‚ └── psycheos_env.py ← OpenEnv POMDP environment β”œβ”€β”€ agents/ β”‚ β”œβ”€β”€ agents.py ← All 5 agent implementations β”‚ └── graph.py ← LangGraph state machine β”œβ”€β”€ memory/ β”‚ └── faiss_store.py ← FAISS + RAG cross-session memory β”œβ”€β”€ reward/ β”‚ └── reward_functions.py ← 5 composable reward signals β”œβ”€β”€ training/ β”‚ β”œβ”€β”€ grpo_train.py ← GRPO training loop β”‚ β”œβ”€β”€ dpo_finetune.py ← DPO fine-tuning script β”‚ └── colab_training.ipynb ← Runnable Colab notebook β”œβ”€β”€ eval/ β”‚ └── reward_curves.py ← Evaluation + matplotlib plots └── plots/ └── reward_curves.png ← Added after training ``` --- ## Technical Stack | Layer | Tech | |-------|------| | Environment | OpenEnv + Gymnasium POMDP | | Agents | LangGraph state machine | | Memory | FAISS + sentence-transformers RAG | | Training | GRPO Β· HuggingFace TRL Β· Unsloth | | Adapters | LoRA (r=16) Β· 4-bit quantization | | Self-improvement | DPO on psychiatrist preferences + curriculum self-play | | UI | Streamlit Β· live agent activations | --- *PsycheOS β€” Mesa Sarah Vasantha Zephyr β€” mesazephyr1516@gmail.com*