Source-linked AI summary

EnvGen: Generating and Adapting Environments via LLMs for Training Embodied Agents

Abhay Zala, Jaemin Cho, Han Lin, Jaehong Yoon, Mohit Bansal

arXiv:2403.12014v2cs.CLcs.AIcs.LG

TL;DR

EnvGen addresses the cost of frequently querying LLM agents by using LLMs to generate and adapt training environments for smaller RL agents. It trains agents across varied environments, feeds original-environment performance back to the LLM, and reports stronger long-horizon learning and benchmark performance with far fewer LLM calls.

  • Problem

    LLM agents can outperform smaller RL agents through world knowledge and reasoning, but frequent LLM calls are slow and expensive while RL agents struggle with sparse-reward long-horizon tasks.

    Source: §1 · p. 2
  • Method

    EnvGen prompts an LLM to generate environment configurations, trains a small RL agent in those environments and the original environment, then adapts them toward weak skills using performance feedback.

    Source: §1 · p. 2
  • Results

    Across Crafter and Heist, EnvGen improves agent performance and long-horizon learning, outperforms reported curriculum approaches and an LLM agent, and uses only a few LLM calls.

    Source: §1 · p. 3, §6 · pp. 10–11
  • Takeaways & Limitations

    LLM world knowledge can be used to shape training environments while retaining a lightweight RL agent and substantially reducing LLM-query costs.

    Source: §1 · p. 3, §6 · pp. 10–11

    EnvGen relies on strong LLMs such as GPT-4 and requires simulators that accept standard text configuration formats.

    Source: G Limitations · p. 22

Abstract

from arXiv · show

Recent SOTA approaches for embodied learning via interaction directly employ large language models (LLMs) as agents to determine the next steps in an environment. Due to their world knowledge and reasoning capabilities, LLM agents achieve stronger performance than previous smaller agents based on reinforcement learning (RL); however, frequently calling LLMs is slow and expensive. Instead of directly employing LLMs as agents, can we use LLMs' reasoning capabilities to adaptively create training environments to help smaller RL agents learn useful skills that they are weak at? We propose EnvGen, a novel framework to address this question. We first prompt an LLM to generate training environments by giving it the task description and simulator objectives that the agents should learn and then asking it to generate a set of environment configurations (e.g., different terrains, items initially given to agents, etc.). Next, we train a small RL agent in a mixture of the original and LLM-generated environments. Then, we enable the LLM to continuously adapt the generated environments to progressively improve the skills that the agent is weak at, by providing feedback to the LLM in the form of the agent's performance. We demonstrate the usefulness of EnvGen with comprehensive experiments in Crafter and Heist environments. We find that a small RL agent trained with EnvGen can outperform SOTA methods, including a GPT-4 agent, and learns long-horizon tasks significantly faster. We also show that using an LLM to adapt environments dynamically outperforms curriculum learning approaches and how the environments are adapted to help improve RL agents' weaker skills over time. Additionally, EnvGen is substantially more efficient as it only uses a small number of LLM calls (e.g., 4 in total), whereas LLM agents require thousands of calls. Lastly, we present detailed ablation studies for EnvGen design choices.

1 Introduction

EnvGen uses LLM reasoning to generate and adapt training environments for lightweight RL agents, addressing sparse-reward exploration while avoiding frequent LLM-agent calls. Across Crafter and Heist, it improves performance and long-horizon learning with only a few LLM calls.

Motivation and approach

  • Small RL agents struggle with long-horizon tasks because rewards arrive sparsely only after sequences of successful actions, making useful exploration slow and expensive.Source: §1 · p. 2
  • EnvGen adaptively generates training environments so small RL agents can learn diverse skills in parallel and receive more frequent rewards for challenging long-horizon tasks.The environments vary conditions such as terrain and initially achieved subgoals, then adapt based on agent performance.Source: §1 · pp. 2–3

Method

  • EnvGen trains a lightweight RL agent in LLM-generated environments, evaluates it in the original environment, and feeds task-specific successes and failures back to the LLM.Source: §1 · pp. 2–3

