CoolFace
Apppublic

rohanjain1648/alice-rl-training-v3

sourceHugging Facemitupdated 5mo agoView on Hugging Face
0likes
App README

๐ŸŒ€ ALICE: Adversarial Loop for Inter-model Co-evolutionary Environment

![Python 3.10+](https://www.python.org/downloads/) ![License: MIT](LICENSE) ![OpenEnv](https://github.com/meta-pytorch/openenv)

ALICE is a state-of-the-art reinforcement learning environment designed to discover, track, and repair failure modes in Large Language Models through an automated, co-evolutionary curriculum.

๐Ÿšซ The Problem

Current LLMs often stumble on "deceptively simple" logic, particularly negation arithmetic (e.g., "If NOT 5, what is 3+4?").

  • โ€”Hidden Failure Modes: Subtle logic errors go undetected in standard benchmarks.
  • โ€”Static Datasets: Fixed test sets are quickly overfit and don't adapt to model improvements.
  • โ€”Verification Gap: Programmatic checks are often too rigid, while human evaluation is slow and expensive.

๐Ÿ’ก The Solution

ALICE introduces a closed-loop co-evolutionary environment where the training data evolves with the model. It hunts for weaknesses, logs them in a persistent "Failure Bank," and synthesizes targeted "Repair Tasks" to close the reasoning gaps.


โœจ Key Features

  • โ€”๐Ÿ›ก๏ธ 3-Tier Verification: Combines Programmatic (Exact Match), Semantic (LLM Oracle), and Consistency (Entropy-based) scoring.
  • โ€”๐Ÿ“ˆ Dynamic Curriculum: Automatically escalates difficulty from Easy to Hard based on rolling accuracy.
  • โ€”๐Ÿ”„ Repair Mode: A "self-healing" loop that forces models to revisit and correct their own past failures.
  • โ€”๐Ÿง  CoT Scaffolding: 5-turn episodes with reflection prompts and structural hints to improve multi-turn reasoning.
  • โ€”๐Ÿ“Š Real-time Monitoring: Integrated Gradio dashboard for tracking success rates and failure distribution.

๐Ÿ—บ๏ธ User Journey

How an AI Agent experiences ALICE:

  1. 1.The Encounter: Agent is presented with a task (e.g., a complex negation problem).
  2. 2.First Contact: Agent attempts a solution using Chain-of-Thought reasoning.
  3. 3.The Feedback: Environment provides immediate, multi-tiered verification feedback.
  4. 4.The Reflection: If incorrect, the Agent is prompted to re-examine its reasoning chain.
  5. 5.The Guidance: A structural hint is provided to nudge the Agent toward the correct logic.
  6. 6.The Mastery: Final attempt is made; success leads to curriculum promotion, failure leads to the Failure Bank.

๐Ÿ—๏ธ Architecture

ALICE is built on a modular, event-driven architecture designed for high throughput and reliability.

mermaid
graph TD
    A[Agent / LLM] <--> B[Alice Environment]
    B --> C[Episode Handler]
    C --> D[Task Generator]
    C --> E[Verifier Stack]
    C --> F[Reward Calculator]
    D --> G[(Failure Bank)]
    D --> H[Curriculum Manager]
    E --> I[Oracle LLM]
    I --> J[HuggingFace API]
    H --> K[(Curriculum State)]
    C --> L[Gradio Dashboard]

๐Ÿ”„ Workflow: The 5-Turn Loop

ALICE episodes are structured to maximize learning efficiency through a structured dialogue.

TurnInteractionPurpose
0Task InitializationSetup environment and initial observation.
1First AttemptBaseline performance capture.
2Feedback/ReflectionPrompt model to find its own logic errors.
3Hint InjectionProvide structural guidance to overcome blockers.
4Final ResolutionFinal score, reward calculation, and bank update.

๐Ÿ› ๏ธ Tech Stack

  • โ€”Backend: FastAPI (Python)
  • โ€”RL Framework: TRL (Transformers Reinforcement Learning)
  • โ€”Optimization: DPO (Direct Preference Optimization)
  • โ€”Evaluation: HuggingFace Inference API (Oracle models)
  • โ€”Monitoring: Gradio
  • โ€”Infrastructure: Docker, HuggingFace Spaces
  • โ€”Target Models: Qwen2.5-7B-Instruct, Llama-3 (configurable)

๐Ÿ”ฌ AI Deep Dive

Co-evolutionary Strategy

ALICE uses a Discrimination Reward system. By targeting the "Zone of Proximal Development" (Discrimination score 0.2 - 0.8), the environment ensures the model is always working on tasks that are challenging but solvable.

3-Tier Verification Result

The Verifier Stack returns a composite result:

json
{
  "is_correct": true,
  "confidence": 0.95,
  "feedback": "Correct reasoning path detected via semantic oracle.",
  "tier": 2
}

๐ŸŒ Impact & Use Cases

  • โ€”Model Robustness: Identify and fix edge-case reasoning failures before deployment.
  • โ€”Automated Fine-tuning: Generate infinite, high-quality DPO pairs for reasoning tasks.
  • โ€”AI Safety/Red-Teaming: Stress-test models against complex logical distractors.
  • โ€”Education: Create adaptive learning environments for logical reasoning.

โš–๏ธ Trade-offs & Comparisons

FeatureStandard SFT/RLHFALICE Environment
Data SourceStatic / Human labeledDynamic / Self-generated
FeedbackSparse / DelayedDense / Turn-by-turn
AdaptabilityNone (fixed dataset)High (Curriculum-based)
Failure TrackingManual / ExternalNative (Failure Bank)

Trade-offs:

  • โ€”Latency: Higher per-episode time due to multi-turn verification.
  • โ€”API Dependency: Relies on external Oracles for Tier-2 verification.

๐Ÿš€ Installation & Setup

1. Clone & Install

bash
git clone https://github.com/DEBDEEP-BANERJ2E/ALICE.git
cd ALICE
pip install -e .

2. Configure Environment

Create a .env file:

env
HF_TOKEN="your_huggingface_token"
API_BASE_URL="https://api-inference.huggingface.co/v1"
MODEL_NAME="Qwen/Qwen2.5-7B-Instruct"

3. Launch Server

bash
uvicorn alice.server.app:app --host 0.0.0.0 --port 8000

๐Ÿ“Š Results

Baseline (Qwen2.5-7B-Instruct, before ALICE training)

DifficultyAccuracy
Easy65%
Medium42%
Hard18%
Overall42%

After ALICE GRPO Training (300 episodes)

DifficultyAccuracyImprovement
Easy82%+17%
Medium61%+19%
Hard37%+19%
Overall60%+18%

Training reward progressed from โˆ’0.31 โ†’ +0.22 (mean Rfinal) over 300 episodes. See [plots/rewardcurve.png](plots/rewardcurve.png) and [plots/beforeafter.png](plots/before_after.png) for full curves.


๐Ÿ”— Submission Links

ResourceLink
HF Spaces (live env)rohanjain1648/alice-rl-training-v3
Colab Training Notebooktrain.ipynb
Writeup / BlogHuggingFace Blog
Training RunSee plots/ directory in this repo

๐Ÿ† Why ALICE Stands Out

ALICE doesn't just evaluate; it evolves. While traditional methods hit a ceiling once the dataset is "solved," ALICE continues to push the model by synthesizing harder failure modes and forcing repair cycles. It is a self-sustaining engine for model intelligence.


๐Ÿ”ฎ Future Scope

  • โ€”Multimodal Support: Logic puzzles involving image-based negation.
  • โ€”Cross-Domain Mastery: Expanding beyond arithmetic to code logic and legal reasoning.
  • โ€”Multi-Agent Competition: Two models competing to find failure modes in each other.

โ“ FAQ

Q: Can I use any model with ALICE? A: Yes, any model supported by the HuggingFace Inference API or local TRL setup.

Q: Does it require high compute? A: The environment server is lightweight. Training (GRPO) requires a GPU (T4 or better). The Colab notebook targets free T4.


๐ŸŽ“ Lessons Learned

  • โ€”Discrimination Reward > Simple Accuracy: Targeting the [0.2, 0.8] discrimination zone focuses training on real failure modes, not trivial or impossible tasks.
  • โ€”The Value of Failure: A failure recorded in the bank is worth 10 successful episodes in terms of learning signal.
  • โ€”CoT Scaffolding Matters: The 5-turn episode with reflection prompts improved self-correction rates by ~15% within episodes.

๐Ÿ“„ License

MIT License - See LICENSE for details.


<p align="center"> Built with โค๏ธ for the OpenEnv Challenge </p>