Wednesday, February 15, 2023

ChatGPT Teaches Ogden Nash How to Do Shakespeare

 If Ogden Nash had rewritten Hamlet's famous soliloquoy, he might have come up with this:

An Ogden Nash version of Hamlet:
To be or not to be, that's quite a question
A real head-scratcher, a thought-provoking suggestion
 
Is it better to exist or to never have been?
Is life a feast or a famine, or a tasteless cuisine?
 
To live, to sleep, to dream, what's the fuss?
In slumber we're kings and queens, nothing's too much
 
In that sleep of death, what dreams may come?
A symphony of wonders, or silence and humdrum?
 
To take arms against a sea of troubles, or to flee?
That's the million-dollar query, the root of the spree
 
The heartache, the thousand shocks, it's all a part of the game
We play it by ear, and sometimes it's a shame
 
To die, to sleep, to dream, it's all just fate
A flip of the coin, who knows what's on the plate?
 
And thus, the play's the thing, it's where we have our fun
We're all just actors, in the grand scheme, a comic pun

The Beatles Goes to Prison -- Folsom Prison -- and rewrite "The Fool on the Hill" (with a little help from ChatGPT)

 Here's an example of how well ChatGPT can understand things:   I told it to rewrite the lyrics to "The Fool on the Hill" to match the rhythm and meter of Johnny Cash's famous hit "Folsom Prison Blues."

Here's what it came up with:

Well, I hear there's a fool, up on that hill, Watchin' the world, with a heart so still, He ain't like the rest, he's got his own pace, And he sees the world, in a different way.

He don't care 'bout the money, or the fame, He's got his own way, and he won't play the game, He's just happy with his own simple ways, And he'll keep on smilin', through all his days.

The fool on the hill, he's got his own view, And he don't care 'bout the things that we do, He'll keep on smilin', through thick and thin, And he'll be happy, with the life he's in.

So don't you judge him, for his different way, He's got his own rhythm, and he'll dance all day, And if you listen, you might just hear, The beat of his heart, and the rhythm of his cheer.

The fool on the hill, he's a lesson to learn, That life ain't always, what it may seem, So take a step back, and hear his tune, And you might just find, your own new groove.

Oh, the fool on the hill, he'll keep on goin', Through all of life's twists and turns, he'll keep on knowin', That the world may change, but he'll stay the same, And he'll keep on smilin', through sunshine and rain.

 

The Dawn of Semantic Search with the Advent of GPT-3 and ChatGPT

This blog has lain fallow for a couple of years, but has now reawakened with the help of openai's large language models.  ChatGPT and GPT-3 are amazing tools.  It is not only ChatGPTs impressive ability to answer questions but, moreover, it is its ability to dialogue with humans and understand our questions that amazes me.

Here's an example:  Years ago I struggled to find a Prolog predicate that would efficiently generate all the subsets of a given set.  I looked on stacktrace, at SWI-Prolog's web site.  I downloaded code that claimed to work but to no avail.

Today, in a matter of minutes, ChatGPT was able to generate this very simply pair of predicates that can generate -- very efficiently, as far as I can tell -- all the subsets of a given set:

% generate subsets of a list
subsets([], []).
subsets([X|Xs], [X|Ys]) :- subsets(Xs, Ys).
subsets([_|Xs], Ys) :- subsets(Xs, Ys).

% generate all subsets of a set
all_subsets(Set, Subsets) :-
list_to_set(Set, SetUnique),
findall(Subset, (subsets(SetUnique, Subset), length(Subset, N), N > 0), Subsets).


The subsets/2 predicate (which I would probably relabel subset/2) is so simple 
and practically obvious. Why couldn't I conceive of this?