Efficiency

  • EnvGen requires only a few LLM calls, such as four, whereas LLM-agent methods query the model thousands of times during an episode.Source: §1 · p. 3

Results

  • Across Crafter and Heist, EnvGen improves overall performance, long-horizon learning, and training stability, outperforming curriculum approaches and a GPT-4 agent in reported comparisons.Source: §1 · p. 3

2 EnvGen: Generating and Adapting Environments via LLMs for Training Embodied Agents

EnvGen alternates between generating varied LLM environments, training a small RL agent, evaluating it in the original environment, and adapting environments toward weak skills. This design targets sparse rewards and prerequisite chains in long-horizon tasks.

Motivation

  • EnvGen addresses long-horizon exploration by training agents in varied environments that expose different skills and provide more frequent rewards.Conditions can include different terrains or already-achieved subgoals.Source: §2.1 · p. 3, §2.2 · pp. 3–4

EnvGen cycle

  • Each EnvGen cycle generates custom configurations with an LLM, trains the agent in parallel across LLM environments, evaluates it in the original environment, and adapts environments using performance feedback.Source: Figure 2 · p. 4, §2.2 · pp. 4–5

Environment generation

  • Environment configurations are prompted from task descriptions, simulator objectives, controllable settings, and simulator constraints, then rendered in the game simulator.Source: §2.2 · p. 4

Long-horizon tasks

  • Crafter exemplifies the challenge: some achievements are immediate, whereas others require long prerequisite chains before becoming available.Source: §2.1 · p. 3, Figure 3 · p. 5

EnvGen cycle

  • The LLM receives task-specific success rates with standard deviations and updates environments in the next cycle to focus on skills where the agent performs weakly.Source: §2.2 · p. 5

3 Experimental Setup

EnvGen is evaluated in Crafter and Heist with a lightweight PPO agent, using Crafter’s hierarchical achievement structure and comparisons against LLM-based and non-LLM baselines. The Crafter setup uses four cycles and 1.96M total training steps.

Benchmarks

  • Experiments evaluate EnvGen in Crafter, a 22-achievement open-world survival game, and Heist, where agents navigate a maze, open locks, and steal a gem.Source: §3.1 · pp. 5–6
  • Crafter contains short tasks and long prerequisite chains, such as collecting resources and crafting tools before an iron pickaxe or diamond becomes attainable.Source: §3.1 · pp. 5–6

Training setup

  • The Crafter EnvGen setup uses NCycle = 4 and totals 1.96M training steps, combining LLM-generated-environment steps, Crafter steps, and final original-environment training.Source: §3.1 · p. 6

Agent and baselines

  • The base agent is a lightweight CNN-plus-linear model with fewer than 5M parameters, trained with PPO from visual observations.Source: §3.2 · p. 6
  • Crafter comparisons include frequent-LLM-call methods such as SPRING and ELLM, alongside non-LLM agents including DreamerV3, MuZero + SPR, LSTM-SPCNN, and PPO.Source: §3.2 · p. 6

4 Results and Analysis

EnvGen improves lightweight RL performance on Crafter, especially for long-horizon achievements, while adaptive environment updates outperform fixed and curriculum-based alternatives.

4.1 Crafter Results

  • 32.2% average score: a 4M-parameter PPO agent trained with EnvGen outperforms Crafter baselines, including a GPT-4 agent scoring 27.3%.Table 1 reports geometric-mean success across 22 achievements for 1M Crafter steps.Source: §4.1 · p. 7, Table 1 · p. 7

4.2 Long-Horizon Tasks

  • CrafterEnvGen improves several achievement success rates, notably long-horizon stone and iron tools, compared with training only in Crafter.The comparison uses 0.96M EnvGen steps followed by 1M Crafter steps versus 1.96M Crafter-only steps.Source: §4.2 · p. 7, Figure 4 · p. 8
  • After unlocking the stone pickaxe, the EnvGen-trained agent unlocks iron tools significantly faster than the baseline.Figure 5 measures first-completion times for stone pickaxe, iron pickaxe, and iron sword during the final 1M training steps.Source: §4.2 · p. 7, §4.3 · p. 8, Figure 5 · p. 8

