CoolFace
Apppublic

shivamtech9395/maths_reasoning_env

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
App README

๐Ÿงฎ Math Reasoning Environment

An OpenEnv-compatible RL environment for training LLMs on math reasoning tasks.

5 Graded Task Types

TaskDescriptionGrader
arithmeticBasic +, -, *, /โœ…
algebraSolve linear equationsโœ…
word_problemsMulti-step word problemsโœ…
number_theoryGCD, LCM problemsโœ…
geometryArea, perimeter, volumeโœ…

Quick Start

bash
# Run server locally
uvicorn server.app:app --host 0.0.0.0 --port 8000

# Test inference
python inference.py

API Endpoints

EndpointMethodDescription
/healthGETHealth check
/resetPOSTStart new episode
/stepPOSTSubmit answer
/stateGETGet current state
/tasksGETList all tasks

Client Usage

python
from client import MathReasoningEnvClient
from models import MathAction

with MathReasoningEnvClient("http://localhost:8000") as client:
    obs = client.reset(task_type="algebra")
    print(obs.problem)  # "Solve for x: 3x + 5 = 14"
    
    result = client.step(MathAction(answer="3", reasoning="3*3+5=14"))
    print(result.feedback)  # โœ… Correct!
    print(result.score)     # 1.1 (bonus for reasoning)

Reward Shaping

  • โ€”โœ… Correct answer: +1.0
  • โ€”โŒ Wrong answer: -0.2
  • โ€”๐Ÿ’ก Chain-of-thought reasoning bonus: +0.1

Docker

bash
docker build -f server/Dockerfile -t math-reasoning-env .
docker run -p 7860:7860 math-reasoning-env