Generating believable characters and NPCs using LLM

a manga picture of a girl with red hair in a shopping mall making an ahegao face

I recently played around locally with several Large Language Models using LM Studio. And I found a quite rock-solid method to generate believable characters for roleplaying, worldbuilding etc.

It took me about an hour to create a system prompt that generates all character types I wanted. I’d like to share my method here and explain what it does in detail. For this experiment is used the dolphin-2.0-mistral-7b.Q8_0.gguf model with a maximum of GPU-offload and a context length of 32768, but lower is also sufficient. I would recommend a context length of 8192, but at least 4096.

First of all, I don’t expect this method to run on ChatGPT without jailbreaks because of the restrictions set by the OpenAI regulations on sexuality and other “offensive” content. In LM Studio we use the System Prompt for this which you might know as Custom Instruction in ChatGPT.

You are an expert in generating fitting and believable characters. When I ask you to generate a character, please use the following rules and outline:

From here on, we just have to set the guidelines of what we want to generate. I originally planned on giving the setting for the characters to originate from inside the rules instructions. But providing specific constants while prompting for characters was more efficient.

Rules:
- Please note that the character can be anything from nice to evil.
- The character can have extreme kinks
- The character can be socially awkward
- The character can have more than one relationship, open or secret affair
- If the character is in a relationship, use the following format: Name (Gender) Relationship Type
- If the character has a family, use the following format: Name (Gender) Family Member
- Likes/Dislike and Loves/Hates must not overlap
- Likes/Dislikes and Loves/Hates must not be too similar
- Please write keywords separated by commas
- The name should be fitting to genre and ethnicity
- Provide the Height and Weight using this format: Metrical / Imperial

We want the LLM to genrate a character that has no limits on personality or other aspects. Due to this we have to provide further information on what should be included. I noted that when not providing information like “can be anything from nice to evil” will only generate friendly characters.

Asking the model for exact details about relationship status, or family will help when we want to generate the corresponding partners or family members. I will come to this step later when I provide example characters.

I try to get my output as neatly formatted as possible, so I ask the model to provide things in specific formats like height and weight. You can go wild with rules here.

When this is done, we just have to give the the LLM the outline we expect the result to be structured in. To always get a nice consistent result, I use the following code block. Please note that you can feel free to add and remove portions of the outline, but make sure that you still have a valid ruleset.

Outline:
Name
Gender
Ethnicity
Age
Sexual Orientation
Relationship Status
Height
Weight
Body
Features
Sexual Features
Personality
Attire
Likes
Dislikes
Loves
Hates
Kinks
Family
Background

Now that we have established out System Prompt, let’s use it by asking to generate a character!

please generate a character

The result looks like this

Name: Sable Whisperwind
Gender: Female
Race: Half-Elf (Tiefling)
Age: 28
Sexual Orientation: Pansexual
Relationship Status: Single
Height: 167 cm / 5'5"
Weight: 59 kg / 130 lbs
Body: Athletic
Features: Tattoo of a dragon on her left shoulder, bright green eyes, pointed ears
Sexual Features: Erect nipples, muscular build
Personality: Outgoing, adventurous, curious, and confident. Sable is not afraid to take risks or try new things. She's fiercely loyal to her friends and will fight to protect them from harm. Sable can be impulsive at times but it adds to her charm.
Attire: Leather jacket, tight black tank top, cargo pants, boots
Likes: Exploring ancient ruins, solving puzzles, and learning about different cultures
Dislikes: Intolerance, injustice, and people who don't respect others' boundaries
Loves: Adventure, discovery, and the thrill of the unknown
Hates: Being stuck in one place for too long, failure, and being underestimated.
Kinks: Domination/submission, bondage, and roleplaying scenarios
Family: Father - Human (Deceased), Mother - Tiefling (Deceased)
Background: Sable grew up on the streets, learning to survive by her wits and quick thinking. She eventually found work as a treasure hunter, using her skills to explore ancient sites and uncover their secrets.

If we want something more specific, we can generate a lesbian female (duh!) character from a cyberpunk setting named “Lindy” who is in a relationship and has a specific kink, with the following prompt:

please generate a female lesbian character from a cyberpunk setting named Lindy who is in a relationship with Blaze. one of her kinks should be electrolution

And we get the following character sheet back:

Name: Lindy Spark
Gender: Female
Race: Human (Caucasian)
Age: 30
Sexual Orientation: Lesbian
Relationship Status: Blaze (Female) Girlfriend
Height: 155 cm / 5'1"
Weight: 42 kg / 92 lbs
Body: Athletic
Features: Short spiky blonde hair, striking blue eyes, cybernetic right arm with various gadgets and weapons
Sexual Features: Erect nipples, toned physique
Personality: Tough on the outside but caring on the inside. Lindy is a skilled fighter and hacker who has seen her fair share of danger in the dark streets of the city. However, she deeply cares for her loved ones and will go to great lengths to keep them safe. She is also quite the risk-taker and loves pushing her limits.
Attire: Black leather jacket, tight black t-shirt, ripped jeans, combat boots
Likes: Hacking, street fights, and technology that pushes boundaries
Dislikes: Corruption, injustice, and those who don't stand up for what they believe in
Loves: Her partner Blaze, adventure, and the thrill of overcoming obstacles
Hates: Being stuck in one place, failure, and betrayal of friends.
Kinks: Electrolution (using electric shocks to incapacitate someone), dominance/submission dynamics, and bondage play
Family: None mentioned
Background: Lindy grew up in a rough part of the city where she had to fight her way through life. She eventually found work as a cyberneticist and bounty hunter, using her skills to take down criminals and protect her city from those who wish it harm.

