The shoot begins as night falls at an industrial warehouse in Bucharest, Romania. The air is filled with artificial fog as spotlights illuminate the film’s unlikely hero: a sleek, new Lexus ES. The emotion has escalated to this penultimate scene, which is the trickiest one to capture, according to director Kevin Macdonald. This is the moment when the machine, once brought to life, rebels.

In this story, the car, which was painstakingly built by a Takumi (Japanese artisan), has been kidnapped and nearly destroyed after its release into the world. But as its captors look on, it finally finds a way to break free.

Macdonald first read this script for a Lexus ad months ago. He doesn’t direct many ads, but this tale intrigued him. "It has a kind of dream logic to it. Normally you would think that’s the sign of an artist," he says. "But in this case, it came from a computer."

The new Lexus ES campaign, which broke this week, was written by artificial intelligence. Macdonald, an Oscar- and Bafta-winning director behind films such as Whitney and The Last King of Scotland, was brought on board to direct the AI’s script. "It’s man and machine working together," Macdonald says, but neither he nor the brand and its agency, The & Partnership London, expected an outcome like this. The story that the AI wrote is eerily self-aware, almost as if a human had written it.

"What’s odd is that it came up with a story that’s self-reflective, about a machine struggling to figure out if it’s alive or not," Macdonald says.

This strange experiment began in early 2018, but the idea of using AI to make advertising is nothing new. Last year, for example, Saatchi & Saatchi LA trained IBM’s supercomputer Watson to write thousands of ads for Toyota’s Mirai. Until now, though, this area has been dominated mostly by gimmickry, such as Burger King’s "AI-created" ads, which turned out to be written by people.

The conclusion drawn from such attempts is often the same: AI could never replace human creativity. Creative directors tend to hold this technology at arm’s length, its full power untapped.

The ad is shot from the car's point of view, with echoes of the Frankenstein tale – 'a creature created by a mad scientist and then tortured until it finds freedom'

But what if that view, clouded by fear of robots taking over jobs, is wrong? Perhaps AI, given the right tools and a dose of human understanding, could be a friendly collaborator, working hand in hand with people to achieve the same level of creativity. Lexus set out to discover whether this was possible.

If any brand were to venture into this territory, it makes sense that it would be Lexus. After all, this is the same company that built a hoverboard in 2015.

Lexus’ mission to transform its image into that of a more innovative brand is dear to Akio Toyoda, president and chief executive of parent company Toyota. Speaking at the Detroit Auto Show two years ago, he said: "I was determined to make sure we became a more emotional brand and that the words ‘boring’ and ‘Lexus’ never showed up in the same sentence again."

So, when introducing its new ES car to Western Europe, Lexus needed a pioneering approach. It bills the ES as an "intuitive" vehicle, with technologically advanced features that respond to drivers’ intentions and can make decisions on their behalf. "[The car’s design] means man and machine together create a better driving experience," Dave Bedwood, creative partner at The & Partnership London, says.

From this principle arose an idea for a campaign: man and machine could also collaborate to create an ad that mimics the intuitive driving experience. Bedwood admits: "We didn’t know how it would pan out."

The & Partnership London turned to tech company Visual Voice to build an AI platform that could write the next Lexus script, with visual recognition support from IBM Watson.

Will Nutbrown, co-founder of Visual Voice, shared Bedwood’s scepticism at the start of the project, unsure whether it could work.

Visual Voice looked to areas beyond marketing for inspiration, such as scientists in the medical field who have developed AI to detect cancer cells. With any AI venture, the first step is to properly train the machine, Nutbrown explains.

"When you start, an AI machine knows almost nothing. It doesn’t understand the world or come with the innate knowledge that a human has," he says. "The first challenge was finding what we needed to feed to the AI machine to allow it to reach a successful outcome."

They trained Lexus’ AI with 15 years’ worth of Cannes Lions-winning car and luxury advertising. Early on, a few trends emerged from the data. For example, award-winning automotive ads usually avoid extended driving shots, focusing instead on the stories and human connections around the car. Meanwhile, much luxury advertising delves into a brand’s heritage or craftsmanship. Both aspects can be found in the script that the AI ended up writing.

But this data alone would probably simply have churned out a clichéd "mash-up of car ads", Bedwood says. What set this project apart was the attempt to teach AI to be intuitive. Visual Voice drew on emotional intelligence data from ad tech company Unruly to identify the most stimulating moments in advertising. The company also teamed up with a group of applied scientists, MindX, at the University of New South Wales, on a study that explored what makes someone intuitive and how people with high levels of intuition respond to car ads.

As a result of this training, the AI was able to write an emotive script similar to one a human might create. The machine produced two documents: one that described a series of locations, actions and individuals, and the sequence in which they should occur; the other a scoring sheet outlining specific criteria to make a successful luxury car ad.

Bedwood says he expected the AI to assist him with creating an ad, but not to take over and write the entire script. The details were so specific and clear that "there was a weird moment when I thought Will [Nutbrown] had written it", Bedwood recalls.

