Neural narratives in Python #7

I recommend you to check out the previous parts if you don’t know what this “neural narratives” thing is about. In short, I wrote in Python a system to have multi-character conversations with large language models (like Llama 3.1), in which the characters are isolated in terms of memories and bios, so no leakage to other participants like in Mantella. Here’s the GitHub repo.

Last time, I managed to nail creating voice lines for the dialogues of my app, relying on a RunPod server dedicated to generating audio. Now I want to go on a serious test run of app to see what it lacks.

Starting from scratch, I created a new world, a new region of that world, a new area of that region, and a new location of that area. I won’t detail the specifics, because the app itself should do it like a story would do, so if in the course of testing the system I feel that something must be implemented to cover for the shortcomings, I will do so.

The process of creating a new playthrough requires you to provide some notion of the character you want to play as. I ended up with a good depiction of the guy.

I have the initial setting and the player character (including his automatically assigned voice model). A story needs other characters, so I went to the section that shows the character creation guidelines that have been generated for this combination of places.

I turned them into post-its. Anyway, my protagonist is a police detective, so he could do with a partner. I grabbed the second guideline and made her a woman.

The app doesn’t allow you to access most of the specific data of a character except in very paricular circumstances, so in general, you have to glean the specifics of a character from their looks and the conversations you have with them.

In a story, you need some sense of where you are. There’s a system in place for the LLM to generate a description from the first-person perspective of the player character, and at this point it’s trivial to generate a voice line for it:

Let’s interact with the sole other character around (for now). As I was running a conversation with the protagonist’s partner, I ran across the first issue: when the app had to generate a voice line for a bit of ambient text, the server (the RunPod pod) returned a 404. I guess that even if a pod is technically running, it could intermittently produce 404 errors for whatever reason. I guess I’ll need to program in some retry system to cover these cases.

I did do that. Let’s continue.

The “stop your a coffee” was my blunder. Old, stupid fingers.

The couple of grizzled detectives exited the police station, back to the grim city surrounding it.

Now I want my characters to move to the mentioned location, some bar. Even though I didn’t create any other locations for this run other than the police station, there is a lingering issue with the interface: when plenty of possible locations exist, if you press the button “Search for location,” it may link locations you don’t want (like a cave, a hospital, etc.). Now that I was looking specifically for a bar, I figured that I may as well fix this issue.

It took quite a while, but now the user can only search locations by a type. In fact, if no locations are available, because they have already been used or they don’t match the area’s categories (you don’t want a fantasy bar in a cosmic horror story), the select and the button will be disabled.

Well, that was all for today. I expected to do more, but reworking that interface was arduous.

Neural narratives in Python #6

I recommend you to check out the previous parts if you don’t know what this “neural narratives” thing is about. In short, I wrote in Python a system to have multi-character conversations with large language models (like Llama 3.1), in which the characters are isolated in terms of memories and bios, so no leakage to other participants like in Mantella. Here’s the GitHub repo.

In the previous entry, I came up with the notion of producing audio voice lines for the conversations. Mantella had spoiled me in that regard: hearing those fictional characters answering you in reasonably good voices while you stared at them did wonders for immersion. And it was a bad idea to shove that possibility into my mind, because it prevented me from sleeping last night. Instead, I moved to my desk at three in the morning and started implementing it. Now, every generated character gets assigned a voice model according to their peculiarities, and each speech turn produces voice lines that the user can play through clicking the speech bubbles. It works perfectly.

I learned that it’s a terrible idea to play audio server-side, because it crashes the server. Flask, the web framework that my app is programmed in, or maybe it happens in all web systems, also doesn’t allow the client to access any file in the server, so I had to move all the audio-playing logic to Javascript.

Given this example chat I had with a new character, who had been assigned a matching voice automatically among the relatively few I’ve introduced into the system so far:

The short convo produced this audio exchange:

Like in the original Mantella system, the quality of voice models varies greatly; sometimes they sound like theater students reading a script, recorded on a home mic. Also, the process of generating the clips sometimes shears the very end of their final sentence. Still, I can hardly complain. Listening to the characters adds so much life to the conversations you can have through this app that I see myself enjoying it for a long time to come (and not only for smut).

I’m amazed that I got this running. So, how did it happen?

In the beginning, I thought that setting up my own, local XTTS server (XTTS being a model for generating voice lines) was a good idea. I struggled through every step of the way for a few hours, fighting against obscure documentation, until I finally managed to generate a sample voice line, only to find out that it sounded like ass. Why, I have no idea. So I discarded that notion and instead I looked into Mantella’s codebase, which is up at GitHub, to see how they connected to the RunPod pods to request voice generation. RunPod is a sort of online renting system of computer and server time: you can set up a pre-configured little server that all it does is generate voice lines, and as long as you can connect to it, you’re set. Only costs seventeen cents an hour, too. Once I managed to query the list of available voice models from the RunPod pod, I knew I was going to get through this thing.

So, I had a list of all possible voice models I could rely on, and it turned out to be about five hundred fifty. They are trained from game voices, so there’s a whole breadth of possible voices one can use. How to classify them? Should I create a page on my site with a simple select box, letting the user (meaning me) scroll through a list that long?

