final: polish README (RLVR specs) and cleanup scratch scripts
Browse filesFiles changed (2)
- README.md+19-6
- verify_repetition.pyDeleted-39
5 unmodified lines67891011121314151611 unmodified lines282930313233343536373839102 unmodified lines1421431441451461471485 unmodified linesapp_port: 7860base_path: /dashboard/---# PolicyEvolverEnv**PolicyEvolverEnv** is an OpenEnv-compliant reinforcement learning environment designed for the Meta × PyTorch × Scaler Hackathon.## Environment Description & MotivationPolicyEvolverEnv is a real-world governance sandbox where an AI agent learns to **design and evolve governance policies** through meta-reasoning over real-world operational data. In modern platforms (social media, enterprise HR, e-commerce), static policies quickly become outdated or vaguely applied, leading to inconsistent enforcement, false-positive moderation, and unrecognized fraud.This environment simulates this challenge by presenting the agent with a corpus of operational data alongside an existing policy framework. The agent's goal is to analyze the outcomes, identify systemic flaws or ambiguities, and act directly on the policies to optimize governance outcomes. This directly tackles live production problems faced by platforms like Meta.11 unmodified lines### 2. The Gradio "Judge Console": How it WorksThe dashboard we built (`server/app.py`) is the human-readable window into this environment. It’s designed as a **Command & Control** center for a "Policy Judge."#### 📈 The Left Panel: Scenario Metrics* **Environment Best Score**: This tracks the highest score achieved in this session. It represents the "Gold Standard" the agent is aiming for.* **Remaining Execution Steps**: Each "Episode" has a limit (5 steps). The agent must improve the policy within this budget. This forces **Strategic Efficiency**.* **Latest Strategic Reward**: Every time you click "Execute," the Grader (`server/grader.py`) analyzes your proposal. If it’s vague, you get a low reward (0.1–0.3). If it’s specific and measurable, you get a high reward (0.8–0.9).#### 📋 The Right Panel: Observations* **Data Corpus (Tabular View)**: These are the "Facts on the Ground." These are real-world incidents (e.g., a post flagged for 'harassment' vs one that wasn't).* **Active Framework**: This shows the current "Code of Law."* **The Workflow**: Your goal is to find an incident in the Corpus that doesn't fit correctly into the Framework, then use the bottom console to fix it.102 unmodified lines## 📈 Strategic Reward Evolution & RLVRPolicyEvolverEnv serves as the **Strategic Sandbox** for the **Reinforcement Finetuning (RLVR)** stage of the modern LLM training pipeline. Unlike static evaluation, this environment enables agents to refine their strategies iteratively based on high-quality, verifiable feedback.### 🧠 How It Works: The Iterative Learning Process1. **Refinement Hub**: The baseline agent tracks its previous rewards and actions through the observation's metadata (`info`).5 unmodified lines6789101112131415161718192021222324252627282911 unmodified lines414243444546474849505152102 unmodified lines1551561571581591601615 unmodified linesapp_port: 7860base_path: /dashboard/---# PolicyEvolverEnv — Multi-Modal Strategic Governance Sandbox**PolicyEvolverEnv** is an OpenEnv-compliant reinforcement learning environment designed for the **Meta × PyTorch × Scaler Hackathon**. It serves as a production-grade benchmark for **Reinforcement Learning from Verifiable Rewards (RLVR)**.---### 🧪 Advanced Reward Shaping (RLVR Integration)Unlike standard environments with static rewards, **PolicyEvolverEnv v2.0** implements a sophisticated, deterministic grading engine designed to harden LLM strategic reasoning:* **Tiered CoT Bonus**: Rewards analytical reasoning (up to +0.20) based on keyword density and length.* **Clarity Coherence**: Penalizes "vague" or "subjective" (e.g., *maybe, perhaps*) policy definitions in Easy tasks.* **Tradeoff Realism**: Detects and caps "hallucinated" outcomes in Hard tasks (e.g., claiming to simultaneously maximize fraud-prevention and revenue).* **Step-Delta Shaping**: Provides an `improvement_bonus` for iterative actions that significantly outperform the episode's best score.* **Anti-Repetition Penalty**: Encounters a -0.30 penalty for exact repeated actions, forcing the agent toward continuous evolution.---## Environment Description & MotivationPolicyEvolverEnv is a real-world governance sandbox where an AI agent learns to **design and evolve governance policies** through meta-reasoning over real-world operational data. In modern platforms (social media, enterprise HR, e-commerce), static policies quickly become outdated or vaguely applied, leading to inconsistent enforcement, false-positive moderation, and unrecognized fraud.This environment simulates this challenge by presenting the agent with a corpus of operational data alongside an existing policy framework. The agent's goal is to analyze the outcomes, identify systemic flaws or ambiguities, and act directly on the policies to optimize governance outcomes. This directly tackles live production problems faced by platforms like Meta.11 unmodified lines### 2. The Gradio "Judge Console": How it WorksThe dashboard we built (`server/app.py`) is the human-readable window into this environment. It’s designed as a **Command & Control** center for a "Policy Judge."#### The Left Panel: Scenario Metrics* **Environment Best Score**: This tracks the highest score achieved in this session. It represents the "Gold Standard" the agent is aiming for.* **Remaining Execution Steps**: Each "Episode" has a limit (5 steps). The agent must improve the policy within this budget. This forces **Strategic Efficiency**.* **Latest Strategic Reward**: Every time you click "Execute," the Grader (`server/grader.py`) analyzes your proposal. If it’s vague, you get a low reward (0.1–0.3). If it’s specific and measurable, you get a high reward (0.8–0.9).#### The Right Panel: Observations* **Data Corpus (Tabular View)**: These are the "Facts on the Ground." These are real-world incidents (e.g., a post flagged for 'harassment' vs one that wasn't).* **Active Framework**: This shows the current "Code of Law."* **The Workflow**: Your goal is to find an incident in the Corpus that doesn't fit correctly into the Framework, then use the bottom console to fix it.102 unmodified lines## 📈 Strategic Reward Evolution & RLVRPolicyEvolverEnv serves as the **Strategic Sandbox** for the **Reinforcement Finetuning (RLVR)** stage of the modern LLM training pipeline. Unlike static evaluation, this environment enables agents to refine their strategies iteratively based on high-quality, verifiable feedback.### 🧠 How It Works: The Iterative Learning Process1. **Refinement Hub**: The baseline agent tracks its previous rewards and actions through the observation's metadata (`info`).
123456789101112131415161718192021222324252627282930313233343536373839import asyncioimport osimport sys
# Add current directory to path so we can import everything correctlysys.path.insert(0, os.getcwd())
from server.environment import PolicyEvolverEnvironmentfrom models import Action
async def verify_repetition(): env = PolicyEvolverEnvironment() # Reset to start fresh obs1 = env.reset(task_id="task_easy") same_action = { "action_type": "propose_clarification", "ambiguous_term": "appropriate", "suggested_definition": "Behavior is defined as appropriate when it specifically follows the community guidelines, meaning it does not include excessive slurs and meets the 5% threshold for verified user reports.", "justification": "The current policy leads to inconsistent and subjective moderation because it is unclear and varies between interpreters.", "think": "" } # First step print("\n--- Step 1 ---") res1 = env.step(same_action) print(f"Step 1 Reward: {res1.reward}") # Second step with identical action print("\n--- Step 2 (Repeat) ---") res2 = env.step(same_action) print(f"Step 2 Reward: {res2.reward}") # Assert assert res2.reward < res1.reward, f"Repeated action should score lower! res2={res2.reward}, res1={res1.reward}" print("\n✅ Anti-repetition test passed! Reward was penalized as expected.")
if __name__ == "__main__": asyncio.run(verify_repetition())README.md+19-6
verify_repetition.pyDeleted-39