CoolFace
Apppublic

sourcandy43/osworld1

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

OsWorld Data Cleaning Environment

A benchmark environment for training and evaluating LLM agents on multi-step data engineering and cleaning tasks.

๐Ÿง  Architecture Overview

The OsWorld Data Cleaning Environment models data cleaning as a Markov Decision Process (MDP).

  • โ€”State Representation: Workspace files (CSV, JSON, SQL, HTML, logs) and task description
  • โ€”Action Space: Structured actions (inspection, Python execution, utilities)
  • โ€”Semantic Grading: Multi-component ฮฆ (Phi) scoring system
  • โ€”Reward System: Delta-based shaping with penalties and efficiency-scaled terminal rewards

๐Ÿš€ Quick Start

1. Prerequisites

bash
pip install uv

2. Installation

bash
uv sync

3. Environment Configuration

Create a .env file:

env
HF_TOKEN=your_huggingface_token
MODEL_NAME=Qwen/Qwen2.5-72B-Instruct
API_BASE_URL=https://router.huggingface.co/v1

# Optional fallback
OPENROUTER_API_KEY=your_key

๐Ÿ“‹ Task Scenarios

The environment contains 15 task variants across 3 difficulty tiers.

Each reset() returns a deterministic task instance, cycling through predefined variants.

During benchmarking (inference.py), only a single episode is executed per run to ensure strict evaluation consistency.

๐ŸŒŸ Easy Tier (4 Variants)

  • โ€”Duplicate Removal Standardize columns (id, name) and remove duplicates
  • โ€”Format Normalization Strip whitespace and normalize strings to lowercase
  • โ€”Type Coercion Convert semantic strings into correct types
  • โ€”Column Rename Pure schema alignment

โšก Medium Tier (7 Variants)

  • โ€”Missing value imputation
  • โ€”Schema repair
  • โ€”Constraint enforcement
  • โ€”Multi-file joins
  • โ€”JSON normalization
  • โ€”SQL extraction
  • โ€”HTML scraping

๐Ÿ”ฅ Hard Tier (4 Variants)

  • โ€”Corrupted pipeline recovery
  • โ€”Adversarial data fixing
  • โ€”Cascading multi-file transformations
  • โ€”Log parsing

๐Ÿ” Interaction Loop

Each episode follows:

  1. 1.Agent receives observation (files + task)
  2. 2.Agent emits an action
  3. 3.Environment executes action in sandbox
  4. 4.Returns updated state, reward, and score

Loop continues until termination or max steps.


๐Ÿ“Š Evaluation System

ฮฆ Score (Semantic Grading)

$$ \Phi = 0.4 \cdot content + 0.2 \cdot schema + 0.2 \cdot validity + 0.2 \cdot constraints - penalty $$

  • โ€”All components normalized to [0, 1]
  • โ€”Final ฮฆ is clamped to [0, 1]
  • โ€”Task is solved when ฮฆ = 1.0

Component Breakdown

Content (40%) F1-based row matching (precision + recall)

Schema (20%) Column overlap + ordering consistency (capped โ‰ค 1.0)

Validity (20%)

  • โ€”Null handling
  • โ€”Type correctness
  • โ€”Format consistency

Constraints (20%)

  • โ€”Uniqueness
  • โ€”Value ranges
  • โ€”Task-specific rules

Anti-Cheat Penalty

$$ penalty = \min\left(0.3,\; 0.1 \cdot \frac{\max(0, n{agent} - n{expected})}{n_{expected}}\right) $$

Prevents:

  • โ€”Row inflation
  • โ€”Duplicate exploitation
  • โ€”Partial-output hacks

๐ŸŽฏ Reward Function

The reward at each step is:

R = step_penalty
  + (new_score - old_score)
  + regression_penalty (if score drops)
  + error_penalty
  + destructive_penalty
  + terminal_bonus (if done)

๐Ÿ”ฅ Terminal Reward Scaling

When the episode ends, a terminal bonus is applied:

terminal_bonus = ฮฑ * final_score * efficiency_factor

Where:

  • โ€”final_score = ฮฆ (final semantic score)
  • โ€”ฮฑ = terminal scaling constant (e.g., 5.0)

โšก Efficiency Factor

Encourages fewer steps:

efficiency_factor = max(0.3, 1 - steps_used / max_steps)

Properties:

  • โ€”Faster solutions โ†’ higher reward
  • โ€”Slow agents are penalized but not zeroed
  • โ€”Minimum floor prevents reward collapse

๐Ÿง  Reward Properties

  • โ€”Dense feedback โ†’ incremental progress rewarded
  • โ€”Regression penalty โ†’ discourages breaking correct states
  • โ€”Execution penalties โ†’ punishes unsafe/destructive actions
  • โ€”Efficiency scaling โ†’ promotes optimal planning

๐Ÿค– Agent Constraints

  • โ€”Agent only sees provided files
  • โ€”Tasks are defined in current_task
  • โ€”Execution occurs in sandboxed Python
  • โ€”Available libraries: pandas, io, etc.
  • โ€”Agent primarily uses execute_python, with optional inspection steps

๐Ÿš€ Usage

Benchmark Mode

bash
uv run inference.py

Outputs strict logs:

[START]
[STEP]
[END]

Evaluation

bash
uv run python eval.py

Run Server

bash
uv run uvicorn server.app:app --host 0.0.0.0 --port 8000

๐Ÿ“‚ Project Structure

OsWorld/
โ”œโ”€โ”€ server/
โ”‚   โ”œโ”€โ”€ tasks.py
โ”‚   โ”œโ”€โ”€ graders.py
โ”‚   โ””โ”€โ”€ OsWorld_environment.py
โ”œโ”€โ”€ models.py
โ”œโ”€โ”€ client.py
โ”œโ”€โ”€ inference.py
โ””โ”€โ”€ openenv.yaml

๐Ÿง  Design Philosophy

  • โ€”Semantic correctness over exact matching
  • โ€”Robustness against reward hacking
  • โ€”Real-world data complexity
  • โ€”Multi-step reasoning evaluation
  • โ€”Efficiency-aware agent behavior

Built for OpenEnv Hackathon | Designed for serious agent evaluation