Bedwood structured the AI’s documents into full sentences in the style of a typical film script, but he worked closely with Visual Voice to ensure every line was true to the computer’s meaning, he adds.

"I was shut out of this creative process in a way," Bedwood says. "It makes you question your own involvement. Are creativity and intuition really out of the realm of AI? You go, maybe it isn’t."

The Lexus ES ad script was written by AI and directed by Macdonald (above, right)

The final script contains unexpected details and moments that cannot be easily explained, such as the final scene when the Takumi and his family watch the car’s escape via a TV news channel. At times, it seems as if the AI treats human habits with cynicism, amplifying the story’s emotion with devices such as disaster, tears and the bond between parents and children. Most surprisingly, the car is given sentience and emotional depth.

"When we first heard the script, we felt a bit uncomfortable because it’s a very unusual story," Meulemans says. "But we really decided to play the game and be faithful to that. You can’t embrace such an idea and not follow it to the end."

Part of the client’s discomfort lay in the fact that the ad does not immediately identify the brand, while Lexus is striving for higher brand awareness. Vincent Tabel, Lexus Europe’s senior brand and communications manager, adds: "It’s good to feel uncomfortable, because it’s challenging you. It’s good to have a chance to look at things differently."

Macdonald, who has never before worked with AI, also stepped outside his comfort zone. He originally agreed just to film a documentary about the making of the Lexus campaign, but when he read the finished script, he wanted to shoot the ad itself.

The nature of this project meant that Macdonald had to set aside his director’s ego, never veering far from the AI’s intent. He sees the AI as his "silent partner" and consulted it more closely than the agency, he says.

Yet Macdonald still brought his unique perspective to the film’s treatment. The ad is shot from the car’s point of view, with echoes of the Frankenstein tale – "a creature created by a mad scientist and then tortured until it finds freedom", he explains.

"Then the car resists. It’s Russell Crowe [in the film Gladiator] standing up to the Emperor," he continues. "The best parallel is [the film] Ex Machina. It’s the poignancy of being a creature that’s not quite alive but pretending to be."

Like Frankenstein’s monster, this story poses the dilemma: is the semi-alive creature meant to be feared or sympathised with? It could be believed that the AI author is asking this question of itself. In Lexus’ experiment, each participant has come to their own conclusion.

Visual Voice warns people not to read too much into the AI’s appearance of autonomy. It would be easy to attribute the surprising aspects of Lexus’ ad to a spooky, "underlying magical aspect of AI", Nutbrown says, but there is no deeper meaning other than the AI achieved what it was trained to do.

"What becomes important is what data we give to the machines. The danger in other areas is where AI is fed unreliable information," Nutbrown says. "If the information contains racial bias, for example, then that machine could start to convey those biases."

In this way, training AI is similar to raising children. Many people believe their intuition is innate and inherently good, but it is actually something that is taught by experience, according to researchers such as MindX.

Nutbrown gives the example of a person who has often climbed a roof with an unsecured ladder and never fallen, who consequently believes that this wobbly process will be safe the next time. In this case, their intuition is faulty; their learned experience could guide them to a dangerous outcome. Different information can build stronger intuition, in the same way that it can feed AI.

"In the same way we bring up our children, there is definitely a responsibility in how we teach machines going forward, to ensure we don’t put our own faults into the technology," Nutbrown says.

Visual Voice maintains that its AI platform for the Lexus ad was better trained, but the jury is out as to whether it achieved the same level of creativity as a human. "AI lacks at the moment because it doesn’t have that knowledge of the wider human condition," Nutbrown says. "Our general finding was that the role for a creative human being is not particularly under threat."

We like to flatter ourselves that we have a couple of unique qualities that separate us from machines. I'm not so sure that's true

Bedwood, too, is optimistic. In his utopian view, humans and machines will work closely together, with AI taking care of mundane and routine tasks so that people can focus solely on being more creative.

"I want AI to be a liberator of human creativity. I don’t want data to be a straitjacket," he says.

Lexus shares this outlook. At the same time as it is striving to be at the cutting edge of technology, the company is returning to its origins, promoting the human craftsmanship behind the car’s design. In the future, brands must find a balance between both, as people crave innovation as much as genuine human connection, Tabel says.

"Expectations rise with new technology, but we have to keep real relationships too," he adds.

But it is Macdonald, perhaps the biggest visionary on this project, who foresees darkness. After directing this script, he has converted to the belief that it will be possible for AI to imitate human creativity.

"We like to flatter ourselves that we have a couple of unique qualities that separate us from machines, including creativity. I’m not so sure that’s true," he says. "I’ve got three kids, and I’m worried for them. If I were a screenwriter or copywriter, I’d be worried about my job. We’re on the cusp of huge changes to the world and our place in it. There’s going to be a revolution."

That revolution hasn’t arrived yet. For now, Macdonald and his crew still have work to do. He returns to set and peers through the camera’s lens.