jithendra-10/DC_env

0

stars

11

commits

Python

primary language

Apr 10, 2026

updated

README


title: DataClean-Env emoji: 🧹 colorFrom: blue colorTo: indigo sdk: docker app_file: server.py pinned: false

DataClean-Env

An OpenEnv-compliant reinforcement learning environment for data cleaning agents.

DataClean-Env challenges LLM agents to clean realistic tabular datasets β€” null imputation, dtype correction, outlier clipping, deduplication, and more. Every episode is reproducible via a seeded generator. Every grader is a deterministic pandas assertion.

OpenEnv Compliant HF Spaces Python 3.11 Docker


Quick Start

export API_BASE_URL=https://router.huggingface.co/v1
export MODEL_NAME=meta-llama/Meta-Llama-3-70B-Instruct
export HF_TOKEN=hf_...

pip install -r requirements.txt
python inference.py

inference.py uses the OpenAI client pointed at the HuggingFace router. Runs all 3 tasks, completes in under 20 minutes, saves scores to baseline_scores.json.


Overview & Motivation

Data cleaning consumes 60–80% of a data scientist's working time. It is a universal, expensive, well-understood problem β€” but no existing OpenEnv environment tests it.

DataClean-Env fills that gap:

  • 3 tasks β€” easy β†’ medium β†’ hard
  • 7 action types covering the full cleaning workflow
  • Rich partial rewards β€” signal on every step, not just at the end
  • Provenance tracking β€” immutable ops log that must replay cleanly on raw data (+0.05 bonus)
  • Confidence calibration β€” rewards calibrated agents, penalises overconfidence
  • Gradio web UI at /web for live judge demos

Section 1 β€” Action & Observation Spaces

Actions

FieldTypeDescription
action_typestringOne of 7 operations
columnstring | nullTarget column (required for most ops)
paramsobjectOperation-specific parameters
confidencefloat 0–1Agent's self-reported confidence β€” calibration is rewarded
Action typeKey paramsEffect
fill_nullsstrategy: mean|median|mode|constant|ffillImpute missing values
remove_duplicatessubset (optional)Drop duplicate rows
fix_dtypetarget_dtype: int64|float64|str|datetime64Cast column to correct type
clip_outliersmethod: iqr|zscore|percentileClip extreme values
rename_columnnew_nameRename to canonical name
drop_columnβ€”Drop irrelevant column
doneβ€”Signal cleaning complete

Observation

FieldTypeDescription
episode_idstringUnique episode UUID
stepintCurrent step
budget_remainingintSteps left
n_rows / n_colsintDataframe shape
duplicate_ratefloatFraction of duplicate rows
columnslist[ColumnProfile]Per-column stats + corruption flags
ops_loglistAll operations applied so far
quality_scoresdictnull_score, type_score, outlier_score, dup_score, overall
last_action_resultstringFeedback on previous action

Corruption flags: heavy_nulls, has_nulls, heavy_outliers, type_chaos


Section 2 β€” Tasks & Difficulty

Task 1 β€” Employee Dataset Β· Easy Β· 15 steps

300 rows. Challenges: 22% null ages, salary outliers, years_at_company stored as string, 30 duplicates.

Grader: null_rate ≀ 0.01, numeric dtypes, IQR-clean salary, no duplicates β†’ score 0.0–1.0

Task 2 β€” E-Commerce Orders Β· Medium Β· 18 steps

500 rows. Challenges: 28% null quantities, 15% null ratings, amount outliers, irrelevant internal_hash column to drop, 40 duplicates.

Grader: all nulls ≀ 1%, numeric dtypes, outliers clipped, internal_hash absent β†’ score 0.0–1.0

Task 3 β€” Healthcare Records Β· Hard Β· 20 steps

800 rows. Mixed per-column corruption β€” agent must diagnose each independently:

ColumnIssue
patient_age25% nulls
weight_kgimpossible outliers (βˆ’10 to 999 kg)
glucose_mgdltype_chaos (floats + strings mixed)
cholesterol12% nulls + outliers
systolic_bp8% nulls
admin_notesirrelevant β€” drop it

Grader: weighted null + dtype + outlier + dup scores β†’ score 0.0–1.0


Section 3 β€” Reward Function

Base: βˆ’0.01 per step (efficiency pressure)

