This Small Corner

Eric Koyanagi's tech blog. At least it's free!

Engineering with AI 5: Using Generative AI to Write a Story

By Eric Koyanagi
Posted on

Based on everything we've learned so far, let's try to leverage AI to do something...well, maybe a bit controversial. We'll use it to create a sci-fi themed short story about AI, exploring some of the darker threads of how deep learning networks might impact society. Nothing says "duality" like using AI to write a story that paints a grim future of the AI-fueled future. The story should be at least 2,500 words. To be clear, we are going to have to do some of our own writing, both in massaging the output and in how we author the prompting.

The Short Premise

We're going to try to keep things somewhat simple as we are aiming for a short story. The protagonist works for a political consultancy firm, specifically to help create AI-generated videos sold to political campaigns. This allows candidates to be shown in the most mathematically ideal perspectives, at least based on the reactions of ten thousand virtual viewers carefully engineered to measure the effectiveness of each ad, much in the same way polling works in today's world.

A test video somehow leaks from the protagonist's system, seeming to show a violent attack that leads to rapid threats about war.

Look, this isn't going to be the most clever premise, but it should make for a good enough concept to create a short story.

And yes, we do need to have a story in mind if we want to use GPT4 to write something. It's sort of impossible to imagine a scenario where you'd want any LLM to "author a plot" -- no, that will always be human-authored. The goal here isn't to have the LLM write the plot, it's to have it create a plausible "work" when spoon-fed prompts as carefully as we can.

But...why?

I'm not a believer at all in the idea of AI replacing creatives. I don't think authoring entire movies is a reasonable choice for people lured by the "magic" of Sora, for example. While AI image generators are really neat (as I explored here), they can't make art, I don't think, because art is something inherently human. It's about expression, not just pixels. I'm not sure it's a great idea to apply AI to creative pursuits like writing stories, so why am I doing it?

First, because it's an interesting challenge in researching how LLMs work and how to use them. When dealing with large works like short stories or novels, the context window becomes a lot more important if you want consistency. We can explore that a bit with this test.

Second, because there's a lot of survivor bias when it comes to AI implementations, today. Well, I suppose it's the opposite: failure bias. We see hilarious stories of AI-generated garbage and it (honestly) makes us all feel a bit better. We can relax, AI is still stupid and it won't be coming for anyone's job or churning out screenplays anytime soon....right?

The problem with this form of cognitive bias is that it ignores everyone that is deploying AI content successfully, often without disclosing it or being detected. If we focus only on the failures, we might get the impression that AI's are just as much hype as NFTs. Conversely, focusing only on the new developments or promises about emergence from AI marketers creates the opposite impression that AI is far smarter than humans, already...which is obviously not true.

I think it's worth exploring this project if only to ask questions about how we ought to value creativity. Do we cherish original works of art as important facets of our culture that distill the nature of our human struggles....or do we commodify it, using AI to build large bridges between tiny islands of original thought? Of course we'll commodify the shit out of it. I mean, let's just be honest.

We've always faced this duality with media. Anyone that's seen one of the six-thousand Fast and Furious movies knows that we started commodifying art a long, long time ago and AI doesn't change that, but it might make it much easier.

The Process

Obviously we can't just ask ChatGPT to create a short story by feeding in this level of detail. If we do, the output will be as bad as expected. There's also a very, very big difference between GPT 3.5 and 4 in the style of the output. I had the best luck when I was explicit about the plot mechanics: I told it to expand on the prompt given, but not to invent new plot points. The goal is to drive 2-3 paragraphs of content with 2-3 sentences of input (often longer).

There's not a lot more to say about the process other than that. To be clear, some of this text I will edit heavily, so it isn't just a copy/paste exercise...but the vast majority will be "authored" by GPT.