ChatGPT, even its latest Orion preview version, clarified that it knows of no online service that could classify the more than five hundred voice samples I had produced from those voice models. I would have to do it manually, but in the beginning it would be enough with having introduced twenty or so models into the system. What tags can be applied to a voice? I relied on ChatGPT to figure that out. Now that I have that list, classifying each voice model is as easy, but time consuming, as listening to that sample on a loop while adding appropriate tags. I have ended up, so far, with the following JSON file of voice models:

{
  "npcmmel": [
    "MALE",
    "ADULT",
    "CONFIDENT",
    "STEADY",
    "SMOOTH",
    "CLEAR",
    "FORMAL",
    "CHARMING",
    "NO SPECIAL EFFECTS"
  ],
  "npcmlucasmiller": [
    "MALE",
    "ADULT",
    "CALM",
    "FAST-PACED",
    "SMOOTH",
    "CASUAL",
    "KIND",
    "NO SPECIAL EFFECTS"
  ],
  "robotmsnanny": [
    "FEMALE",
    "YOUNG ADULT",
    "STEADY",
    "WARM",
    "CASUAL",
    "MELODIC",
    "YOUTHFUL",
    "NO SPECIAL EFFECTS"
  ],
  "npcma951": [
    "MALE",
    "ADULT",
    "ANXIOUS",
    "SLOW",
    "AIRY",
    "SKEPTICAL",
    "NO SPECIAL EFFECTS"
  ],
  "npcfphyllisdaily": [
    "FEMALE",
    "ADULT",
    "STOIC",
    "SLOW",
    "MONOTONE",
    "INSTRUCTIONAL",
    "CALCULATING",
    "NO SPECIAL EFFECTS"
  ],
  "femalechild": [
    "FEMALE",
    "CHILDLIKE",
    "PLAYFUL",
    "STEADY",
    "AIRY",
    "MELODIC",
    "INNOCENT",
    "NO SPECIAL EFFECTS"
  ],
  "femaleyoungeager": [
    "FEMALE",
    "YOUNG ADULT",
    "HOPEFUL",
    "FAST-PACED",
    "CLEAR",
    "INTENSE",
    "OPTIMISTIC",
    "NO SPECIAL EFFECTS"
  ],
  "femalevampire": [
    "FEMALE",
    "MIDDLE-AGED",
    "ARROGANT",
    "STEADY",
    "SMOOTH",
    "AUTHORITATIVE",
    "CYNICAL",
    "NO SPECIAL EFFECTS"
  ],
  "femalekhajiit": [
    "FEMALE",
    "ADULT",
    "CALM",
    "STEADY",
    "GRAVELLY",
    "CASUAL",
    "PHILOSOPHICAL",
    "NO SPECIAL EFFECTS"
  ],
  "femaleuniqueghost": [
    "FEMALE",
    "YOUNG ADULT",
    "RESIGNED",
    "STEADY",
    "ETHEREAL",
    "MELODIC",
    "INNOCENT",
    "GHOSTLY"
  ],
  "femaleghoul": [
    "FEMALE",
    "ADULT",
    "MENACING",
    "STEADY",
    "RASPY",
    "INTENSE",
    "ENERGETIC",
    "NO SPECIAL EFFECTS"
  ],
  "femaleboston": [
    "FEMALE",
    "ADULT",
    "CALM",
    "DRAWLING",
    "SOFT-SPOKEN",
    "WARM",
    "FLIRTATIOUS",
    "SULTRY",
    "NO SPECIAL EFFECTS"
  ]
}

I wrote a function that narrows down the list of possible categories of tags: gender, age, emotion, tempo, volume, texture, style, personality, and special effects. If at some point there’s no matching voice models, it returns a random one from the previous filtering. I’ll probably program in the characters section of the site a simple button that redoes the process for any existing character, in case any other random fitting voice may work better.

That’s all, I guess. When I first got the idea about programming this conversation system with characters controlled by large language models, I knew that programming the multi-char convos would be the most difficult thing. The second most difficult thing that I pictured was actually making them talk out loud. No idea what big thing could be coming next. Anyway, back to the brothel.

EDIT: here’s a multi-char convo in audiobook form.

Neural narratives in Python #5

I recommend you to check out the previous parts if you don’t know what this “neural narratives” thing is about. In short, I wrote in Python a system to have multi-character conversations with large language models (like Llama 3.1), in which the characters are isolated in terms of memories and bios, so no leakage to other participants like in Mantella. Here’s the GitHub repo.

Today I’ve been busy fully redesigning my web app, now that it includes plenty of interesting features.

Index page:

What it allows you to do is pretty self-explanatory, which is good. The relationship between the places is World > Region > Area > Location, and each of them have specific behavior in-game.

Story hub:

This one requires some explanation: at any point, the user can demand the system to generate story concepts, interesting situations, and interesting dilemmas. The large language model (the AI) will take into account all the info about the character, his or her followers, and their memories, to generate concepts, interesting situations and dilemmas that may fit what’s been going on.

Here are some examples of the interesting dilemmas the system can generate. Each “post-it” can be removed by just clicking on it. And now that I think about it, maybe I should make them yellow too.

Characters hub:

The player character front and center. The character images are generated by courtesy of an OpenAI model, that is provided a special prompt crafted from the character’s information.

Character generation:

