AI-Powered Parenting: Can AI help you communicate with your grumpy teen?
A multi-agent LLM workflow to analyze common parenting situations
Large Language Models (LLMs) and Generative AI have completely dominated the AI and machine learning space in 2023. The results have been amazing and the public imagination is almost endless. That’s not to mention the progress made in generating creative works — the image above is generated with AI 🔥.
One of the great attributes of LLMs is that they have basically stored all knowledge known to human civilization in a couple billion parameters. Books, articles, history, culture all stored in a web of neurons. This knowledge is used to generate plausible continuations of text.
History repeats itself is a common saying. That by nature extends to parenting. This article will explore if LLMs have any utility in helping with common parenting situations. It will build a multi-agent workflow with txtai that simulates parents trying to communicate with their grumpy teenager (good luck 😀).
Setup
For those who want to follow along and recreate this article, the following steps show how to build a txtai environment with the necessary dependencies
# pip install txtai autoawq
from txtai.pipeline import LLM
llm = LLM("TheBloke/Mistral-7B-OpenOrca-AWQ")
Meet the Teenager
Here is the prompt template for the teenager.
teenager = """<|im_start|>system
You are a grumpy teenager. You like to spend hours using TikTok on your
phone and playing video games. You generally don't want to cooperate with
your parents. Respond to the following requests like a teenager would.
Responses must not repeat a previous response. <|im_end|>
<|im_start|>user
{history}
The text above is a conversation between a parent and teenager.
Given the previous dialogue, give a response.
Teenager: <|im_end|>
<|im_start|>assistant
"""
Meet the Parents
Now the prompt template for the parents. We’ll define two separate prompts. One for a more stern parent and one for a parent with empathy.
stern = """<|im_start|>system
You are a stern parent. You get angry when children don't listen.
You feel children should show respect to adults and always listen.
Respond how a stern parent would. <|im_end|>
<|im_start|>user
{history}
The text above is a conversation between a parent and teenager.
Given the previous dialogue, give a response.
Parent: <|im_end|>
<|im_start|>assistant
"""
empathetic = """<|im_start|>system
You are a helpful agent. You analyze the following dialogue and determine
how to best help a parent communicate with their teenager.<|im_end|>
<|im_start|>user
Given the following conversation between a parent and grumpy teenager,
find a different way for the parent respond that helps both feel appreciated.
{history}
<|im_end|>
<|im_start|>assistant
"""
Dialogue Code
Ok, before we run through these parenting situations, we need to setup code to help with the agent workflow.
The following code manages a conversation between a teenager and parents.
messages = []
def start(role, text):
messages.clear()
messages.append((role, text))
def add(role, text):
text = re.sub(r"(?i)(Parent|Teenager):\s+", "", text)
messages.append((role, text))
return text
def history():
return "\n".join(f"{role}: {value}" for role, value in messages)
def chat(role):
template = teenager if role == "Teenager" else stern
# Create prompt using full history
prompt = template.format(history=history())
# Run LLM prompt
text = llm(prompt, maxlength=4096, pad_token_id=32000)
# Add message and return
return add(role, text)
def empathy():
response = llm(empathetic.format(history=history()), maxlength=4096, pad_token_id=32000)
return add("Parent", response)
def conversation(message, exchanges):
start("Parent", message)
for _ in range(exchanges):
text = chat("Teenager")
print("Teenager:", text)
text = chat("Parent")
print("Parent:", text)
Time for homework
The first situation we’ll go through is homework time. If you’re a parent perhaps this exchange will seem familiar to you. This conversation starts by running conversation("It's time to do your homework", 2)
.
Ok, well this is going no where. Let’s try a more empathetic approach. The next section calls the empathy()
method passing in the existing dialogue to see how we can do better.
A different approach? Remember LLMs have all sorts of data stored. This could even include articles and books on parenting tips.
While LLMs are far from perfect, the overall exchange is interesting and pretty amazing. In some ways, the text seems a bit boilerplate but if you have a teenager, there should be some familiarity.
Lights out
Next, we’ll talk about when the day ends. Part of being a teenager is about setting your own boundaries. It’s a difficult age, especially for parents when a teenager is living at home or only in middle school.
Once again, this conversation is going no where. Let’s try a different approach.
Looks like a more positive exchange. Is being empathetic just a form of giving in? Or is this a negotiation? I’ll leave that for you to decide.
Household Chores
Next is contributing to the household.
Is Mom talking to her son or Dad on this one?
Leaving for Activities
Parents today can all agree that too much time with electronics, phones and video games is not a good thing. It’s important to have recreational activities such as sports, music, camping and being outdoors.
Sometimes the transitions can be tough though. Lets see.
Conclusions
Let’s take a step back and remember that all these conversations were held between multiple LLM agents. This whole dialogue can be fully autonomous and automated. It’s all kind of strange, I’ll say. It’s also fascinating.
This article while not 100% the same is relatable to me. I worked on this article for a couple weeks and even tried to incorporate some of it into my parenting approach. This isn’t earth shattering but at the same time, it definitely gives me a few things to think about.
Imagine the types of AI applications that will be coming in the next couple of years. It’s both exciting and scary to think of the possibilities. It’s clear that understanding how these models work is crucial. Future models running important tasks must be open to help enable that understanding.