4.3 Adaptation of Training Environments Helps the Agent Improve Weaker Skills

  • Across EnvGen cycles, feedback about weak skills prompts targeted environments, such as coal collection and stone-pickaxe crafting, that improve those skills.The LLM receives intermediate performance and adapts subsequent training configurations accordingly.Source: §4.3 · pp. 7–8, Figure 6 · p. 9

4.4 Additional Analysis and Ablation Studies

  • Adaptive environment updates raise the Crafter score to 32.2%, versus 29.9% for fixed LLM environments and 26.8% for both easy-to-hard and adversarial curricula.The adaptive method updates environments using intermediate performance to target weaker skills.Source: §4.4 · pp. 8–9, Table 2 · p. 9
  • Updating environments every 0.12M steps performs best; more than four feedback cycles provide no further improvement, though feedback remains better than fixed or original environments.The reported comparison is against 26.4% for original Crafter training and 29.9% for fixed LLM environments.Source: Table 3 · p. 9, §4.4 · p. 10

5 Related Works

Related work covers LLM-based action planning for embodied agents and deep-learning approaches to procedural game and simulator content generation.

LLMs as open-world game agents

  • LLM-based embodied-agent methods use world knowledge and reasoning to create action plans, often querying LLMs frequently during open-world-game interaction.The cited methods target environments such as Minecraft and Crafter.Source: §5 · p. 10

Deep learning-based game/simulator content generation

  • Procedural content generation automatically creates game elements such as levels, landscapes, items, rules, and quests, with recent work applying deep learning methods including GANs.Traditional approaches use search, solvers, rules, or grammars, while newer approaches use learned generators.Source: §5 · p. 10

6 Conclusion

EnvGen uses LLM knowledge to generate and adapt training environments for embodied RL agents, improving weaker skills across Crafter and Heist while reducing LLM usage.

Conclusion

  • EnvGen prompts an LLM to generate simulator configurations, trains an agent in the resulting environments, evaluates it in the original environment, and feeds performance back for updates.The updates target skills at which the agent is weaker.Source: §6 · p. 10
  • In Crafter and Heist, EnvGen improves agent performance, is more effective than longer training in the original environments, and dynamically adapted environments outperform curriculum approaches.A lightweight model trained with generated environments also outperforms an LLM agent while using fewer LLM calls.Source: §6 · p. 11
  • The paper includes additional related work, environment details, experiments, curriculum baselines, implementation details, LLM details, and limitations in the appendices.Source: Appendix · p. 16

C.1 Design Choices, Ablations, and Other Agent Architectures

Ablations show that EnvGen improves performance over longer training in the original environment, with GPT-4-Turbo and four generated environments performing particularly well. The framework also generalizes to Heist, benefits from meaningful parameter names, and improves long-horizon achievement learning with Achievement Distillation.

EnvGen vs. longer training

  • 32.2% vs. 26.4% at 1.96M total steps shows EnvGen outperforming longer training only in Crafter.At 1.24M steps, the corresponding comparison is 22.3% vs. 21.1%.Source: §C.1 · p. 18, Table 4 · p. 18

Different LLMs

  • 29.9% for GPT-4-Turbo exceeds Deepseek 33B Instruct at 26.3% and GPT-3.5-Turbo at 21.5% for environment generation.These environments use a fixed single-cycle configuration.Source: §C.1 · p. 18, Table 5 · p. 18

Number of LLM environments

  • Four generated environments produce the highest result, while all tested environment counts improve performance over the 26.4% original-Crafter baseline.The tested counts are 1, 2, 4, and 8 environments per cycle.Source: §C.1 · p. 18, Table 6 · p. 18

Training-step ratio

  • EnvGen trains first in LLM-generated environments and then in the original environment to reduce overfitting to generated environments.The ratio of training steps between these settings is varied while keeping total training steps constant at 1.96M.Source: §C.1 · p. 19, Table 7 · p. 19