Because there will be a lot of text following with this story, I will summarize a few things I learned:

  • You can (likely) coerce GPT to use "made up" words like "autotaxi" with the right prompt, useful for something like a story where authors often invent nouns
  • GPT4 especially can be...heavy handed. I often had to dial things down -- because it "knows" it's trying to write a story, it likes to be more colorful, sometimes to the point of distraction
  • The more you can "suggest", the better, including specific metaphors you think it should employ or dialog it should use. Writing with AI doesn't mean AI does all the writing.
  • Sometimes it really does pick a funny way to describe things, like describing a phone as a "portable computer device". It can also get obsessive about sci-fi terms. No, the phone doesn't need antigrav glass. It also creates some odd phrases that work, but in a very corny way, like "the sting of humble pie scorching his tongue". Uh, okay?
  • Dialog is tricky -- it prefers to write descriptive text over dialog, although I expect dialog could be tuned a lot more with more specific prompting.
  • The longer you go, the more difficult it will be, which to be fair is true of any story in general no matter how it's created. You'll see more inconsistencies because the AI has poor "memory" as text moves out of the context window. Even this story at only around 3,000 words begins to stretch its ability to stay consistent.
  • The AI sometimes takes a tone that doesn't entirely match the plot, lending "sympathy" to ideas it shouldn't
  • Rarely, the AI will massively misspell a normal word, like "ruthciless" instead of "ruthless" -- that's the magic of the LLM's stochastic model and internet scale data, baby!

The Story

Jolted awake by the gentle sing-song trill of the autotaxi, Caleb blinked open bleary eyes as the autopilot courteously informed him the vehicle had pulled up at his destination. The windows projected hologram alabaster landscapes draped in ivy, swimming in more life than he imagined possible. Wistful, he squinted as the high-tech window panes instantly shifted, the utopian imagery they once held melting away like liquid gold, replaced with a gritty, harsh reflection of the industrial city beyond.


His heart sank at the sight, which, despite his daily passage, never lacked shock value. A dystopian patchwork quilt of desolation and desperation stretched out before him - buildings bearing skeletal remains of a once-active metropolis now adorned with graffiti and veiled in grime. An unending river of makeshift tents, a depressing mishmash of tarps, old billboards, and scavenged materials became homes to the city's forgotten citizens. Yet still, the politicians quibbled over increasing the basic income, swearing it would lead to the doom of society, as if they hadn't stepped outside in years.


To escape the prying eyes of the disenfranchised, Caleb hurried through the overbearing bronze doors of his office - a sanctum of towering glass and polished steel - protected by the promise of opulence. He moved quickly, past the Art Deco water feature, up the glimmering escalators running like veins through the belly of the corporate titan. As soon as he reached the gilded lobby, the security staff greeted him by name, their sleek uniforms crisply set against a backdrop of golden marble and high tech gadgetry. But the emptiness in their smiles felt no different than the desolation outside, reminding Caleb that this gleaming fortress his employer had built did not stand for refuge; it was a mirage, not altogether disconnected from the desolate streets he so wished to ignore.


Caleb’s workspace was a combination of the mundane and the futuristic; he sat amidst a cascade of large, hovering screens that were scattered around him like holographic planets in orbit. The incessant flicker of the feeding data flowing from PoliBot kept his otherwise dimly lit room bathed in a haunting glow. The videos PoliBot churned out were unnervingly lifelike, each digital persona intricately crafted down to the very last pixel, moving and emoting with an eerie flawlessness that was only achievable through decades of tireless machine learning. Each generated video was a masterpiece, a terrifyingly accurate doppelganger of reality.


In the evolving world of political warfare, PoliBot was a game-changer. With a cold, calculating precision, the AI studied video content and dissected every subtle inflection, every play of expression, every nuanced gesture of a political candidate and trained it against tens of thousands of digital avatars tuned to represent the vast majority of the electorate. The result was an astounding amalgamation of visuals and dialogues that could uplift a candidate's standing, or ruthlessly tarnish an opponent’s reputation. The computer-rendered visuals donned the skin of reality, so convincingly, they left no room for the human eye to discern the fabrication.


