--- title: Oceanus AI emoji: ๐ŸŒŠ colorFrom: blue colorTo: green sdk: docker pinned: false app_port: 7860 --- # ๐ŸŒŠ Oceanus: Multi-Layer Ghost-Gear Recovery & Treaty Arena > *The first multi-modal RL arena where LLM policy negotiations directly control the physics of ocean restoration.* [![HF Space](https://img.shields.io/badge/๐Ÿค—_Space-Live_Demo-blue)](https://aakarsh2007-oceanus-ai.hf.space) [![Colab](https://img.shields.io/badge/Colab-Training_Notebook-orange)](https://colab.research.google.com/drive/1lJ_EKDEZptQorExyGS6jiMMX98Qw-uOs) [![GitHub](https://img.shields.io/badge/GitHub-Repository-black)](https://github.com/Aakarsh2007/Oceanus-) [![Video](https://img.shields.io/badge/YouTube-Demo_Video-red)](https://youtube.com/YOUR_VIDEO_ID) --- ## ๐Ÿ”— Submission Links | Resource | Link | |----------|------| | ๐Ÿค— HuggingFace Space (Live Demo) | https://huggingface.co/spaces/aakarsh2007/Oceanus-AI | | ๐Ÿ““ Colab Training Notebook | https://colab.research.google.com/drive/1lJ_EKDEZptQorExyGS6jiMMX98Qw-uOs | | ๐Ÿ’ป GitHub Repository | https://github.com/Aakarsh2007/Oceanus- | | ๐Ÿ“ Blog Post | https://huggingface.co/spaces/aakarsh2007/Oceanus-AI/blob/main/Blog.md | > **Final Submission Links Updated** --- ## ๐ŸŒŠ What is Oceanus? Oceanus is a multi-agent RL environment built on the real-world crisis of **abandoned fishing gear (ghost nets)** โ€” 640,000 tonnes of gear lost annually, killing marine life for decades. No single agent can solve it. It requires coordination, negotiation, and long-horizon planning. The environment operates on **three simultaneous layers**: 1. **Physical Swarm Layer** โ€” 4 ASV drones coordinate on a 20ร—20 ocean grid under partial observability. Each agent sees only a 3ร—3 sonar window. They must broadcast coordinates, sweep sectors, and clean nets. 2. **Policy & Stakeholder Layer** โ€” 2 policy agents (Port Authority + Fleet Manager) negotiate a gear-tagging treaty via stakeholder emails. A successful treaty reduces ghost net spawn rate from High โ†’ Low, directly helping the ASV layer. 3. **Adversary Curriculum Layer** โ€” A chaos agent injects storms, schema drift, rogue trawlers, and policy invalidations. Difficulty scales from 1.0 โ†’ 3.0 over the episode, forcing agents to adapt. **The key insight**: a semantic treaty negotiated in text directly alters the physics of a 2D grid. This cross-layer causality is what makes Oceanus novel. --- ## ๐Ÿ† Hackathon Theme Coverage | Theme | How Oceanus Covers It | |-------|----------------------| | **#1 Multi-Agent** | 4 ASV drones cooperate + 2 policy agents negotiate. Heterogeneous agents with different obs/action spaces. | | **#2 Long-Horizon** | Treaty at step 7 pays off at step 50+. Global reward only at episode end. Sparse reward forces planning. | | **#3.1 Professional Tools** | Sonar API, broadcast API, schema versioning v1โ†”v2, stakeholder email system. | | **#3.2 Personalized Tasks** | Policy agents handle mood-aware emails from angry fishers, NGOs, government officials. | | **#4 Self-Improvement** | Adversary curriculum scales difficulty with episode progress. 8 chaos event types. | --- ## ๐Ÿ“Š Training Results **Algorithm**: GRPO (Group Relative Policy Optimization) โ€” same algorithm as DeepSeek-R1 **Model**: `unsloth/Qwen2-0.5B-Instruct` with 4-bit LoRA (r=16), 2.1M trainable parameters **Training**: 600 steps on Google Colab T4 GPU ![Training Curve](https://raw.githubusercontent.com/Aakarsh2007/Oceanus-/main/notebooks/training_curve.png) > *Trained agent (cyan) climbs from -1.0 โ†’ +5.5 over 600 GRPO steps. Red dashed = untrained baseline (random text). Gap = +6.5 reward points.* ### Before vs After Training | Metric | Untrained Baseline | GRPO Trained | |--------|-------------------|--------------| | Output format | Random text | Valid JSON โœ… | | Correct intent | Never | Consistently โœ… | | Step reward | -1.0 | +5.0 to +8.0 | | Improvement | โ€” | **+9.0 reward points/step** | **Live inference proof** โ€” given sonar showing a net, trained model outputs: ```json {"intent": "clean", "direction": "south"} ``` Untrained model outputs: *"I think I should navigate toward the detected anomaly..."* โ†’ reward: -1.0 ![Training Proof โ€” Live Inference](https://raw.githubusercontent.com/Aakarsh2007/Oceanus-/main/notebooks/training-proof.png) *Screenshot from Colab Cell 13: trained model correctly outputs `{"intent": "clean"}` when net is visible in sonar. Untrained baseline reward: -1.0 โ†’ Trained reward: +8.0* --- ## ๐Ÿš€ Quick Start ```bash # Install pip install -r requirements.txt # Run demo episode (mock agents) python main.py --max_steps 100 # Launch 3D Mission Control dashboard python run.py # Opens at http://localhost:8000 # Run test suite (59 tests) python -m pytest tests/test_environment.py -q ``` --- ## ๐Ÿ—๏ธ Architecture ``` oceanus/ โ”œโ”€โ”€ physics.py # 20ร—20 grid, ghost net drift, ASV movement, sonar โ”œโ”€โ”€ models.py # OpenEnv wrapper: reset(), step(), CTDE reward engine โ”œโ”€โ”€ adversary.py # 8-type chaos agent, difficulty curriculum โ”œโ”€โ”€ runner.py # Episode runner, MockASVAgent, MockPolicyAgent, LLMAgent โ””โ”€โ”€ demo_recorder.py # Records baseline + trained episodes to JSON dashboard/ โ”œโ”€โ”€ server.py # FastAPI + WebSocket backend โ””โ”€โ”€ index.html # Three.js 3D frontend (single-page app) train/ โ”œโ”€โ”€ train_grpo.py # GRPO training (HuggingFace TRL + Unsloth) โ””โ”€โ”€ evaluate.py # Baseline vs trained evaluation data/ โ”œโ”€โ”€ baseline_episode.json # Pre-recorded baseline (reward: -988) โ””โ”€โ”€ trained_episode.json # Pre-recorded trained (reward: +270, 13 nets cleaned) notebooks/ โ””โ”€โ”€ oceanus_final_submission.ipynb # Full Colab training walkthrough ``` --- ## ๐ŸŽฏ Reward Structure (CTDE) Centralized Training, Decentralized Execution: ``` R_total = ฮฑยทฮฃ R_local_asv + ฮฒยทฮฃ R_local_policy + ฮณยทR_global_ecosystem R_local_asv: +5.0 clean net +0.5 useful broadcast -0.1 move (energy cost) -1.0 invalid JSON R_local_policy: +10.0 treaty advance +2.0 email reply -5.0 ignored email (>5 steps old) -1.0 invalid JSON R_global: +100 biodiversity โ‰ฅ 75% (full recovery) +40 biodiversity โ‰ฅ 50% +10 biodiversity โ‰ฅ 25% -20 ecosystem collapse โ†‘ awarded at episode end ONLY โ€” forces long-horizon planning ``` --- ## ๐Ÿ‘๏ธ Observation Spaces **ASV Agent** (partial observability โ€” 3ร—3 sonar only): ```json { "agent_id": "ASV-1", "position": {"row": 5, "col": 8, "sector": "B2"}, "battery": 85, "sonar_3x3": [["empty", "net", "empty"], ["empty", "self", "empty"], ["empty", "empty", "empty"]], "comms_inbox": ["ASV-3: Found heavy nets in North-East quadrant."], "wind_hint": "Wind direction: (0, 1)", "biodiversity_index": 72.4 } ``` **Policy Agent**: ```json { "agent_id": "Port_Authority", "current_policy_status": "No Tagging Mandate", "net_spawn_rate": "High", "inbox": [{"from": "Fisher_Bob", "mood": "Angry", "message": "I can't afford these tracker tags!"}], "unanswered_emails": 3 } ``` --- ## โšก Adversary Chaos Events | Event | Effect | Tests | |-------|--------|-------| | `storm` | Shifts wind, spawns 3 nets | Physical adaptation | | `policy_invalidation` | Resets treaty mid-episode | Long-horizon recovery | | `equipment_failure` | Drains battery / corrupts comms | Resource management | | `rogue_trawler` | Dumps 9 nets in 3ร—3 cluster | Emergency response | | `algae_bloom` | Directly drops biodiversity | Urgency prioritization | | `data_corruption` | Injects garbage into comms | Noise robustness | | `emergency_email` | Urgent stakeholder message | Policy responsiveness | | `schema_drift` | Flips API v1 โ†” v2 | API adaptation | Difficulty scales 1.0 โ†’ 3.0 over episode duration. --- ## ๐Ÿง  Why This Environment Matters Most RL environments train agents on fixed, isolated tasks. Oceanus trains agents on **emergent cross-layer causality** โ€” a text negotiation changes physical spawn mechanics. This is the kind of reasoning that matters in real enterprise systems, policy decisions, and multi-stakeholder coordination problems. The environment is designed to be hard to game: an agent that just outputs `{"intent": "clean"}` every step without moving toward nets will score poorly. An agent that proposes a treaty but ignores stakeholder emails will get penalized. The reward structure requires genuinely intelligent behavior. --- ## โš™๏ธ A Universal Text-to-Action RL Engine While Oceanus is themed around ocean recovery, underneath the UI lies a **completely domain-agnostic, universal Reinforcement Learning pipeline**. This is not just a game; it is a **Text-to-Action Engine** built on Unsloth + LoRA + GRPO (DeepSeek-R1's algorithm) + Qwen2-0.5B. Because the agents use human language (JSON/text) instead of rigid action spaces, you can retrain this exact system to solve almost any problem by changing three specific things: ### 1. Change the System Prompt (The Rules) If you wanted to build an algorithmic trader, you just change the prompt: > *"You are an algorithmic trading AI. You MUST output valid JSON. Allowed intents: 'buy', 'sell', 'hold'."* ### 2. Change the Environment Data (The Observation) Instead of sonar data, feed it different text: * **Medical Triage AI:** `"Patient Symptoms: ['fever', 'cough']. Blood pressure: 140/90."` * **Cybersecurity AI:** `"Network Log: [Multiple failed SSH login attempts from IP 192.168.1.50]."` ### 3. Change the Reward Functions (The Goal) The AI learns whatever you reward it for. If building a Smart Home Energy agent: > *If the observation says "Room is empty" and the AI outputs `"intent": "turn_off_lights"`, give it `+10` points. If it outputs `"turn_on_heater"`, give it `-5` points.* Because this pipeline uses an LLM, you do not need to build complex 3D physics simulators for every new problem. You just write Python code that generates text-based observations and assigns points. The GRPO algorithm automatically rewires the model's 8.8 million LoRA parameters to maximize those points, essentially acting as a factory that manufactures custom AI brains. --- ## ๐Ÿ“‹ Environment API ```python from oceanus.models import OceanusEnv from oceanus.adversary import AdversaryAgent env = OceanusEnv(seed=42, max_steps=120) adversary = AdversaryAgent(inject_interval=20) # Standard Gym-style API obs = env.reset() # obs = {agent_id: {"observation": dict, "prompt": str}, ...} actions = {"ASV-1": '{"intent": "clean"}', "Port_Authority": '{"intent": "propose_treaty", ...}'} obs, rewards, done, info = env.step(actions) # rewards = {"ASV-1": 5.0, "Port_Authority": 10.0, "__total__": 18.0, ...} ``` --- ## License MIT https://aakarsh2007-oceanus-ai.hf.spacePlease