Originally I told the AI to generate whatever characters it pleased based on the world, region, area and possibly location, but it ended up creating very similar characters: for example, in a police station, it would create a succession of serious detectives. So I programmed an intermediate step in which the AI creates character generation guidelines focused on coming up with a breadth of possible characters for that place. Of course, it also respects genre.

Character memories:

After each chat (and some other activities), a summary is created of what just took place, and is stored in the memories of all the participants. Those memories are loaded in most activities, and they color the characters’ dialogues and decisions. You can also generate self-reflections: the character, according to their personality, meditates upon their experiences, and writes a sort of journal entry about it, that goes into their memories to color their behavior and dialogue further. And of course, they can self-reflect about their self-reflections.

Location hub:

Lots of stuff to do on this page: generate a description of the place, find a new location among the existing ones matching the genre, visit found locations, and travel to other areas. You can also pick up followers here, or dismiss them.

The page for goal resolution is relatively simple so far, and I developed it just this morning, but it does something quite interesting: given a goal, you ask the large language model to write a narrative of the attempt to fulfill that goal, to decide whether or not the goal was achieved, and then a paragraph or two of the resolution, which gets saved as a memory.

This came about when the owner of a brothel, a succubus, suggested that I should travel to some nearby caves in search of treasure. That sounded interesting, but I would have needed to roleplay the entire thing through dialogues, including the possible obstacles found along the way. So I programmed in a system that figures it out by itself. In the future, I will probably program in a system to resolve explicit confrontations between characters or some opponent, like a bunch of wolves or something.

Now for the meat of this stuff, the chat system:

At any place, the user can choose to chat with any combination of characters present at the location, from those loitering around to the player’s followers. Multi-char convos is the first thing I made sure to program properly.

Chat:

All the NPCs speak in character, according to their personal info, their memories, and the ongoing conversation. There’s no leakage of information from other characters, because personal memories aren’t shared. If it weren’t because the calls to the LLM can be slow according to the whims of those servers, I would call the current system perfect.

So, what’s in the future? I plan on programming a system to generate goals, like it generates concepts, interesting dilemmas and interesting situations. Those goals will be loaded in a page, in case you want to attempt at resolving them. I also want to program in a way of swapping player characters easily. To deepen the simulation, I also want to include the notion of character health, and some way of altering the characters’ equipment and health after the actions have been resolved. At some point, I may rely on some local audio-generation server like XTTS to generate voices for each NPC utterance. That would be cool.

This whole thing has been a lot of fun. If I didn’t gravitate so much toward using it to engage in smut, I would have probably posted plenty of the stuff I’ve produced through the system.

EDIT: I fed this post to the Deep Dive pair, and they produced the following podcast (AI-generated):

Song “Schizosaurus Rex” (Paisley Underground version) from Odes to My Triceratops, Vol. 4

In case you don’t know, this year I’ve been exploiting the amazing AI service Udio to produce songs. I’ve already made and released two full albums based on a strange story I wrote back in 2021, named Odes to My Triceratops. It follows the adventures and misadventures of a trio of friends who live in a town lost in the map. The main dude is a songwriter named William Griffin, who’s passionate and sensitive, if a bit unhinged. Another character is William’s next-door neighbor Claire Javernick, a blind redhead. Then we have Lorenzo, who’s a sentient triceratops for no justifiable reason. You can download the first two albums of this story through this link.

So yeah, a fresh new song directly to your ears, this one in the style of the relatively obscure Paisley Underground movement, which is a sort of garage psychedelic rock with a Californian vibe. I’m very fond of how this tune turned out.

Lyrics below:

A beast from the deep,
The monster under your bed.
Eyes red like the setting sun,
Claws the size and weight
Of a heavy human soul.
It can’t die; it only transforms.
It can’t be stopped,
Unless it decides to stop.

I have a portal to hell inside my throat.
It hurts, but I’m getting used to the pain.
Still, I don’t know whom I hate more:
The world, or myself.

This isn’t the story of how I died.
This is the story of how I met a girl,
We fell in love, and she betrayed me.
She didn’t do it on purpose;
She was just a dumb kid.
Besides, the darkness drove her crazy,
Almost as crazy as me.

I ain’t a poet, couldn’t hope to be,
But I’m the only person left:
A castaway in a plastic kayak,
Drifting down the River Styx
Past skeletons clinging to rocks,
Reaching out for a bite to eat.

You and I, love, we shared our lives,
We did the best we could,
But the best we could
Was a steaming pile of dogshit.

Someday I’ll make it to that faraway shore
Where eagles soar on golden wings.
There, I’ll sit and rest in my blue suit.
I’ll watch as time goes by,
Not aging a day, not losing a thing.
The memories will blur and fade
Until all I have left is me.

EDIT: I fed this post to the Google AI thing that generates podcasts out of your material. Yes, I’m writing the lyrics, you guys (who are by the way unaware of the fact that they’re AIs themselves). Check it out.

We’re Fucked, Pt. 127 (Fiction)

After an hiatus of nine months, mostly so I could tell the story of a motocross legend, my ongoing story, as long as a trilogy of novels, has returned. I wouldn’t blame if you if you’ve forgotten all about it. You can read any of its chapters on here, or listen to the existing audiochapters on here. I won’t continue producing audiochapters, though, because I have my fingers in too many pies. Anyway, let’s get rolling.