EventReward
Fill nulls (dirty column)+0.10 Γ— (1 βˆ’ remaining_null_rate)
Remove duplicates+0.12
Fix dtype+0.10
Clip outliers+0.08 Γ— (1 + std_reduction)
Drop irrelevant column+0.04
Action on clean columnβˆ’0.05
Done (quality β‰₯ 0.80)+0.15
Done (quality < 0.80)+0.15 Γ— quality
Provenance bonus+0.05 if ops log is fully reproducible
Confidence bonus+0.04 high-confidence correct action
Confidence penaltyβˆ’0.06 high-confidence wrong action

Section 4 β€” Setup & Usage

Required environment variables

VariableDefaultDescription
API_BASE_URLhttps://router.huggingface.co/v1LLM API endpoint
MODEL_NAMEmeta-llama/Meta-Llama-3-70B-InstructModel identifier
HF_TOKENβ€”HuggingFace API key (huggingface.co/settings/tokens)

Run inference script

export API_BASE_URL=https://router.huggingface.co/v1
export MODEL_NAME=meta-llama/Meta-Llama-3-70B-Instruct
export HF_TOKEN=hf_...

python inference.py

Run server

uvicorn server:app --host 0.0.0.0 --port 7860
# Gradio UI at http://localhost:7860/web

Run with Docker

docker build -t dataclean-env .
docker run -p 7860:7860 \
  -e API_BASE_URL=https://router.huggingface.co/v1 \
  -e MODEL_NAME=meta-llama/Meta-Llama-3-70B-Instruct \
  -e HF_TOKEN=hf_... \
  dataclean-env

OpenEnv validation

openenv validate --url https://huggingface.co/spaces/jithendra/dataclean-env

Section 5 β€” Baseline Scores

Seed: 42 | Script: python inference.py

Heuristic agent (no LLM β€” deterministic lower bound)

TaskScoreRewardStepsProvenance
task_10.91670.47003βœ“
task_20.95000.78995βœ“
task_30.95000.99007βœ“

LLM agent β€” inference.py

Model: meta-llama/Meta-Llama-3-70B-Instruct Β· Provider: HuggingFace router Β· Client: OpenAI

TaskScoreRewardStepsProvenance
task_1TBDTBDTBDTBD
task_2TBDTBDTBDTBD
task_3TBDTBDTBDTBD

Run python inference.py with your HF_TOKEN to reproduce.


Nemotron-Compatible Wrapper (Phase 2)

from baseline.agent import NemotronAgentWrapper

agent = NemotronAgentWrapper(
    server_url="https://huggingface.co/spaces/jithendra/dataclean-env"
)
obs    = agent.reset(task_id="task_1", seed=42)
action = agent.step(obs)
score  = agent.score()
agent.close()

Section 6 β€” Reinforcement Learning (GRPO)

DataClean-Env is not just to evaluate existing models β€” it is a fully functional RL Training Environment. We provide training_script.py to demonstrate how AI researchers can securely hook our mathematically dense reward signals into the HuggingFace TRL library to fine-tune Small Language Models (like Qwen2.5) from scratch using Group Relative Policy Optimization (GRPO).

# Optional RL dependencies (requires large GPU for actual training)
pip install trl transformers torch datasets accelerate

# Run the training loop demonstration
python training_script.py --dry-run

Section 7 β€” Supervised Autonomy & Web UI

DataClean-Env features a professional Gradio interface with two distinct modes:

  1. Manual Inspector Mode: Allows researchers to iteratively debug and test the mathematical bounds of the environment API by manually issuing Python dictionary payloads to the server via sliders and dropdowns.
  2. Agent Copilot (Sandbox): A complete Supervised Autonomy arena. Judges can select any HuggingFace model (e.g., Llama-3-70B), provide their token, and physically watch the LLM and Environment communicate autonomously within a live Chat UI until a perfect score is reached.
  3. Custom Datasets: The Copilot Sandbox includes a file dropzone. Judges can upload their own .csv files bypassing the TASK_REGISTRY, proving the environment scales seamlessly to custom, real-world data outside of the hackathon's static tests.

HuggingFace Space Setup

  1. Create Space β†’ SDK: Docker, tag: openenv
  2. Push all repo files
  3. Add Space secrets: HF_TOKEN, API_BASE_URL, MODEL_NAME
  4. Run: openenv validate --url https://huggingface.co/spaces/Jxth/dataclean-env

License

MIT License. Built for the Meta-Scalar OpenEnv Hackathon.

Contributors

jithendra-10

11 commits