The old world politicians spun narratives and perceptions through eloquent speeches and charismatic debates. But in Caleb's brave new world, the art of persuasion had transformed into a technology of mass manipulation. Political campaigns were no longer broad pathetic attempts at casting nets, hoping to sway a few undecided voters. In the hands of those who could wield its power, Polibot turned them into meticulous, strategic missiles armed with algorithms of influence, launched with clinical precision to detonate within the psyche of the masses. Like a bomb lobbed into an ocean teeming with life, it spared no one. The era of nonchalantly throwing bait was over, and the age of deep-sea hunting had begun.


After eight-odd hours of monotony, Caleb fled, ignoring the security guards and their empty smiles and collapsing into another autotaxi. The taxi was like a fish in a river of metallic vehicular sea creatures, each carrying memories of weary-eyed employees eager to dissolve into the elusive comforts of their homes. Sometimes Caleb wondered what secrets those countless lights had to live with; everyone with the fortune to have a job had some burden to bear like him.


His home was a silver-steel-and-glass homage to minimalistic corporatacracy: dapper, sterile, devoid of warmth. A tiny kingdom nestled high in the metal embrace of the city where everything had its place and there was a place for everything. It was his compensation for his role in the high-octane corporate world, a generous gift from his employer - a gilded cage easily mistaken for a castle. He shed his heavy coat and scanned his retina to access the condo, his condo, and sighed, the sigh of a knight returning to his fortress after a grueling battle.


As he settled onto his streamlined microfiber couch, fatigue singing in the grooves of his cheekbones, Caleb drew out his phone from his pocket. The small square of glass, pulsing with translucent blue light, hovered elegantly above his fingers. His thumb hovered above his contact list; perhaps an old friend might shake off this sense of debilitation. A banner of news headlines flickered into view on the edge of his screen and halted his thoughts.


Caleb's eyes remained glued to the gleaming screen of his phone, the relentless mechanical glow reflecting a stormy expression as he watched the rather damning evidence play out once more. Any doubt eroded with each play-through. It was a test video authored from his own machine, a fiction now erupting across the news.


"Well, shit." His voice was a lost echo in the room, devoid of any reverberating warmth, swallowed up by the towering canyons of rusted metal electronics and half-finished robotic components that carpeted every inch of his unit.


"I'm truly fucked," he muttered to the room. His mind raced and crashed against the icy walls of panic like a desperate moth fluttering in a jar, seeking an exit that did not exist.


The synthetic stream played out with chilling sophistication. Hyper-realistic virtual missiles exploded against pixelated American defences, visible in high definition on his slick, glass monitor. A PoliBot creation, it was a malevolent orchestration masterfully manipulating the vulnerable network of trust. His heart pounded as he watched the digital carnage, barely able to comprehend the implications.


The clamour of politicians, amplified by the relentless swarm of social media buzz, was growing louder with every minute that passed. The bloodlust was building, goaded on by the all too realistic video, their perceived enemy now brought to vivid, horrifying life. They were all calling for a reaction, for retribution. The blood depicted in his test video hadn't even dried, and already, they were screaming for more.


As Caleb sat there, dizzy amidst the chaos, a grim realization dawned on him. He had engineered this unintended incitement. He never thought his test would act as a catalyst for carnage. His hands trembled as he reached for his phone. He had to call his boss, Anya. He had to own up to his mistake. His heart pounded in his chest; his future, and possibly the world's peace, hanging in the balance of that single phone call.


Anya answered the call quickly, her green eyes narrowed, confused by the unexpected call. She was still at the office, neon leaking into the sterile space, almost daring to touch her boring office with a splash of color.


"Hello," she said curtly, the syllable clipped and professional, echoing slightly through speaker's grille.


"Anya, we have a problem," boomed Caleb's voice. His brief hesitation filled the silence before he finally blurted out. "Have you seen the news?! The attack? I don't know how it got out...but it's a test video. We need... someone should...” His voice trailed off in uncertainty.