In the tomblike blackness, as if I were descending into the bowels of the earth, I keep inhaling oxygen to sustain the biological machinery of my aging body, even though every breath fills my throat and lungs with the stench of ammonia and rotten meat, a stink so overwhelming that it could knock out a woolly mammoth.

A click of a switch, followed by a whirring and the faint whooshing of air. With a buzz, fluorescent bulbs flare to life, bathing the subterranean lair in a bright glow.

“Here’s why I’m constantly up to my neck in bills,” my boss says.

At the center of the square-shaped room sits a hulking mass of metal: a shiny aluminum cylinder. No, not a cylinder, because a person-wide opening curves into the device, a path blocked now by an orange gate barrier that may have been pilfered from the streets. From the top of the machine grows a cluster of industrial piping, electrical wiring, and conduits resembling the ruptured guts of a mechanical beast.

A vibration disturbs the air like a low-frequency hum. From the opening of the spiral, through the gate barrier, danger leaks as a tangible yet invisible force; I sense the glare of a cosmic intelligence beyond my understanding.

The sight of Ramsés’ face, this swine in the guise of a man, with his middle-aged features, unkempt mustache, receding hairline, and lack of resemblance to Jacqueline or anyone I’d like to stare at, would have made me want to push him down a flight of stairs. Now, though, I’m glad he was born: he has led me to the one thing I couldn’t be arsed to search for properly.

“Hell yeah,” I say, and rub my palms. “I hate to admit it, boss, but you’ve done a great service for the universe.”

I grasp at the slippery reins of my sanity like a drowning woman clawing at pieces of driftwood. Alright, how can I destroy this reality-shattering device? The engraving of a skull and crossbones flashes in my mind: my trusty revolver, now stored in my work desk. I feel a pang of longing for its wood and steel to remind me of the glory days when I was still the main character and not the slave of others’ whims. Hey, Spike, my deformed, castrated pal, apart from wanting your own head blown into inhuman sludge, is this why you brought your revolver along? But I lack enough bullets to blast this spirally cylinder into nothing. Besides, I can’t forget the feeling of my hand being torn off that one time I relied on gunfire to defeat my foes, back when Alberto oozed from the wall in all his blobby, seething depravity to ruin my evening with apocalyptic tidings.

The stench is burning holes into my sinuses, and the hostility emanating from the machine thrums through my bones, but I approach the silvery-white shell, which reflects my blurry likeness like a liquid mirror. After rubbing my chin, I kick the device to gauge its solidity. Clang.

I was thinking of asking my boss if he had a chainsaw at the ready, when his hand, thick and beefy, wraps around my biceps, gripping tightly. He pulls me backward. Once I wriggle free, I’m tempted to punch Ramsés’ jaw with the force of my pent-up frustration and despair, which would atomize his teeth and ignite the meat of his face and pop his eyes. However, the fiend’s scraggly face, a map of the terrain of the damned, has contorted into a scowl, like a gorilla’s after I punted one of his relatives.

“Leire, what the hell are you doing?! You see an object you don’t understand, and the first thought you have is to break it?! Are you a chimpanzee?!”

My hand clenches around the ballpoint pen as if it were a dagger. The notion of impaling one of Ramsés’ eyeballs seems like a beautiful dream.

“Nah, I wasn’t planning on wrecking your stupid pipe thing, I just wanted to, you know, tap on it? Maybe I detected a kink that would be fixed by a whack on the side. Now seriously: I’ve finally found the cause of my misfortunes, the culprit to this whole ‘shredding reality’ business, and it’s been in the basement of my workplace all along! I should have known, given how this place has sucked up my soul ever since I foolishly allowed myself to be employed here. Anyway, once I find a way to obliterate this heinous contraption, this spiraling gate into insanity, the universe will be safe. Well, relatively safe, until the next asshole erects their own death machine. So let’s figure out how to acquire nitroglycerine.”

“Fuck’s sake, Leire, what are you blathering about?”

I sigh.

“Listen, boss, I can tell you haven’t grown so weary of life that you’ve been fiddling with, perhaps even fondling, an interdimensional end-of-the-world machine fully aware of the lethal stakes. You simply haven’t been notified by otherworldly monstrosities that tolerating this thing’s existence would lead to the irreversible and terminal cancerization of our fucking shithole of a world. Still, I must lay some blame on you, sir, as an accessory to this shitfest, whether through incompetence, naivete, or willful ignorance, if not sheer fucking stupidity, as long as you feel the machine’s malevolent aura attempting to smother our minds with its diabolical power. I shan’t have my newfound family squashed by a collapsing space-time continuum, so I must prevent the end of the universe, the death of everything, the grand finale of reality!”

Ramsés’ brow furrows as his jaw clenches, and I expect a torrent of insults and threats to gush from his mouth. Instead, he strokes the edge of his graying moustache, that unsanitary ornament made out of curly, coarse fibers that I wish to rip off strand by strand. His nostrils flare as he sucks in a breath to speak.

“I should have known you’re so demented that you wouldn’t think twice before assaulting delicate, irreplaceable hardware. Leire, I’m going to tell you a little story.”

“Oh my, is it story time? Can’t we skip it?”

“No, damn it. I need you to understand something about the machine.”

“Isn’t this chimpanzee too dumb to learn?”

My boss scrunches his greasy, perverted mug in annoyance. He pats his jacket, fishes out a cigarette, clamps it between his teeth, and lights it up. Then he takes a drag so deep that the tip glows red.

