At the Shabbos table this week, we were discussing my son’s homework assignment to write a poem. It didn’t have to be a great poem, but it should involve more than one person. I suggested he write one on the parsha.
Here are my on-the-spot efforts. First, a limerick:
There once was a man from Be’er Shava,
Who dwelt for a while with Lava(n).
All 613 he kept,
Learned all night, barely slept,
And the angel of Esav, he shove-a’d.`
Then, as a nursery rhyme:
Little Miss Rochel,
Sat on some truffles, (im)
Hiding the idols of clay.
Along came her father,
Her he started to bother,
Until Yaakov chased him away.
I thought these were pretty good for minimal effort. They are funny (if I say so myself) and they have the right rhyme scheme and meter. On a lark, I decided to ask ChatGPT to try it.
Prompt: please write a nursery rhyme about Rachel hiding her father's idols as she sat on a camel.
Response:
Rachel sat on a camel,
Hiding her father's idols,
She held them close to her chest,
Afraid they would be discovered.The camel swayed from side to side,
As they journeyed through the night,
Rachel clutched the idols tight,
Praying they would be alright.She thought of her dear father,
And all that he held dear,
She knew he trusted her,
To keep his idols near.Through the desert they did roam,
Under the stars so bright,
Rachel held on to the idols,
With all of her might.When the morning sun did rise,
Rachel breathed a sigh of relief,
She had kept her father's idols safe,
Through the long and lonely night.And as she climbed down from the camel,
Rachel knew she had done her best,
To protect her father's treasures,
While sitting on that camel's chest.
Oy. I didn’t like it, because it didn’t conform to the Biblical story, where she was hiding them from her father. Also, it didn’t really have the beat of a nursery rhyme. I tried to correct it, and redirect it. I thought that limericks were also more constrained in their expected number of syllables and rhyme schemes, so redirected it to write a limerick.
Prompt: Actually, she despised those idols and was trying to hide them from her father. Please rewrite the poem, this time as a limerick.
Response:Rachel sat on a camel,
With idols hidden in her shirt,
She hoped her father wouldn't see,
For she knew they would cause a hurt.With a sly and cunning smile,
She rode along for a while,
Till she reached a hidden spot,
Where she quickly buried the idol.But little did she know,
That her father watched her go,
And when she returned that night,
He gave her a terrible fright."Why did you hide my idols?" he bellowed,
Rachel was at a loss for words,
"I don't like them," she stammered,
"They give me the worst of all scares."Her father was enraged,
And sent her away,
Rachel never returned,
To that desert oasis that day.
Pretty good that it was able to correct itself. But it doesn’t yet know how to write a poem in a specific style. It doesn’t know meter, and it doesn’t know the right rhyme scheme.
Now, many humans fail at this. I’ve seen many humans fail at the task. Just look at the cringe-worthy Purim poetry in the (attempted) style of Dr. Seuss. (I don’t want to name and shame, so just do a Google search for “dr suess purim poetry”.)
Maybe with much more training data and direction, ChatGPT can greatly improve. I’m just comparing with one of the first assignments in the NLP course I give. I ask the students to write a haiku verifier and a limerick verifier. For the Haiku, it needs to look at syllable count as well as nature themes. For the Limerick, it needs to look at syllable count, stress points on those syllables, and the appropriate rhyme scheme.
It looks like ChatGPT was indeed trained on haikus, which have a 5-7-5 syllable count. So the output when I asked it to write it in the form of a short haiku was this:
Rachel on a camel rides,
Hiding idols deep inside,
Father watches on with a frown.
Hey, it rhymes, somewhat. But every sentence is seven syllables. :( For illustrative purposes, a bad equivalent with the right number of syllables might be (as I compose it):
Rachel’s camel rides,
Hiding idols deep inside,
Father watches, frowns.
If one could write a verifier, once can also write a generator. What approach do we use in my NLP class? I’ll give a broad sense. We make use of CMU’s Pronunciation Dictionary, together with NLTK. For each word in a line of poetry, we get the the stresses and calculate the number of syllables from that.
So, for my limerick, I have (slightly modified to give the idea):
The number of digits is the same as the number of syllables in the line. The 1s are stressed syllables and the 0s are unstressed.
So, if an AI could really know what a haiku, limerick, or nursery rhyme was, then it could perform these calculations to confirm it was producing something appropriate.