Anya tilted her head, thoughtful. Her silvery green eyes narrowed into slits, the cold Arctic sea captured in their depths. Caleb could almost imagine her cool gaze over the line, always appraising, dissecting the situation with terrifying clarity. "Caleb," she said, her voice as calm as a glassy lake, balancing the rising waves of panic on the other end of the line. "Calm down. We'll meet first thing tomorrow to discuss this. Until then, you are bound by the strictest NDA on the planet to keep this to yourself," Anya concluded firmly, stamping out the faintest trace of panic with an air of unshakeable resolve.


The harsh glow of the TV screen was the only light source that pierced through the heavy gloom of his apartment, the dark shadows cast stark motives of panic onto the walls. The low, persistent hum of the news anchors filled the otherwise silent room, their voices no longer comforting but rather, chilling. Politicians, faces filled with feigned concern, hurled daunting words through the speakers at an already frightened public. The threat of an unsaid draft was felt in the air, interlaced with the sweet scent of "patriotism" that'd always been part of his country's DNA. It was like the perfect grim tango dance, terrifyingly beautiful, only Caleb wished he couldn't see the choreography.


Under the pale hue of the still-set moon, Caleb carried his tired body down his condo tower and waited for another taxi. Despite patches of artificial intelligence embedded in the city's design that dutifully swept the streets and collected refuse, an eerie silence hung heavy in the pre-dawn hours. He barely flinched at the summons materializing in his inbox nearly the moment he collapsed into his desk. Of course Anya was already at work.


He met the stoic gaze of his boss, Anya, from behind the warps of her multi-layered titanium desk. Illuminated by the clinical bluish hue of her wall-to-wall holoscreen, she wore an expression of uneasy calmness, her sharp features uncharacteristically dulled by worry. She unfolded a digital readout, the room filling with projected images of a troublesome video that had become a viral wildfire on 'E-Galaxy', the ubiquitous news network.


"You've got it wrong, Caleb," Anya said flatly, thrusting the video tablet back across her sleek metal desk towards him. She pushed her angular eyeglasses back up the bridge of her nose, her piercing gaze settling unnervingly on him. "This video isn't from us. It's real."


Caleb blinked, hand still outstretched over the tablet, his bushy brows climbing higher on his tired face. The neon glow from the hologram cast an eerie, shifting light upon his confused expression. He pushed out words like an old truck puffing smoke, insisting, "I'm not wrong, 'mam. I can find the raw –"


"Listen, Caleb," Anya interrupted him sternly, her gaze razor-sharp. She leaned back in her high-back obsidian chair, her face half cloaked in the dim, ambient lighting of her office. Her voice was filled with menace and warning, "You need to focus on doing your job. You signed an NDA, remember? And violating it... well, you know the consequences. Just be a team player, here, and everything will be fine."


Red warning lights sparked in his mind, as the threat hung heavy in the dense silence between them. Nodding stiffly, Caleb took a deep breath as he lifted up the tablet, the weight of an entire war appearing to settle squarely onto his shoulders. The threat from Anya became a static white noise in his ears. All he could imagine were the mountains of broken bodies, the heavy booms of gunfire ripping innocent people apart because of his video.


He pondered upon the gravity of violating his Non-Disclosure Agreement. In an age where privacy was reduced to an old-fashioned concept, breaking such a contract was akin to social suicide. The consequence was certain - a swift and unceremonious termination of his blue-chip career, his privileges revoked, his name scrubbed off from the employee list within nanoseconds. Left to join the countless outcasts of society, the evicted who sought asylum in the patchwork of rusty tents pitched in the shadow of the mammoth, gleaming monoliths of the metropolis. The cold whisper of uncertainty niggled in the back of his mind like a icy breeze. He could do what he was told, letting the consequences flow past him like a raging river, and do it with utter impunity.


The artificial glow of computer screens bounced off the steel corridors as he shuffled back to his workstation. His heart pounded with trepidation, droning a melancholic beat in his ears as he slid back into the cold, rigid chair. Pulling up the video, he cast a fleeting gaze on the gruesome tableau. It was a grisly scene sprouted from the seeds of a fabricated bitter lie, every pixel an orchestrated symphony of deceit. His stomach knotted, eyes squinted in revulsion against the vehement unreality of the digital travesty he had unwillingly birthed.