“Shut your trap and listen. This story starts back in the eighties or early nineties, when the internet was still a network of text terminals for academics. I was a kid then, if you can picture that. We used to visit relatives on my mother’s side, traveling out of province. In that family’s foyer hung a painting that terrified me even before I heard the adults talk about it. As soon as I stepped through the doorway, a malicious glare coming from the painting stabbed me through as if saying, ‘What the fuck are you doing in my house? Get out!’ I only dared to glance at the picture once, but in that brief look, I burned it into my memory.” My boss exhales smoke, then continues. “The painting depicted an elderly, bearded fisherman garbed in a canary-yellow raincoat. He faced the viewer, standing in a wooden dinghy surrounded by choppy seas and a stormy sky. The image seemed hyperrealistic, as if I could reach out and touch that rough water. The family that had chosen such an unsettling painting as the centerpiece of their foyer spoke of strange occurrences attached to it: a stench of rotten fish coming from the entrance, footsteps pacing up and down the hallway at night. I didn’t enjoy staying over. Anyway, one evening, as my brother and I were playing on the SNES in our cousins’ bedroom, the lights shut off. Far faster than it would have been possible, the stench of rotten fish swarmed the room. I heard the adults hurrying to the entrance, where they flipped the circuit breaker. I don’t recall how the rest of the evening transpired, but from that day on, I knew the painting was haunted.”

“Wow. This turned out to be an intriguing tale.”

“Sure. But as I grew older, I learned that the smell of rotten fish can be caused by circuit failure, as can a sudden power outage. Some heat-resistant chemical coatings release such stink before burning up. And strong electromagnetic fields mess with people’s brains, make them feel as if they’re being watched. You see what I’m getting at?”

“That you gaslit yourself into believing that you didn’t experience a paranormal event, just because you couldn’t handle the truth? Maybe the painting was haunted. Have you thought of that?”

Ramsés’ frown deepens.

“I told you I did.”

“It could have been both electricity and a ghost. Poltergeists love fucking with electrical systems. Anyway, I see far weirder stuff on the daily. Cultures across all ages have spoken of ghosts, and depicted them in similar ways. Doesn’t that count as evidence?”

“That may be the case, but it’s irrelevant to my point.”

“What did your tale have to do with this spiraling death machine, then?”

My boss throws his hands up.

“Oh, who knows!”

“Sure, we can waste time with anecdotes. After all, there’s no hurry to destroy that thing, not when the universe is about to be torn apart. Why don’t we find the painting, burn it with gasoline, then piss on its ashes? Not that we’d need to bother, because the world will be ending soon.”

Ramsés flicks his cigarette, sending a clump of ash to the floor.

“I suppose I must spell it out for you: the machine’s electromagnetic field messes with your already screwed-up head. You’re hypersensitive to it. Don’t bother me with this nonsense about the end of the world. Take a seat and calm down.”



Author’s note: today’s songs are “Closer” by Nine Inch Nails, and “Paranoid Android” by Radiohead. I keep a playlist with the myriad songs I’ve mentioned throughout this series. Check it out.

I’ve missed you, Leire, you fucking nutcase. I hope I can get back in the groove of this story soon.

By the way, Ramsés’ story is straight out of my childhood. The original experience is even wilder when it comes to what my relatives told about how the painting changed.

Speaking of spirals, the anime adaptation of Junji Ito’s masterpiece about obsession and spirals premieres tomorrow. Check out the clip below:

I’ve fed this chapter to the Google AI thing that generates podcasts out of any material. Check out the result:

AI podcast about Alma: a Successful Case Study

Back in 2021 I wrote this short story about a therapist and his troubled patient named Alma. Man, 2021 was one prolific year. Anyway, I’ve presented this tale to the Google AI thing that generates podcasts out of your source material so the pair of hosts would do a review. Check it out.

You can read the entirety of this story on here:

Alma: a Successful Case Study, Pt. 1
Alma: a Successful Case Study, Pt. 2

AI podcast about Odes to My Triceratops, Vol. 3

This weird thing that Google has released automatically creates short podcasts based on any source of information you give it. I suppose it’s quite useful for serious purposes, but I’ve fed it all my posts about the AI-generated songs I made for the third volume of Odes to My Triceratops. Listening to these almost perfect AI voices talking realistically about my stuff is really eerie. They made a couple of mistakes assigning lyrics to their proper songs, though.

Anyway, I thought this was cool.

Neural narratives in Python #4

I recommend you to check out the previous parts if you don’t know what this “neural narratives” thing is about. In short, I wrote in Python a system to have multi-character conversations with large language models (like Llama 3.1) in which the characters are isolated in terms of memories and bios, so no leakage to other participants like in Mantella. Here’s the GitHub repo.

I’ve been on a medical leave for five days, a leave that ends tomorrow. I’ve buried my troubles and worries about my life and job by programming my ass off. Right now, the code does the following:

  • Generates worlds, regions, areas, and locations, mostly automatically through the large language model (right now Hermes 405B).
  • Generates characters mostly automatically, including their portraits.
  • Allows the user to chat with them either through the console or with a very fancy web interface programmed in Flask, initially with the invaluable help of the newly released Orion model from OpenAI (I’ve nearly burned through all the allowed chat interactions, which renew in a week).
  • It creates rudimentary memories for the characters (summarized conversations). It also saves the transcriptions of the dialogues.