jithendra-10/DC_env

0

stars

11

commits

Python

primary language

Apr 10, 2026

updated

README


title: DataClean-Env emoji: 🧹 colorFrom: blue colorTo: indigo sdk: docker app_file: server.py pinned: false

DataClean-Env

An OpenEnv-compliant reinforcement learning environment for data cleaning agents.

DataClean-Env challenges LLM agents to clean realistic tabular datasets β€” null imputation, dtype correction, outlier clipping, deduplication, and more. Every episode is reproducible via a seeded generator. Every grader is a deterministic pandas assertion.

OpenEnv Compliant HF Spaces Python 3.11 Docker


Quick Start

export API_BASE_URL=https://router.huggingface.co/v1
export MODEL_NAME=meta-llama/Meta-Llama-3-70B-Instruct
export HF_TOKEN=hf_...

pip install -r requirements.txt
python inference.py

inference.py uses the OpenAI client pointed at the HuggingFace router. Runs all 3 tasks, completes in under 20 minutes, saves scores to baseline_scores.json.


Overview & Motivation

Data cleaning consumes 60–80% of a data scientist's working time. It is a universal, expensive, well-understood problem β€” but no existing OpenEnv environment tests it.

DataClean-Env fills that gap:

  • 3 tasks β€” easy β†’ medium β†’ hard
  • 7 action types covering the full cleaning workflow
  • Rich partial rewards β€” signal on every step, not just at the end
  • Provenance tracking β€” immutable ops log that must replay cleanly on raw data (+0.05 bonus)
  • Confidence calibration β€” rewards calibrated agents, penalises overconfidence
  • Gradio web UI at /web for live judge demos

Section 1 β€” Action & Observation Spaces

Actions

FieldTypeDescription
action_typestringOne of 7 operations
columnstring | nullTarget column (required for most ops)
paramsobjectOperation-specific parameters
confidencefloat 0–1Agent's self-reported confidence β€” calibration is rewarded
Action typeKey paramsEffect
fill_nullsstrategy: mean|median|mode|constant|ffillImpute missing values
remove_duplicatessubset (optional)Drop duplicate rows
fix_dtypetarget_dtype: int64|float64|str|datetime64Cast column to correct type
clip_outliersmethod: iqr|zscore|percentileClip extreme values
rename_columnnew_nameRename to canonical name
drop_columnβ€”Drop irrelevant column
doneβ€”Signal cleaning complete

Observation

FieldTypeDescription
episode_idstringUnique episode UUID
stepintCurrent step
budget_remainingintSteps left
n_rows / n_colsintDataframe shape
duplicate_ratefloatFraction of duplicate rows
columnslist[ColumnProfile]Per-column stats + corruption flags
ops_loglistAll operations applied so far
quality_scoresdictnull_score, type_score, outlier_score, dup_score, overall
last_action_resultstringFeedback on previous action

Corruption flags: heavy_nulls, has_nulls, heavy_outliers, type_chaos


Section 2 β€” Tasks & Difficulty

Task 1 β€” Employee Dataset Β· Easy Β· 15 steps

300 rows. Challenges: 22% null ages, salary outliers, years_at_company stored as string, 30 duplicates.

Grader: null_rate ≀ 0.01, numeric dtypes, IQR-clean salary, no duplicates β†’ score 0.0–1.0

Task 2 β€” E-Commerce Orders Β· Medium Β· 18 steps

500 rows. Challenges: 28% null quantities, 15% null ratings, amount outliers, irrelevant internal_hash column to drop, 40 duplicates.

Grader: all nulls ≀ 1%, numeric dtypes, outliers clipped, internal_hash absent β†’ score 0.0–1.0

Task 3 β€” Healthcare Records Β· Hard Β· 20 steps

800 rows. Mixed per-column corruption β€” agent must diagnose each independently:

ColumnIssue
patient_age25% nulls
weight_kgimpossible outliers (βˆ’10 to 999 kg)
glucose_mgdltype_chaos (floats + strings mixed)
cholesterol12% nulls + outliers
systolic_bp8% nulls
admin_notesirrelevant β€” drop it

Grader: weighted null + dtype + outlier + dup scores β†’ score 0.0–1.0


Section 3 β€” Reward Function

Base: βˆ’0.01 per step (efficiency pressure)