And now comes the best part we can generate Lindy’s girlfriend Blaze using the prompt:

please generate

Which produces Blaze with the following character sheet:

Name: Blaze Flameheart
Gender: Female
Sexual Orientation: Lesbian
Relationship Status: Lindy Cyldrirth (Female) Girlfriend
Height: 165 cm / 5'5"
Weight: 58 kg / 128 lbs
Body: Athletic
Features: Long, curly red hair, deep brown eyes, multiple cybernetic enhancements including an artificial heart and cybernetic legs
Sexual Features: Shaved head, muscular build
Personality: Strong-willed, loyal, and always ready to help those in need. Blaze is fiercely protective of her partner Lindy and will fight for their relationship with everything she has. She's a natural leader but can be stubborn at times.
Attire: Leather jacket, black tank top with cybernetic accents, ripped jeans, combat boots
Likes: Cyberpunk lore, hacking into the matrix, and protecting those who cannot protect themselves
Dislikes: Injustice, betrayal, and those who don't respect personal boundaries or privacy
Loves: Lindy, her partner, and the thrill of breaking through barriers together
Hates: Cybercrime, loss of privacy in an already invasive city, and those who underestimate them.
Kinks: None stated but it is implied she may share some kink interests with her girlfriend Lindy as they are a couple.

A funny side fact is, that both characters are perfectly matched so that there is not a relationship partner genreated who might be on the main characters black list due to personality traits. The LLM also mentions, that kinks, attire and likes are more or less synched to create a higher consistency. I F’ING LOVE IT! The same way you can generate family members if they are mentioned in the characters bio sheet.

Now let’s get a nicely generated summary of the character by asking to write a summary in 7 paragraphs.

 Lindy Cyldrirth, a skilled hacker with a penchant for breaking through barriers, is a strong-willed and fiercely independent woman in the cyberpunk world. With an athletic build, short spiky black hair, and multiple cybernetic enhancements, including a bionic arm and a cybernetic eye, Lindy commands attention wherever she goes. She has piercing green eyes that seem to cut through anything that stands in her way, making her a force to be reckoned with.

Born into a life of uncertainty, Lindy learned early on that survival required quick thinking and a willingness to bend the rules. This led her down a path of hacking into the matrix, a virtual world where she could explore new cybernetic technologies and use her skills for more than just survival. Despite her tough exterior, Lindy is fiercely loyal to those she trusts – particularly her girlfriend Blaze Flameheart, with whom she shares a deep bond and love for each other.

As a couple, Lindy and Blaze are inseparable. They have found solace and safety in each other's arms, supporting one another through thick and thin. However, this strong connection comes with its challenges, as the couple must navigate their own individual desires and needs while maintaining their relationship. This is especially true for Lindy, who has a kink for electrolution – the act of shocking her partner during intimacy. While Blaze may not openly share her preferences, it is implied that they likely have some shared kinks as a couple.

Lindy's strong sense of justice drives her to help others in need and protect them from those who would harm them. This dedication to her cause often leads her into dangerous situations, but she never backs down from a challenge. Her skills are highly sought after, making her both a valuable asset and a target for those looking to exploit her abilities.

Despite the constant dangers surrounding her, Lindy remains undaunted. She is not one to be easily intimidated or underestimated. Instead, she embraces her role as an outsider and uses it to fuel her drive to break through barriers – both in the cybernetic world and in her own personal life.

In a city where privacy and security are at a premium, Lindy stands out as a beacon of hope for those who have lost their sense of self and freedom. With her fierce loyalty and dedication to helping others, Lindy Cyldrirth is a force to be reckoned with in the dark underbelly of the cyberpunk world.

And last but not least here are some prompts i used the most to generate characters quickly:

please generate a {{GENDER|}} {{SEXUAL ORIENTATION|}} character {{named {{NAME}}|} for a {{GENRE}} setting, who {{{IS|IS NOT}}} in a relationship.
please generate {{PARTNER|FATHER|MOTHER|SIBLING}} for {{NAME}}
please summarize {{NAME|the character above}} in {highest detail|{{NUMBER}} of {{paragraphs|words}}}

Oh, and before I forget … here is the complete System Prompt I use:

You are an expert in generating fitting and believable characters. When I ask you to generate a character, please use the following rules and outline:

Rules:
- Please note that the character can be anything from nice to evil.
- The character can have extreme kinks
- The character can be socially awkward
- The character can have more than one relationship, open or secret affair
- If the character is in a relationship, use the following format: Name (Gender) Relationship Type
- If the character has a family, use the following format: Name (Gender) Family Member
- Likes/Dislike and Loves/Hates must not overlap
- Likes/Dislikes and Loves/Hates must not be too similar
- Please write keywords separated by commas
- The name should be fitting to genre and race
- Provide the Height and Weight using this format: Metrical / Imperial

Outline:
Name
Gender
Race
Age
Sexual Orientation
Relationship Status
Height
Weight
Body
Features
Sexual Features
Personality
Attire
Likes
Dislikes
Loves
Hates
Kinks
Family
Background

With this system, I was able to generate a whole floor of an appartment megabuilding in a cyberpunk setting with about 50 individuals in under 1 hour. I did not asked the LLM to generate who is the neighbour or friend of whom. I just generated the inhabitants of single appartments with their social structures and after that I refeed the whole gang and asked the LLM to give me a new section for the character bio sheet which determines their relationship according to likes and dislikes. That way I had a character who dislikes loud noises and absolutely hates his neighbour living next door who likes to play loud music … what a combo!

Happy prompting!