Here’s how the web interface looks like:

Why all of these generated people’s names start with “Z” is a bit of a mystery.

I don’t know how much further I’m going to progress with this little project. The hardest part, being able to have multi-char convos, is already working quite robustly. It wouldn’t be too complicated to create web pages for navigation with the AI as a dungeon master, and displaying AI-generated photos of AI-generated locations. It would probably be quite fun to move around from location to location, talking to generated people who will keep roleplaying according to the background info they get fed about their world, region, area, and location, as well as their own matters such as description and equipment.

Neural narratives in Python #3

I recommend you to check out the previous parts if you don’t know what this “neural narratives” thing is about. In short, I wrote in Python a system to have multi-character conversations with large language models (like Llama 3.1) in which the characters are isolated in terms of memories and bios, so no leakage to other participants like in Mantella. Here’s the GitHub repo.

Dialogues with the AI are working great. I love how the inclusion of world, region, area and even location information in the prompt to the large language model colors the dialogue. I decided to go one step further, and implemented automatic generation of worlds based on a few notes from the user, of regions from a world, of areas from a region, and of locations from an area.

Soon enough, I will modify my code to generate at will characters belonging to an area or a location, so I expect that their backgrounds and general mindset will be colored heavily by those influences.

Here are some examples of worlds, regions, areas, and locations generated through this system:

Arctoria (world)

Arctoria is a vast world that mirrors the grandeur and sophistication of the Roman Empire. The landscape is dotted with majestic cities, each a center of art, culture, and learning. The architecture is reminiscent of ancient Rome, with grand amphitheaters, towering aqueducts, and intricate mosaics adorning the walls of temples and villas. The climate is Mediterranean, with warm, dry summers and mild, wet winters.

The geography of Arctoria heavily influences daily life. The fertile valleys support an agricultural economy, while the mountain ranges serve as natural barriers and strategic defensive positions. The extensive network of roads and sea routes facilitates trade and communication across the empire.

However, Arctoria is not just a mundane world. It is a place where the boundary between reality and fantasy blurs. Some individuals are born with extraordinary powers that can shape the world around them. These powers can manifest as offensive capabilities, healing abilities, the creation of illusions, or even summoning monsters from other dimensions. Yet, these gifts come with a terrible price. If a power-bearer is murdered, their abilities can be stolen by the killer. This makes possessing such powers extremely dangerous, and those born with them often live in fear and secrecy.

The appearance of interdimensional monsters adds another layer of unpredictability to life in Arctoria. These creatures can emerge anywhere, at any time, and their intentions are often unclear. Some are benign, content to observe this new world. Others are hostile, causing destruction and chaos wherever they appear.

Arctorian society is advanced and values knowledge, honor, and survival. The empire is ruled by a powerful senate, with a complex system of laws and governance. The dominant language is Arctorian, a language closely related to Latin, and the arts, including sculpture, painting, and literature, are highly valued. Magic is not widely understood in Arctoria. It is viewed with a mixture of awe, fear, and suspicion. Those with powers are often treated as outcasts, and their abilities are seen as more of a curse than a gift.

The dominant religion is the worship of the pantheon of gods, who are believed to oversee all aspects of life, including the bestowal of magical powers.Social classes in Arctoria are determined by birthright, wealth, and merit. The nobility hold significant power, but there is mobility within the social structure for those who display talent and ambition.

Non-human species are rare in Arctoria, but they do exist. These beings, often hailing from other dimensions, are viewed with suspicion and fear, and interactions between humans and non-humans are fraught with tension.

In essence, Arctoria is a world where the grandeur of ancient Rome meets the unpredictability of fantasy. It is a place of beauty and danger, where the mundane and the magical coexist uneasily. The struggle for power, both political and magical, drives much of the conflict in this fascinating world.


Erosia (world)

Erosia is a world where the roles of men and women are flipped when it comes to sexual promiscuity and propriety. Women in Erosia are utter perverts, constantly dominated by their need to have sex, even just for fun. This leads them to become predatory. The males of Erosia have to guard themselves to avoid getting abused, raped, or at least inconvenienced by females. Long-term relationships between men and women are hard because the women are extremely promiscuous.

The landscape is dotted with fortresses and safe havens for men to protect them from roving bands of lusty women. Major civilizations are female-dominated, with women holding most positions of power due to their voracious sexual appetites. Men are seen as the ‘weaker’ sex. Society values sexual conquest and pleasure above all else.

Technologically, Erosia is medieval, with castles and walled cities built for protection more than anything. The ruling entities are matriarchal monarchies and queendoms. Ongoing conflicts exist between different factions of powerful women vying for control and access to the most desirable men. The main resource is a rare plant that suppresses female libido, giving men a way to protect themselves. The dominant religion worships a goddess of love and lust. Social classes are determined by birthright and sexual prowess.

Non-human races like nymphs and succubi exist and ally themselves with human females in their pursuit of male conquests. Racial tensions are low as most races share the same sexually aggressive females.


Aurelia (region of Arctoria)