EventReward
Fill nulls (dirty column)+0.10 Γ— (1 βˆ’ remaining_null_rate)
Remove duplicates+0.12
Fix dtype+0.10
Clip outliers+0.08 Γ— (1 + std_reduction)
Drop irrelevant column+0.04
Action on clean columnβˆ’0.05
Done (quality β‰₯ 0.80)+0.15
Done (quality < 0.80)+0.15 Γ— quality
Provenance bonus+0.05 if ops log is fully reproducible
Confidence bonus+0.04 high-confidence correct action
Confidence penaltyβˆ’0.06 high-confidence wrong action

Section 4 β€” Setup & Usage

Required environment variables

VariableDefaultDescription
API_BASE_URLhttps://router.huggingface.co/v1LLM API endpoint
MODEL_NAMEmeta-llama/Meta-Llama-3-70B-InstructModel identifier
HF_TOKENβ€”HuggingFace API key (huggingface.co/settings/tokens)

Run inference script

export API_BASE_URL=https://router.huggingface.co/v1
export MODEL_NAME=meta-llama/Meta-Llama-3-70B-Instruct
export HF_TOKEN=hf_...

python inference.py

Run server

uvicorn server:app --host 0.0.0.0 --port 7860
# Gradio UI at http://localhost:7860/web

Run with Docker

docker build -t dataclean-env .
docker run -p 7860:7860 \
  -e API_BASE_URL=https://router.huggingface.co/v1 \
  -e MODEL_NAME=meta-llama/Meta-Llama-3-70B-Instruct \
  -e HF_TOKEN=hf_... \
  dataclean-env

OpenEnv validation

openenv validate --url https://huggingface.co/spaces/jithendra/dataclean-env

Section 5 β€” Baseline Scores

Seed: 42 | Script: python inference.py

Heuristic agent (no LLM β€” deterministic lower bound)

TaskScoreRewardStepsProvenance
task_10.91670.47003βœ“
task_20.95000.78995βœ“
task_30.95000.99007βœ“

LLM agent β€” inference.py

Model: meta-llama/Meta-Llama-3-70B-Instruct Β· Provider: HuggingFace router Β· Client: OpenAI

TaskScoreRewardStepsProvenance
task_1TBDTBDTBDTBD
task_2TBDTBDTBDTBD
task_3TBDTBDTBDTBD

Run python inference.py with your HF_TOKEN to reproduce.


Nemotron-Compatible Wrapper (Phase 2)

from baseline.agent import NemotronAgentWrapper

agent = NemotronAgentWrapper(
    server_url="https://huggingface.co/spaces/jithendra/dataclean-env"
)
obs    = agent.reset(task_id="task_1", seed=42)
action = agent.step(obs)
score  = agent.score()
agent.close()

Section 6 β€” Reinforcement Learning (GRPO)

DataClean-Env is not just to evaluate existing models β€” it is a fully functional RL Training Environment. We provide training_script.py to demonstrate how AI researchers can securely hook our mathematically dense reward signals into the HuggingFace TRL library to fine-tune Small Language Models (like Qwen2.5) from scratch using Group Relative Policy Optimization (GRPO).

# Optional RL dependencies (requires large GPU for actual training)
pip install trl transformers torch datasets accelerate

# Run the training loop demonstration
python training_script.py --dry-run

Section 7 β€” Supervised Autonomy & Web UI

DataClean-Env features a professional Gradio interface with two distinct modes:

  1. Manual Inspector Mode: Allows researchers to iteratively debug and test the mathematical bounds of the environment API by manually issuing Python dictionary payloads to the server via sliders and dropdowns.
  2. Agent Copilot (Sandbox): A complete Supervised Autonomy arena. Judges can select any HuggingFace model (e.g., Llama-3-70B), provide their token, and physically watch the LLM and Environment communicate autonomously within a live Chat UI until a perfect score is reached.
  3. Custom Datasets: The Copilot Sandbox includes a file dropzone. Judges can upload their own .csv files bypassing the TASK_REGISTRY, proving the environment scales seamlessly to custom, real-world data outside of the hackathon's static tests.

HuggingFace Space Setup

  1. Create Space β†’ SDK: Docker, tag: openenv
  2. Push all repo files
  3. Add Space secrets: HF_TOKEN, API_BASE_URL, MODEL_NAME
  4. Run: openenv validate --url https://huggingface.co/spaces/Jxth/dataclean-env

License

MIT License. Built for the Meta-Scalar OpenEnv Hackathon.

Contributors

jithendra-10

11 commits

Languages

Python

99.3%