AI can generate code to generate personas!

Among team members, we (like much of the global research community) have followed the progress of AI-based language generator tools, such as Open AI’s GPT-3. Previously, we published a post with AI-generated content.

In this post, we will briefly explore GPT-3’s ability to generate code for persona generation.

This is a challenging task, because it requires, first of all, understanding of what personas are. Secondly, AI has to be able to understand what information personas would contain, and how to obtain such information. It also needs to exhibit some level of creativity in “imagining” a process or method for persona generation.

So, without further ado, let’s see what happens!

I used the prompt: “write code that generate personas automatically from data” and used the default hyperparameters available in Open AI’s sandbox tool (btw, when publishing the results of experiments with language models, one should always make the prompt available, as well as the hyperparameters used).

The machine generated this output:

Here is an example of how you could generate personas automatically from data:

import random

# Define a list of possible personality traits
personality_traits = [“adventurous”, “assertive”, “charming”, “confident”, “creative”, “determined”, “energetic”, “friendly”, “humorous”, “independent”, “intelligent”, “kind”, “passionate”, “patient”, “persistent”, “sensible”, “sincere”, “sympathetic”, “thoughtful”, “wise”]

# Define a list of possible demographics
demographics = [“age”, “gender”, “marital status”, “education level”, “income level”, “occupation”, “location”]

# Define a function to generate a random persona
def generate_persona():
# Choose a random set of personality traits
num_traits = random.randint(3, 5)
chosen_traits = random.sample(personality_traits, num_traits)

# Choose a random set of demographics
num_demographics = random.randint(3, 5)
chosen_demographics = random.sample(demographics, num_demographics)

# Create a dictionary to represent the persona
persona = {}
persona[“personality traits”] = chosen_traits
persona[“demographics”] = {}
for demographic in chosen_demographics:
persona[“demographics”][demographic] = “unknown”

return persona

# Generate 10 random personas
for i in range(10):
persona = generate_persona()
print(f”Persona {i+1}:”)
print(f” Personality traits: {persona[‘personality traits’]}”)
print(f” Demographics: {persona[‘demographics’]}”)

This code generates a random set of personality traits and demographics for each persona, and stores them in a dictionary. You could then use real data to fill in the values for the demographics. For example, if you had a dataset of customer information, you could use that data to populate the persona dictionaries with real values for each demographic.

When I shared this result with the team members, one of them reacted, “Wow that’s fascinating”. I agree with that assessment — extremely fascinating.

We can make a few observations from the generated output.

  • First, since there is no data, the AI invents example variables and uses randomization for “imagining” data. Clever.
  • Second, the AI provides both the pseudo code and explanation of it. Thus, the output seems complete.
  • Third, the AI even explains that you could use real data to replace the dummy data it provides, providing practical tips on how to implement its suggestion.

Overall, this brief example indicates that AI can generate “creative aids” for data-driven or algorithmic persona generation.

The AI seems to understand the concept of personas (that they can include personality traits and demographics), and it seems to devise a creative solution to the problem. The output is similar to how I’d presume a real computer scientist would solve the problem. Also, this solution is not just copy-pasted from some online source; it is an original and whole solution that is complemented with explanations of how to use it.

One important point to add is the brevity of the prompt. Comparing to human-to-human communication, most likely I’d need to explain the concept of personas to a computer scientist in much more detail; here, I just mentioned the concept of persona and the AI understood what it was (whereas *most* computer scientists in my experience don’t know what personas really are).

So, I’d likely need to brief real humans much more than what I did with GPT-3. In this case, I just provided it with a prompt that required it to understand very specific concepts, and it did! While it is remarkable that this is now possible, it also indicates that the AI has some traits of a good assistant — i.e., it requires only a small amount of explaining from the instructor and can work with concise instructions.

We’re living historic times!

Scroll to Top