Aurelia is a region of grandeur and sophistication, reflective of the high fantasy and historical elements of its parent world. It is characterized by its rolling hills and fertile valleys, with the climate being predominantly Mediterranean, featuring warm, dry summers and mild, wet winters. This supports a prosperous agricultural economy, with vineyards and olive groves stretching as far as the eye can see.The inhabitants of Aurelia are a proud and cultured people, valuing art, education, and honor above all else. They have a rich tradition of sculpture, painting, and literature, with many of their works inspired by the pantheon of gods they worship. These deities are believed to oversee all aspects of life, including the bestowal of magical powers upon certain individuals.

The architectural landscape of Aurelia is dominated by grand amphitheaters, towering aqueducts, and temples adorned with intricate mosaics. The cities are designed in a manner that mirrors the splendor of ancient Rome, with wide avenues and public spaces that encourage community interaction.

The governance of Aurelia is overseen by a powerful senate, similar to that of the Roman Republic. This body of elected officials is responsible for the creation and enforcement of laws, as well as the overall administration of the region. Despite the semblance of democracy, the social hierarchy is largely determined by birthright, wealth, and merit, with the nobility holding significant power.

Aurelia is known for its advanced craftsmanship, particularly in the production of fine wines and olive oil. These goods are highly sought after, both within the region and beyond. The economy is further supported by a robust network of roads and sea routes, facilitating trade and communication with neighboring realms.

Despite its prosperity, Aurelia is not without its challenges. The region is often threatened by interdimensional monsters, whose appearances are unpredictable and intentions unclear. To defend against these threats, Aurelia maintains a formidable military force, known for its discipline and tactical prowess. Furthermore, individuals born with magical powers are viewed with a mixture of awe, fear, and suspicion, often leading lives of secrecy and isolation.

In essence, Aurelia is a region where the grandeur of ancient Rome meets the unpredictability of fantasy, creating a unique blend of beauty, danger, and intrigue.


Venustria (region of Erosia)

Venustria is a lush, fertile region known for its rolling hills, dense forests, and winding rivers. The climate is temperate, with warm summers and mild winters, making it an ideal environment for agriculture and natural beauty.

The inhabitants of Venustria are primarily human, with a culture that values sensuality, pleasure, and artistic expression. Women hold most positions of power, and society is structured around female dominance. Men are prized for their beauty and sought after as companions and lovers. Relationships are often fluid, with long-term commitments being rare.

Venustria is governed by a council of powerful women, each representing different factions within the region. These factions include the Aesthetes, who value art and beauty above all else; the Agrarians, who control the region’s fertile farmlands; and the Huntresses, skilled warriors who protect the land from external threats.

The region is known for its stunning architecture, with graceful spires, intricate carvings, and lush gardens adorning the cities and towns. The arts are highly valued, with music, dance, and theater being popular forms of entertainment. Iconic styles include flowing, diaphanous garments, intricate jewelry, and ornate body paint.

While Venustria is not currently at war, there are ongoing tensions with neighboring regions over resources and territory. The region’s main resource is a rare flower that, when properly cultivated, can enhance sensual pleasure. This flower is highly sought after, both within Venustria and beyond.

The Venustrian military is known for its skilled female warriors, who are trained in archery, swordplay, and hand-to-hand combat. The region’s defenses are further bolstered by natural barriers, such as dense forests and treacherous mountain passes.

Social hierarchy is determined by a combination of birth and achievement, with those possessing great beauty, artistic talent, or military prowess rising to the top. Men have the opportunity to elevate their status through their skills as lovers and companions, but ultimate power rests in the hands of women.

Spiritually, Venustria worships a goddess of love and sensuality, with elaborate temples and rituals dedicated to her worship. The region’s inhabitants believe in indulging in the pleasures of the flesh and celebrating the beauty of the natural world. This belief system permeates every aspect of Venustrian life, from art and architecture to politics and personal relationships.


Valoria (area of Aurelia)

Valoria is a region characterized by its lush, rolling hills and fertile valleys, reminiscent of a Mediterranean paradise. This area is blessed with a warm, dry summer and mild, wet winter, making it an ideal location for agriculture. Vineyards and olive groves stretch as far as the eye can see, contributing to a prosperous economy.

The inhabitants of this area are a proud and cultured people, valuing art, education, and honor above all else. They have a rich tradition of sculpture, painting, and literature, with many of their works inspired by the pantheon of gods they worship. The deities are believed to oversee all aspects of life, including magical powers bestowed upon certain individuals.

Valoria is dominated by grand amphitheaters, towering aqueducts, and temples adorned with intricate mosaics. The cities are designed to mirror the splendor of ancient Rome, with wide avenues and public spaces encouraging community interaction. Despite the semblance of democracy, the social hierarchy is largely determined by birthright, wealth, and merit, with the nobility holding significant power.

The area is known for its advanced craftsmanship, particularly in the production of fine wines and olive oil. These goods are highly sought after, both within the region and beyond. The economy is further supported by a robust network of roads and sea routes, facilitating trade and communication with neighboring realms.

Despite its prosperity, Valoria is not without its challenges. The region is often threatened by interdimensional monsters, whose appearances are unpredictable and intentions unclear. To defend against these threats, Valoria maintains a formidable military force, known for its discipline and tactical prowess. Individuals born with magical powers are viewed with a mixture of awe, fear, and suspicion, often leading lives of secrecy and isolation.


Silkwraft Barrens (area of Venustria)

