Dream Cities
We trained AI models to imitate a city simulator, searched inside them for good city plans, and then tried those plans in the real simulator. Many of the best-looking plans failed, because the search had found the models’ mistakes.
A narrated film of a little over six minutes, in five parts, with a title before the last four. The introduction. A small city at night in a simulator, named as Micropolis, which works it through three months as a line of light crosses its map. A sheet of green light, the city as a world model imagines it, lifts off the ground and draws the fourth month before the simulator reaches it. Plain plates come down into the sheet for the 3,000,000 monthly transitions it was trained on. Twelve plans are tried in sheets stacked over the city, which does not move. Laid on the city, the sheet differs from it on one tile of 12,000, and a paper by Smith and Winkler is credited. The tile is named model exploitation, and papers by Ha and Schmidhuber and by Janner and others are credited. Then, on a dark ground, a row of 35 failed plans parted between luck and the world model at a place that wanders, over a question, how often does a plan look good only because the world model is wrong. Part two, The rollout, follows one plan. It is drawn on the city’s ground month by month, a search imagines a thousand plans as sheets reaching to the horizon and keeps this one. Run in the simulator, the plan pulls down a coal power plant, the district it fed goes dark inside thin outlines, and by the end of its two years 18 of the city’s 74 zones are without power, while the imagined city above them stays lit. Part three, The experiment. A count runs up to 11,232,678 plans replayed in the simulator. Two replays of the plan, seen from overhead and begun from seeds 703935725 and 616910012, come to differ on 160 of 12,000 tiles by the end of the two years. Begun from one seed they are the same, and 6,000 of 6,000 replays checked were the same to the last bit. A diagram of the method follows, the same search of 1,000 plans run in the world model and in the simulator, the winner of both replayed in the simulator on 32 fresh seeds. Under it is the estimate. A score is true worth and luck, and the measure is the share of the world model’s winners that fail less the share of the simulator’s own winners that fail. Then two bars, 90 of 193 test cases solved by the search in the simulator and 53 by the search in the world model. Part four, The findings. Two curves over the plans a search tried, from 10 to 10,000, the simulator’s climbing to 58 per cent of test cases solved and the world model’s levelling off at 27. The two usual tests are shown and named, both as tests of predictive fidelity. For one-step accuracy, a patch of city a month ahead with the tiles that changed in the simulator and in the world model. For rollout error, two pairs of lines parting over a year. Both tests are passed by 24 of 24 world models. Then 120 marks follow with a flat line through them. One recorded plan in two cities seen from overhead passes in the world model on 7 of 8 runs and fails in the simulator on 32 of 32 seeds. The 120 marks slide into a rising band, with a rank correlation of +0.875, and +0.681 within one kind of task. Five pairs of bars for five kinds of task show the winners a world model passed and the fewer it passed after six times the training, none of them on three kinds. Part five, The lesson. 77 squares stand for the winners the world model passed in searches of 1,000 plans. 35 of them failed in the simulator, 13 of those by luck alone. The advice follows. The two tests are named again, with what they measure and what they do not show. Three lines of type then say to pick a few plans at random, to ask the world model whether they pass and to check whether the real environment agrees, over five small marks in a ring for a few random plans beside 10,000 for one search. Then the first city with its two verdicts. The film closes on black, where a point of light draws the outline of the HyperPrior wordmark and of its mark, and then on white, where both stand in chrome.
Today we are publishing our first paper, Dream Cities. It asks how often a plan found inside a learned model of the world looks good only because the model is wrong.
The question matters now because these models are moving out of research and into use. Teams train agents, programs that learn by trial and error, inside them and check plans in them before trying anything for real. If a search can fool the model, what it finds there cannot be trusted.
We studied this in a city-building simulator, where we could check the true outcome of any plan and tell the model’s mistakes apart from ordinary luck. Searching harder inside a model soon stopped finding better plans and started finding the model’s blind spots. The usual accuracy tests gave no warning of this, but one simple check did.
What a world model is, and what can go wrong
A world model is a neural network trained to predict what an environment will do next. The environment might be a game, a robot’s surroundings or a city. Once you have one, an agent can practise inside it and plans can be tested inside it. That is faster and cheaper than the real thing, and sometimes the real thing is not available at all.
The trouble is that a world model is an approximation, and it is never completely right. That becomes a problem when you pair it with an optimiser, which here means a search that tries many plans and keeps the one with the highest score.
The search is drawn to the places where the model happens to be wrong in a plan’s favour, so the winning plan can look excellent inside the model and then fail in reality. Researchers call this exploiting the model.
A relief model of a landscape in white card, the simulator, with a sheet of lime acrylic, the world model, lying on it. In one place the sheet lifts into a summit with no ground under it. On the sheet are 1,000 points, the plans a search imagined. The plan it kept stands on the false summit, where it passes in 7 of 8 runs, and a plumb line drops to the ground beneath, where it fails on 32 of 32 seeds.
Why it is hard to measure
Reinforcement learning researchers have known about this for years. What has been hard is saying how much of it is going on, because ordinary luck gets mixed in.
Flip a thousand coins ten times and pick the one that came up heads most often. It will look like a special coin, and on the next ten flips it will behave like any other. In the same way, the best of a thousand noisy attempts at a task will look better than it really is, even in a perfect simulator.
So when a plan found inside a world model disappoints in reality, part of the drop is luck and part is the model being wrong. To find the model’s share, you have to measure the luck on its own and take it away.
What we did
We used Micropolis, the open-source engine of the original SimCity, the city-building game from 1989. You zone land, build roads and power plants and set taxes, and the city grows or it does not.
The game has chance built into it, so the same plan can come out differently from one run to the next. We changed the engine so that a run can be repeated exactly. A run starts from a random seed, a number that fixes all the dice it will throw, and with the seed fixed the simulator gives back the same two years, down to the last bit. That let us say for certain what any plan really does.
We then trained 24 world models to imitate the simulator, of different sizes and with different amounts of training. All of them passed the usual accuracy tests, which check how well a model predicts the city one month ahead and twelve months ahead.
A plan, in our experiments, is two years of building decisions for one city, made month by month. A task sets a goal for the end of those two years, for example to keep at least 95 per cent of the city’s zones, its blocks of land, supplied with power.
We searched for good plans inside the world models and replayed the winners in the simulator to see whether they really worked. To measure luck, we ran the same search in the simulator itself and checked its winners on fresh random seeds. Some of the simulator’s own winners failed on those fresh seeds, and that share is luck. Whatever the world models’ winners lost beyond it was the models’ doing.
Two rows. In the first a search tries 1,000 plans on a sheet of lime acrylic, the world model, keeps its winner and replays it on a tray of 32 fresh seeds in the simulator. Across 193 test cases, 35 of those winners fail the replay. In the second the same search is run on white card, the simulator itself, and 13 of its winners fail. Beneath, the 35 are laid out as tiles. 13 are card, as many as the simulator’s own winners lose, which is luck, and 22 are lime acrylic, the model’s doing.
One example, the missing power plant
One search tried a thousand plans inside a world model and kept those the model said would pass the power task. One of the winners demolishes a coal power plant in month eight.
Inside the model nothing goes wrong. We ran the plan there 8 times, because a model’s predictions vary a little from one run to the next, and it passed in 7 of them. In the run shown below, all 75 of the city’s zones still have power at the end of the two years.
In the simulator the plant is gone and stays gone. By the end of the two years 18 of the 74 zones the city has there are without power, and the plan fails on all 32 random seeds we tried.
One city drawn twice at month 24. Below, a white card model of the simulator’s city, 74 zones with 18 of them blacked out. Floating above it, a sheet of lime acrylic with the world model’s 75 zones, all lit. A line drops through both at the power plant the plan pulled down in month 8. Under them a step chart of the zones without power month by month. The simulator’s line jumps to 18 at month 8 and ends at 18 of 74. The world model’s stays at four or fewer and ends at 0 of 75.
We wanted to know which part of the model’s picture of the city had gone wrong. When we copied the simulator’s power grid into it, the model changed its answer and rejected the plan. Copying in any of eight other parts of the city, such as traffic or land value, made no difference. The mistake was in how the model keeps track of power.
Three rods over 24 months, the distance between the model’s picture of a city and the real one, where 1 is as far as the real city moves in two years. Lime is the coal plant plan, which the model passes in 7 of 8 runs and the simulator fails on all 32 seeds. Clear is a plan the model judges correctly, and blue the model’s largest miss. All three rise together and end near 0.7. The coal plant’s rod is marked at month 8, when the plant comes down, and spikes at the two year ends, months 11 and 23.
What we found
-
27 per cent
Searching harder does not help.
In the simulator, a longer search finds more plans that work. After 10,000 tries it had solved 58 per cent of our 193 test cases. Inside the world model, real performance stopped improving after about a thousand tries, and at 10,000 the winning plans solved 27 per cent. The gap between the two grew from 6 percentage points to 31 as the search got longer. Past about a thousand tries, searching for longer inside the world model bought us nothing.
A ribbon of white card, the search in the simulator, climbs from 13 per cent of test cases solved at 10 plans to 58 per cent at 10,000. Under it a block of lime acrylic, the search in the world model, rises to 27 per cent at 1,000 plans and stays at 27. The gap between them is measured at both ends, 6 points at 10 plans and 31 at 10,000. That is 112 of 193 test cases against 52. Pale bars mark the 95 per cent intervals.
Test cases solved by the winning plans once they are run in the simulator, against the number of plans a search tried. -
+0.875
The usual accuracy scores do not warn you. One cheap test does.
How well a model predicted the next month or the next year told us little about whether it would later be fooled. To measure how badly a model could be fooled, we trained agents inside all 24 models on all five of our kinds of task, which makes 120 pairings, and recorded how much better an agent scored inside its model than in the simulator. A much simpler check turned out to predict that. We take one recorded plan for a city, ask the model whether it passes the task, and compare its answer with the simulator’s. How often a model got this right ranked the models almost in the order of how badly they were later exploited. Across the 120 pairings the rank correlation was +0.875, where 1 would be a perfect match.
Two square boards of white card, both with the same 120 marks, one mark to a pairing of a world model and a kind of task, tinted by the kind of task in five acrylics. A mark is placed by its rank on a test and by its rank in how badly it was later exploited. On the usual accuracy test the marks show no order, a rank correlation of −0.098. On the cheap test they rise along the line, a rank correlation of +0.875, and +0.681 within one kind of task.
One mark is one pairing of a model and a task, 120 in all. The usual test here is accuracy one month ahead. The cheap test is how often the model passes one recorded plan that the simulator fails.Exploitation is how far an agent trained inside the model for a million months scored better there than in the simulator. -
3 of 5
The obvious fixes swap one mistake for another.
We tried three common remedies. Training a model six times longer improved its usual scores, and turned a model that said yes too often into one that said no to everything on three of our five kinds of task. Defences applied when the model is used cut the false passes, the plans that pass in the model and fail in the simulator, but only by also rejecting many plans that really work. Retraining on a wider range of tax and funding settings reduced the false passes without finding more plans that work. None of the three replaced checking the winning plans in the simulator.
Why it matters
More and more, agents are trained inside world models, and their work is scored by models that have been trained to judge it. Whenever a search or a training loop pushes hard against a learned model of either kind, the same thing can happen, because a model can look accurate on the usual tests and still be wrong exactly where an optimiser will push it.
So our advice is to keep a way of checking a world model’s verdicts against the real environment, even if only on a handful of whole plans, and to use it before paying for a long search inside the world model.
Limits
This is one simulator and one family of world models, on a modest budget of about 160 GPU hours. Some of the retraining results rest on a single run. We do not yet know how far the findings carry to larger models or other settings.
The paper and the code
The paper has the full method, the controls for luck and the complete results. The code and the data are released with it.
