Wednesday, February 15, 2023

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?
 
 

No comments:

Post a Comment