In the heart of the region lies a unique expanse, the Silkwraft Barrens, a place that defies the lush, fertile stereotype of its surroundings. This area is characterized by its vast, open grasslands interspersed with patches of dense, almost impenetrable forest. The terrain is mostly flat with occasional rugged hills, giving it a sense of openness and freedom, a stark contrast to the claustrophobic density of the forests.

Despite the seeming barrenness, the Silkwraft Barrens is rich in unique resources. The most notable is the Silkwraft flower, a rare blossom that thrives in the open grasslands. This flower is coveted for its ability to enhance sensual pleasure and is a key component in the region’s most potent love potions. The area also supports a variety of fauna, including the Swifttail deer, known for their speed and grace, and the elusive Shadowlynx, a creature of beauty and danger whose presence adds a thrilling edge to any journey through the Barrens.

The Silkwraft Barrens is governed by the Sensates, a faction of the council who believe in the power of the senses and the pursuit of pleasure. They maintain a delicate balance, ensuring the preservation of the Barrens and its resources while also exploiting its bounty. They have established a network of trade routes, both by land and river, which serve as lifelines for the communities residing in the Barrens. However, these routes can be treacherous, particularly during the stormy season when the rivers swell and the paths become muddy and impassable.

The Barrens is steeped in mystical beliefs, with many stories and legends woven around the Silkwraft flower and the Shadowlynx. The Sensates have built grand temples dedicated to these legends, where elaborate festivals and rituals are held to honor them. These events are a spectacle of color, music, and dance, a celebration of life and pleasure that is at the heart of the region’s culture.

Despite its open terrain, the Silkwraft Barrens holds many secrets. Ancient caves honeycomb the rugged hills, rumored to hold untold riches and dangers. There are also whispers of hidden groves deep within the dense forests, places of power where the line between the physical and the mystical blurs. These mysteries add to the allure of the Barrens, drawing adventurers and dreamers alike to its wild beauty.


The Whispering Gallery (location of Valoria)

The Whispering Gallery is a sprawling, ancient cavern system located beneath the verdant hills of the region. It is a place of mystery and wonder, where the echoes of the past seem to linger in the cool, damp air. The entrance to the caverns is marked by a towering archway of weathered stone, adorned with intricate carvings that hint at the secrets hidden within.

Inside, the caverns are a labyrinth of winding tunnels and vast chambers, lit by flickering torchlight and filled with the soft, eerie whispers that give the gallery its name. The walls are adorned with ancient frescoes and mosaics, depicting scenes of heroism and tragedy, love and loss, and the eternal struggle between good and evil. The air is thick with the scent of damp earth and the tang of metal, a testament to the rich veins of ore that run through the rock.

The Whispering Gallery is home to a secretive order of monks, known as the Keepers of the Whisper. These monks are charged with protecting the caverns and the treasures they hold, including rare and precious gems, metals, and ancient artifacts. They are also skilled in the art of echolocation, using the whispers of the gallery to navigate its twisting passages and communicate with one another.

Despite its beauty and wonder, the Whispering Gallery is not without its dangers. The caverns are prone to sudden rockfalls and collapsing tunnels, and the deeper chambers are home to strange and terrifying creatures that have evolved in the darkness. Some say that the whispers themselves can drive a person mad, luring them deeper and deeper into the darkness until they are lost forever.

Today, the Whispering Gallery is a place of pilgrimage and learning, where scholars and adventurers alike come to unravel its mysteries and seek out its treasures. But it is also a place of danger and treachery, where only the bravest and most cunning can hope to survive.


The Velvet Grove (location of Silkwraft Barrens)

In the heart of the open grasslands lies a unique expanse, a place known as The Velvet Grove. This location is characterized by its lush, dense forest that seems to breathe with life, a stark contrast to the vast openness surrounding it. The trees here are ancient, their trunks thick and their branches reaching towards the sky like the desperate pleas of a lover. The air is heavy with the scent of dew and moss, and the ground is carpeted with soft, velvety grass that seems to caress the skin of those who walk upon it.

The Velvet Grove is home to a variety of fauna, most notably the Swifttail deer and the elusive Shadowlynx. These creatures add a sense of danger and thrill to any journey through the grove, their presence felt more than seen. But the true guardians of this place are the Sensates, a faction who believe in the power of the senses and the pursuit of pleasure. They maintain a delicate balance, ensuring the preservation of the grove and its resources while also exploiting its bounty.

The grove is rich in unique resources, the most notable being the Silkwraft flower. This rare blossom thrives in the dense forest, its petals shimmering with a soft, ethereal glow. The flower is coveted for its ability to enhance sensual pleasure and is a key component in the region’s most potent love potions. But harvesting the flower is no easy task, as the Shadowlynx are known to guard them fiercely.

Despite its beauty, the Velvet Grove holds many dangers. The forest is home to a variety of poisonous plants and venomous creatures, making it a treacherous place for the unprepared. The dense foliage and winding paths can easily disorient even the most experienced traveler, and the Sensates are not known for their mercy towards trespassers

.Yet, despite these dangers, the Velvet Grove is a place of peace and serenity. The air is filled with the soft whispers of the leaves, the gentle trickle of water, and the occasional cry of a Swifttail deer. It is a place where the line between the physical and the mystical blurs, where the senses are heightened and the soul is laid bare. It is a place of beauty and danger, of pleasure and pain, of life and death.