His fingers danced over the keyboard, conjuring commands to unravel the falsehood. A few clicks and clacks and the scene morphed into a transparent matrix of digitized artistry, exposing the bones of its digital architecture. The brutality dissolved into an ensemble of complex algorithms, flows of multicolored data streams intertwining like a Jackson Pollock on overdrive. Each abstract shape, each point of intense color acting as a steadfast reminder of the synthetic fraudulence documented.


Caleb stepped once again into Anya's imposingly austere glass and steel office, summoned minutes later, as the virulent echoes of the news started to ripple through the intricate structures of their organization.


Determination sparkled in her steely gaze as she elucidated the depth of his impending downfall—termination, legal battles, and criminal prosecution that left no room for a normal life expectancy. Yet, against such bleak allegations, his reaction was quite the paradox. He greeted her threats with an almost serene smile. His tranquil grin oddly mirrored her ruthless stare.


Barely above a whisper, he responded, his voice floating into the tense atmosphere like a rogue comet, free from the gravitational pull of public opinion.


"It was worth it," he affirmed, resonating with a pulsating sense of the inevitable. "Someone had to stop the video before it caused a war. People would have died because of this."


You naive fool," she declares, her tone brimming with the bitter taste of reality. "Don't you get it, yet?" She continued, her voice sinking into a low whisper, as if the very walls around them might be eavesdropping. "No one cares about the truth, it's too much work. Fake or not, the war is inevitable at this point. It's too late."


"What...?"


"You ruined your whole life for nothing," She spat, acid swimming in her low voice, "You betrayed this company for nothing. The video might be fake, but the emotions it stirred are very real, and people care a lot more about that than some abstract idea like truth. PoliBot didn't start this war, if it helps you sleep at night in your cell or your tent or wherever it is lowlifes like you end up. If it wasn't us, it would have been a mess of advertisements or social media posts. This isn't a new game, Caleb. We just happen to be very, very good at it."


"But -"


Caleb didn't have time to reply. Anya nodded at the pair of security guards hovering outside her office like drones. Caleb stumbled as the guards' viselike grips pushed him forward. His gaze flickered between them, their faces a cold, emotionless mask.


As soon as the cold touch of the harsh metallic door pushed against his back, he found himself falling onto the hard asphalt. His ears resonated with the gravitational echo of the towering glass monolithic building overshadowing him. A unique fusion of both polished granite and ultra high-strength glass, it was a symbol of gargantuan power, every inch a reminder of the conglomerate's reach and command. 


The LED screen on his phone illuminated, casting a harsh light onto his stricken face as he read the words cut colder than the brisk wind, 'Eviction Notice: Termination Effective Immediately.' His heart pounded in his chest as the reality of his predicament sank in. His employer-paid apartment had been more than just a home; it was a symbol of his achievements, of his success in a world drowning in inequity. Life, as he had known, unraveled within the blink of an eye.


In the end, Anya was right. The pseudo-experts, their clean-shaven faces practically gleaming under the studio lights, rushed to defend their leaders, all solemnly opining that the video was an original, untampered piece of evidence. 


The news cycle churned and shifted its focus, the way a shark always swims towards the scent of fresher blood. The War was more urgent, more critical, and most importantly, more sensational. The banners of victory painted a grand narrative, a tale of patriotic dedication and military might. The public's attention quickly shifted. The video that started the war no longer mattered, a forgotten relic lost in a river overflowing with propaganda.


Caleb spent his final days in the sun, basking in soothing, simple warmth, trusting only in the truth of his skin against the sun, strangely free of regret for the first time in his adult life.

« Back to Article List
Written By
Eric Koyanagi

I've been a software engineer for over 15 years, working in both startups and established companies in a range of industries from manufacturing to adtech to e-commerce. Although I love making software, I also enjoy playing video games (especially with my husband) and writing articles.

Article Home | My Portfolio | My LinkedIn
© All Rights Reserved