CoolFace
Apppublic

KingHero121/dataforge-env

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
README.md115 linesDownload Raw Back to root
1---2title: DataForge Env3emoji: ๐Ÿค–4colorFrom: blue5colorTo: green6sdk: docker7app_file: server/app.py8pinned: false9---10 11# DataForge-Env ๐Ÿ”ง12 13> A production-grade OpenEnv environment for evaluating LLM-based agents on real-world data cleaning, validation, and multi-table reconciliation tasks.14 15---16 17## Overview18 19DataForge-Env wraps a stateful data-cleaning sandbox. Agents interact via structured actions to fix dirty datasets โ€” filling nulls, casting types, normalising values, joining tables, and satisfying business rules.20 21Rewards are **dense** and **deterministic**: agents receive granular feedback after every step, enabling RL-style training and scientific benchmarking.22 23## Tasks24 25| ID | Name | Difficulty | Max Steps | Description |26|----|------|-----------|-----------|-------------|27| `easy` | The Untidy Retailer | Easy | 15 | Fill missing emails, remove duplicates, trim whitespace |28| `medium` | Financial Anomaly | Medium | 20 | Parse currency strings, unify dates, cap outliers |29| `hard` | Supply Chain Reconciliation | Hard | 25 | Normalise SKU keys, join tables, compute inventory value |30 31## Quick Start32 33### Local34```bash35pip install -r requirements.txt36python -m server.app37# Server runs on http://localhost:786038```39 40### Docker41```bash42docker build -t dataforge-env .43docker run -p 7860:7860 dataforge-env44```45 46### API Usage47 48**Reset** (start an episode):49```bash50curl -X POST http://localhost:7860/reset \51  -H "Content-Type: application/json" \52  -d '{"task_id": "easy"}'53```54 55**Step** (apply an action):56```bash57curl -X POST http://localhost:7860/step \58  -H "Content-Type: application/json" \59  -d '{"action": {"action_type": "fill_missing", "params": {"column": "email", "strategy": "constant", "fill_value": "unknown@example.com"}}}'60```61 62## Action Space63 64| Action | Key Params |65|--------|-----------|66| `fill_missing` | `column`, `strategy` (mean/median/mode/constant/drop), `fill_value` |67| `drop_duplicates` | `subset` (optional list of columns) |68| `cast_type` | `column`, `target_dtype` (int/float/str/datetime) |69| `normalize` | `column`, `method` (trim/lower/upper/strip_currency/unify_date/strip_prefix/map_values/clip) |70| `join` | `right_table`, `left_on`, `right_on`, `how` |71| `validate` | (no params โ€” returns current validation errors) |72 73## Reward Formula74 75```76R = 0.3 ร— C_schema + 0.2 ร— C_nulls + 0.1 ร— C_dupes + 0.4 ร— C_logic โˆ’ 0.01 ร— step_penalty77```78 79All components and the final reward are normalised to **[0, 1]**.80 81## Inference Script82 83```bash84export API_BASE_URL=https://api-inference.huggingface.co/v185export MODEL_NAME=meta-llama/Llama-3-70B-Instruct86export HF_TOKEN=hf_...87export ENV_URL=http://localhost:786088export TASK_ID=easy89 90python inference.py91```92 93Output follows strict `[START]` / `[STEP]` / `[END]` format.94 95## Project Structure96 97```98โ”œโ”€โ”€ openenv.yaml          # Environment specification99โ”œโ”€โ”€ env/100โ”‚   โ”œโ”€โ”€ models.py         # Pydantic schemas101โ”‚   โ”œโ”€โ”€ env.py            # Core environment class102โ”‚   โ”œโ”€โ”€ tasks.py          # Task definitions & data generators103โ”‚   โ””โ”€โ”€ graders.py        # Deterministic grading104โ”œโ”€โ”€ server/105โ”‚   โ””โ”€โ”€ app.py            # FastAPI server106โ”œโ”€โ”€ inference.py          # LLM agent inference script107โ”œโ”€โ”€ Dockerfile            # Container definition108โ”œโ”€โ”€ requirements.txt      # Python dependencies109โ””โ”€โ”€ README.md             # This file110```111 112## License113 114MIT115