Spaces:
Running
Running
Commit ·
fb9da93
1
Parent(s): 51aa9cd
docs: update HF_BLOG_POST.md with OpenEnv interface details, reward engineering insights, and refined training results
Browse files123456789101112131415163 unmodified lines2021222324252627282930313233343536373839404142434445464 unmodified lines515253545556575859606162636465662 unmodified lines6970717273747511 unmodified lines878889909192939495969798991001011021031041051061071081091101 unmodified line1121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771782 unmodified lines1811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302 unmodified lines233234235236237---title: GridMind-RL: Training LLMs to Manage Industrial Buildings with GRPOdescription: How we built an RL environment that teaches language models real-world energy management — and what 10 training runs taught us.---# GridMind-RL: Training LLMs to Manage Industrial Buildings*OpenEnv Hackathon India 2026 · GridMind-RL Team*---There is a building somewhere running its air conditioning at full power right now,even though electricity costs four times more than it did six hours ago. Not becausethe operator made a bad decision — but because the control system doesn't know theprice changed.3 unmodified linesof dollars per building per year.LLMs can read pricing curves, respond to fault alerts, and follow natural languageinstructions. The missing piece has always been an environment that trains them to*act* on that reasoning under real operational pressure.That's what we built.---## The EnvironmentGridMind-RL simulates a complete 24-hour industrial building energy system at15-minute resolution — 96 decision steps per episode. The agent operates incontinuous time, responding to a world that changes around it: prices spike, equipmentdegrades, grid stress signals arrive, and sometimes the chiller fails at 2pm on thehottest day of the year.**The agent sees 13 fields every step:**current indoor temperature, thermal storage level, electricity price, grid stresssignal, HVAC efficiency (which degrades continuously over the episode), active faultalarms, a 4-step price forecast, cumulative cost so far, carbon intensity, batch jobqueue, hour of day, and — in Task 4 — a natural language instruction card describingthe episode's objective.**The agent has four levers:**4 unmodified lines| `batch_job_slot` | 0 → 4 | When to run deferrable industrial loads || `load_shed_fraction` | 0 → 0.5 | Voluntary demand reduction during grid stress |**Four tasks test different capabilities:**- **Cost Minimization** — Navigate 24-hour price volatility and thermal storagearbitrage to minimize total energy spend.- **Comfort Management** — Hold indoor temperature within 19–23°C through equipmentdegradation, faults, and shifting external conditions.- **Demand Response** — Read grid stress signals in real time and voluntarily shedload to earn demand-response credit without sacrificing comfort.- **Instruction Following** — Parse a natural language objective card at episodestart and adapt the entire 96-step strategy to meet it.2 unmodified linesThe naive approach is to reward cost savings and call it done. The problem is thata cost-only reward teaches the agent to turn off the HVAC entirely — perfect score,frozen building.Real building operators don't optimize one metric. They manage a hierarchy:comfort is non-negotiable, grid compliance is contractual, cost is the primary KPI,11 unmodified lines| `efficiency_bonus` | 0.05 | Incentivises smart thermal storage arbitrage || `stability_penalty` | -0.05 | Prevents HVAC thrashing that causes equipment wear || `fault_mitigation` | dynamic | Correct fault response prevents costly outages || `task_satisfaction` | 0.50* | Task 4 only — weighted per the instruction card |A reward this dense is harder to game. An agent that exploits one component whileneglecting the others will see it reflected immediately in the score.---## TrainingWe trained Qwen2.5-1.5B-Instruct with QLoRA (4-bit, rank 16) using GRPO viaHuggingFace TRL. Each run is 60 steps on a T4 GPU, taking roughly 35 minutes.We ran 10 training iterations in total.**Why GRPO over PPO?**GRPO doesn't require a separate value network. At 1.5B parameters on a T4, thatmemory saving matters. Instead of estimating a value baseline, GRPO samples a groupof completions per prompt and computes advantages by comparing them against eachother — a natural fit for our setting where we generate multiple actions per state.| Component | Detail ||-----------|--------|1 unmodified line| Fine-tuning | QLoRA (4-bit, rank 16) || Algorithm | GRPO via HuggingFace TRL || Hardware | HF Space T4 GPU || Training time | ~35 minutes per run || Total runs | 10 |---## What the Curves Show### Run 1 vs Run 10: The reward is climbingThe clearest evidence of learning is what happens to the reward curve within a singletraining run — and how that shape changes as the training setup matures.**Run 1 — the first training run:***Run 1: Reward climbs from −0.47 to ~0.65 over 60 steps. The model is learning fastin the early steps, then stabilizing — with a small dip at the very end.***Run 10 — after iterative refinement:***Run 10: Same starting point, smoother curve, still rising at step 60. The modelhasn't plateaued — which means longer training would continue to improve it.*Both runs start at the same reward (~−0.47) because each run initializes fresh.What changes is the *shape*: Run 10 is more stable, ends higher (~0.68 vs ~0.65),and shows no end-of-run dip. Ten runs of iteration on the training setup produceda meaningfully cleaner learning signal.The 1.1-point reward improvement within a single 60-step run is not noise.The agent is learning to manage energy in real time.### Before and After: Where the model wins**Run 1 — heuristic baseline vs GRPO-trained:***Run 1: The trained model outperforms the heuristic on Task 4 by a significant margin.On Tasks 1–3 it scores below the heuristic — early training, limited steps.***Run 10 — heuristic baseline vs GRPO-trained:***Run 10: Similar pattern. Task 4 remains the trained model's strongest result.Tasks 1–3 gap to the heuristic has narrowed compared to Run 1.*### The Task 4 result is the headlineThe heuristic scores **0.30** on Task 4. The trained model scores **0.70**.That is a **133% improvement** on instruction following — and it makes complete sense.A fixed heuristic cannot read a natural language objective card. It cannot parse"keep total cost under $2.50 while maintaining comfort" and change its behavioraccordingly. The trained model can. That capability gap is exactly what thisenvironment was designed to measure.Tasks 1–3 tell a more honest story. Time-of-day HVAC scheduling is genuinelyreasonable for cost and temperature — the heuristic is a strong baseline on thosetasks, and 60 training steps with a 1.5B model isn't enough to beat it consistently.That's not a failure of the environment. It's a signal that longer training wouldcontinue to pay off.---2 unmodified linesNone of these behaviors are hardcoded. The reward signal surfaces them:**Thermal arbitrage** — the agent learns to charge thermal storage during off-peakhours (~4¢/kWh) and discharge during peak (~32¢/kWh), reducing the effective costof maintaining comfort during expensive periods.**Grid cooperation** — when the stress signal exceeds 0.7, the agent voluntarilysheds load rather than ignoring the signal. The demand-response credit offsets thecomfort penalty.**Fault adaptation** — when HVAC efficiency degrades below a threshold, the agentreduces its HVAC target rather than fighting a weakened system at full power.**Instruction parsing** — in Task 4, the agent reads the objective card and adjustsits entire 96-step strategy accordingly, not just the next action.---## What We'd Do With More Compute- **300+ training steps** would likely close the gap on Tasks 1–3- A **7B model** with the same setup would show sharper policy improvement- **Multi-agent coordination** — 3 buildings sharing a 250kW feeder — is fullyimplemented but not yet the primary training focus. Fleet-level demand responseis the next frontier.---## Try ItThe environment is live. You can reset an episode, send actions, and read rewardsright now from your terminal:```bash# Health checkcurl https://prajwal782007-gridmind.hf.space/health# Start an episodecurl -X POST https://prajwal782007-gridmind.hf.space/reset \-H "Content-Type: application/json" \-d '{"task_id": 4}'# Take an actioncurl -X POST https://prajwal782007-gridmind.hf.space/step \-H "Content-Type: application/json" \-d '{"hvac_power_level": 0.6, "thermal_charge_rate": 0.4,"batch_job_slot": 2, "load_shed_fraction": 0.0, "building_id": 0}'```- 🤗 **Environment**: https://prajwal782007-gridmind.hf.space2 unmodified lines---*Built for the OpenEnv Hackathon India 2026 · April 25–26 · Scaler School ofTechnology, Bangalore.*123456789101112131415163 unmodified lines202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576774 unmodified lines82838485868788899091929394959697982 unmodified lines10110210310410510610711 unmodified lines1191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511 unmodified line1531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132 unmodified lines2162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852 unmodified lines288289290291292---title: GridMind-RL: Training LLMs to Manage Industrial Buildings with GRPOdescription: How we built an OpenEnv-compatible RL environment that teaches language models real-world energy management — and what the training curves actually show.---# GridMind-RL: Training LLMs to Manage Industrial Buildings*OpenEnv Hackathon India 2026 · Aditya Suryavanshi, Shreeshant Bokade, Prajwal Valekar*---There is a building somewhere running its air conditioning at full power right now,even though electricity costs five times more than it did six hours ago. Not becausethe operator made a bad decision — but because the control system doesn't know theprice changed.3 unmodified linesof dollars per building per year.LLMs can read pricing curves, respond to fault alerts, and follow natural languageinstructions — but there has never been an environment that trains them to *act* onthat reasoning under real operational pressure. We built one, trained on it, and theresults show an agent that beats a hand-crafted heuristic on the tasks that matter most.---## Who We AreWe are a team of three fascinated by the gap between what LLMs can reason about andwhat they can actually *do*. Building energy management sits right at that frontier —the domain is rich, the stakes are real, and no RL benchmark has touched it.GridMind-RL is our attempt to change that.We built this for the Meta PyTorch OpenEnv Hackathon Grand Finale at Scaler Schoolof Technology, Bangalore, April 25–26, 2026.---## Which Themes We're TargetingGridMind-RL directly addresses two hackathon themes:**Theme 1 — Multi-Agent Interactions:** Three buildings share a 360kW grid feeder(120kW per building). A coordinator LLM reads fleet-wide demand via `/feeder` andsets per-building price multipliers via `/coordinate`. Buildings that ignore thesignal trip the feeder limit — causing a grid fault penalty for all three. Thiscreates genuine emergent coordination pressure without explicit communication.**Theme 3.1 — World Modeling (Professional Tasks):** The `/simulate` endpoint letsthe agent ask "what if?" before committing an action. When HVAC efficiency is low orfaults are active, the agent can simulate a proposed action and revise its plan ifthe predicted reward is poor. This trains causal reasoning and persistent worldmodeling — exactly what Theme 3 targets.---## The EnvironmentGridMind-RL implements the OpenEnv-compatible interface (reset/step/state/grade)via a high-performance Go HTTP server. openenv-core==0.2.3 is used as thePython client library for training-side interaction. It simulates a complete 24-hour industrialbuilding energy system at 15-minute resolution — 96 decision steps per episode.The agent operates in continuous time, responding to a world that changes around it:prices spike up to 5× during tariff faults, equipment degrades, grid stress signalsarrive, and sometimes the chiller fails at 2pm on the hottest day of the year.**The agent sees a rich observation space every step, including:**indoor temperature, thermal storage level, electricity price, grid stress signal,HVAC efficiency (which degrades continuously throughout the episode), active faultalarms, a 4-step price forecast, cumulative cost, carbon intensity, batch job queue,and hour of day. In Task 4, this also includes a natural language instruction card.**The agent has four levers:**4 unmodified lines| `batch_job_slot` | 0 → 4 | When to run deferrable industrial loads || `load_shed_fraction` | 0 → 0.5 | Voluntary demand reduction during grid stress |**Four tasks of increasing difficulty:**- **Cost Minimization** — Navigate 24-hour price volatility (~2¢ to ~36¢/kWh) andthermal storage arbitrage to minimize total energy spend.- **Comfort Management** — Hold indoor temperature within 19–23°C through equipmentdegradation, faults, and shifting external conditions.- **Demand Response** — Read grid stress signals in real time and voluntarily shedload (when signal exceeds 0.7) to earn demand-response credit without sacrificingcomfort.- **Instruction Following** — Parse a natural language objective card at episodestart and adapt the entire 96-step strategy to meet it.2 unmodified linesThe naive approach is to reward cost savings and call it done. The problem is thata cost-only reward teaches the agent to turn off the HVAC entirely — perfect score,frozen building. This is textbook reward hacking.Real building operators don't optimize one metric. They manage a hierarchy:comfort is non-negotiable, grid compliance is contractual, cost is the primary KPI,11 unmodified lines| `efficiency_bonus` | 0.05 | Incentivises smart thermal storage arbitrage || `stability_penalty` | -0.05 | Prevents HVAC thrashing that causes equipment wear || `fault_mitigation` | dynamic | Correct fault response prevents costly outages || `task_satisfaction` | 0.10–0.50* | Task 4 only — weighted per the instruction card |> *`task_satisfaction` weight varies by instruction template, ranging from> 0.10 to 0.50 depending on the episode's objective card (tasks.go).### How we prevent reward hackingA multi-component reward is only part of the answer. We also:- **Clamp all actions** at the server side — the agent cannot exceed valid rangesregardless of what it outputs (`hvac_power_level` hard-clamped 0–1,`load_shed_fraction` hard-clamped 0–0.5, etc.)- **Inject four fault types** that make naive exploitation brittle: chiller failure(HVAC drops to 20% capacity), grid outage (price up to ×4, stress = 1.0), sensorfault (temperature jitter ±5°C), and tariff spike (price up to ×5)- **Use a seeded but stochastic environment** — price curves, fault timing, anddemand patterns vary across episodes, preventing the agent from memorizing afixed solution- **Score via `/grade`** at episode end using a separate grading function that isdecoupled from the per-step reward signal---## TrainingWe trained Qwen2.5-1.5B-Instruct with QLoRA (4-bit, rank 16) using GRPO viaHuggingFace TRL on a T4 GPU — roughly 35 minutes per run.| Component | Detail ||-----------|--------|1 unmodified line| Fine-tuning | QLoRA (4-bit, rank 16) || Algorithm | GRPO via HuggingFace TRL || Hardware | HF Space T4 GPU || Training time | ~35 minutes || Steps | 60 |**Why GRPO over PPO?**GRPO doesn't require a separate value network. At 1.5B parameters on a T4, thatmemory saving matters. Instead of estimating a value baseline, GRPO samples a groupof completions per prompt and computes advantages by comparing them against eachother — a natural fit for our setting where we generate multiple actions per stateand want to reinforce the better ones.The hackathon context emphasized that RL only works if the probability of a goodanswer is greater than zero. We confirmed this by running a heuristic baseline firstto verify the environment produces non-zero reward before starting RL training.---## Results### The numbers first| Policy | Task 1 | Task 2 | Task 3 | Task 4 | Avg (unweighted) ||--------|--------|--------|--------|--------|------------------|| Heuristic Baseline | 0.54 | 0.56 | 0.50 | 0.31 | 0.48 || GRPO Fine-tuned | 0.42 | 0.34 | 0.47 | **0.49** | 0.43 |> Heuristic = fixed time-of-day HVAC scheduling, no learning.> GRPO Fine-tuned = Qwen2.5-1.5B-Instruct after 60 steps of GRPO training> against the live environment.The trained model **beats the heuristic on Task 4 by 58%** (0.49 vs 0.31) and**comes within 6% of the heuristic on Task 3** (0.47 vs 0.50).These are the two tasks where intelligent reasoning matters most — instructionparsing and real-time grid cooperation. A fixed schedule cannot read an objectivecard. A fixed schedule cannot respond to a grid stress signal that arrives mid-episode.The trained model can do both.Tasks 1 and 2 are an honest result. Time-of-day HVAC scheduling is genuinelycompetitive for cost and comfort — the heuristic baseline is strong on thoseobjectives because the physics are predictable. Closing that gap requires moretraining steps. The reward curve shows the trend is still moving upward at step 60,meaning training had not plateaued.### The reward curve*Reward vs training step. From −0.47 at step 5 to +0.61 at step 60 — a 1.08-pointgain. The smoothed average (red dashed) is still rising at the final step, confirmingtraining had not saturated.*### The before/after*Grade scores per task: heuristic baseline (blue) vs GRPO-trained LLM (green).Task 4 is where the trained model pulls clearly ahead — 58% above the heuristic.*---2 unmodified linesNone of these behaviors are hardcoded. The reward signal surfaces them:**Thermal arbitrage** — the agent learns to charge thermal storage during off-peakhours (~3.5¢/kWh) and discharge during peak (~31¢/kWh), reducing the effective costof maintaining comfort during expensive periods.**Grid cooperation** — when the stress signal exceeds 0.7, the agent voluntarilysheds load rather than ignoring it. The demand-response credit offsets the comfortpenalty — which is why Task 3 performance is closest to the heuristic.**Fault adaptation** — when HVAC efficiency degrades, the agent reduces its HVACtarget rather than fighting a weakened system at full power. This behavior emergespurely from the `fault_mitigation` reward component.**Instruction parsing** — in Task 4, the agent reads the objective card and adjustsits entire 96-step strategy to meet it. This is the hardest capability for aheuristic to replicate — and where the trained model wins most clearly.---## What's NextGridMind-RL is a foundation, not a finished product. The directions we find mostinteresting:**Longer training runs** — the reward curve hasn't plateaued at 60 steps. 300+steps would likely close the gap on Tasks 1 and 2 and push Task 4 performancefurther above the heuristic.**Larger models** — a 7B model with the same training setup would bring strongerinstruction-following capability and better multi-step planning out of the box.**Fleet-level coordination** — three buildings share a 360kW grid feeder (120kW perbuilding). Fleet-level coordination is fully implemented — training a coordinator LLMthat orchestrates all three through price signals is the next research direction.The shared feeder constraint creates genuine emergent coordination pressure — if onebuilding ignores the signal, all three pay the penalty.**Real deployment** — the environment's physics are grounded in real buildingparameters. The gap between this simulator and a real BMS integration is smallerthan it looks.---## Try ItGridMind-RL is live and OpenEnv-compliant. Task 4 is the most interesting to try —the agent receives a natural language objective card and must adapt its entirestrategy to meet it:```bash# Health checkcurl https://prajwal782007-gridmind.hf.space/health# Start a Task 4 episode (instruction following)curl -X POST https://prajwal782007-gridmind.hf.space/reset \-H "Content-Type: application/json" \-d '{"task_id": 4}'# Take an action and observe the rewardcurl -X POST https://prajwal782007-gridmind.hf.space/step \-H "Content-Type: application/json" \-d '{"hvac_power_level": 0.6, "thermal_charge_rate": 0.4,"batch_job_slot": 2, "load_shed_fraction": 0.0, "building_id": 0}'# Grade the full episodecurl https://prajwal782007-gridmind.hf.space/grade```- 🤗 **Environment**: https://prajwal782007-gridmind.hf.space2 unmodified lines---*Built for the Meta PyTorch OpenEnv Hackathon × Scaler School of Technology ·Grand Finale, April 25–26, 2026, Bangalore.*
HF_BLOG_POST.md+153-98