Parameter naming

  • Obscuring environment parameter names lowers performance from 32.2 ± 0.6 to 28.5 ± 0.6, indicating that parameter semantics contribute to generated-environment quality.The analysis replaces original parameter names with obscure names to remove prior knowledge about their usefulness for skills.Source: §C.1 · p. 19

Achievement Distillation

  • EnvGen also improves long-horizon tasks for the Achievement Distillation agent, including making iron tools and collecting diamonds.This result is reported from the Crafter evaluation.Source: §C.1 · p. 19

C.2 Evaluation on Heist Environment

On Heist, EnvGen improves average performance and rewards while reducing score variance. The evaluation averages success rates over 100 test episodes across 10 seeds.

Heist evaluation

  • 37.7% vs. 25.9% average score and 5.5% vs. 4.1% reward show HeistEnvGen improving over standard Heist training.Score variance also decreases from 13.2% to 7.5%.Source: §C.2 · p. 19

Curriculum baselines

  • The comparison includes easy-to-hard and adversarial curriculum baselines for evaluating environment-training strategies.The easy-to-hard curriculum follows a predefined progression from easy to hard environments, while the adversarial curriculum updates training toward difficult environments.Source: D Curriculum Learning Baseline Details · p. 20

E RL Agent Implementation Details

The implementation uses a PPO-based agent and an Achievement Distillation agent, with architecture and auxiliary-training details inherited from prior work. The appendix also includes their hyperparameter tables and a prompt-template figure.

PPO agent

  • The PPO agent modifies IMPALA’s default ResNet by increasing channel and hidden sizes and adding layer normalization around linear and convolutional layers.The implementation places layer normalization after the final linear layer rather than before it.Source: E RL Agent Implementation Details · p. 20

Prompt template

  • The environment-generation prompt template is documented separately for the LLM-based configuration process.The supplied figure identifies the prompt template used for environment generation.Source: Figure 9 · p. 21

Achievement Distillation agent

F Additional LLM Details

Additional materials document the environment-generation and feedback prompts, agent hyperparameters, and the cost of using GPT-4-Turbo in EnvGen. The reported costs are much lower than those of an LLM agent queried throughout an episode.

Environment-generation prompt

  • The environment-generation prompt template can vary slightly across environments and games while retaining a generally consistent structure.The template is shown in the referenced figure.Source: F Additional LLM Details · p. 21

Hyperparameters

  • The appendix provides hyperparameter tables for the PPO and Achievement Distillation agents.The supplied tables identify these as implementation references for the corresponding agent architectures.Source: Table 9 · p. 22, Table 10 · p. 22

Feedback prompting

  • The feedback prompt is concatenated to the previous LLM output, preserving chat history across feedback-cycle iterations.This prompt is used during step 4 of the EnvGen cycle.Source: F Additional LLM Details · p. 22

API cost

  • EnvGen’s initial environment generation costs $0.03, and each feedback iteration adds $0.04 using GPT-4-Turbo.The listed API rates are $10.00 per 1M input tokens and $30.00 per 1M output tokens.Source: F Additional LLM Details · p. 22
  • SPRING is reported to cost $270 USD and require several thousand LLM calls per episode, making it more expensive than EnvGen.After EnvGen training, no further LLM calls are required for inference or additional training on the original environment.Source: F Additional LLM Details · p. 22

G Limitations

EnvGen’s limitations are its reliance on strong LLMs and on simulators that accept correctly formatted configuration files. These requirements constrain accessibility and applicability across environments.

LLM accessibility

  • EnvGen relies on strong LLMs such as GPT-4, although the framework uses only a few calls during training.The authors report that roughly four calls cost less than $1 for the entire training process.Source: G Limitations · p. 22

Simulator requirements

  • EnvGen requires simulators to accept standard configuration formats and LLMs to generate those configurations correctly.Supported formats include JSON, CSV, YAML, and TOML.Source: G Limitations · p. 22
  • The paper’s environment-generation prompts specify task descriptions, controllable simulator settings, and simulator constraints.Source: G Limitations · p. 22, Figure 10 · p. 23
Loading 2403.12014v2…