Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Artificial Intelligence experiment

by PerlGuy(Tom) (Acolyte)
on Feb 03, 2020 at 05:05 UTC ( #11112307=perlmeditation: print w/replies, xml ) Need Help??

I'm not really sure why, life experience I guess, but while studying and practicing Perl programming, an idea for artificial intelligence flashed into my mind.

I guess the idea came from a realization that human interaction in general, especially conversation with strangers, is often very shallow and superficial, we learn to behave in a pre-programmed way from early childhood. When someone says "thank you", we are taught that we are supposed to say "you're welcome". Perhaps I had been reading too much P.D. Ouspensky.

Using Perl, I had the idea that I could write a program that could learn to respond the way it's supposed to, the way children are taught to say please and thank you.

If someone says: Good morning, what is our habitual automated response? We say Good morning in reply.

Is AI any different? Or put another way, are our own responses so automatic and habitual, could we tell the difference?

So I wrote a kind of mock artificial intelligence program and put it up on the internet so it could talk to visitors and learn from them the proper and correct things to say (and sometimes not so correct or proper, depending on who visits the page and does the teaching).

I must have written a "Bot 1" because I've called the program "Bot 2".

Bot 2 has been online for many years. Few people have visited Bot, as far as I know. I don't keep track, but he(? I think he's a he, or genderless) has been gradually learning new responses, which I did not teach him.

The program is really two programs.

Talk to Bot, until you hit on a phrase or combination of words he hasn't learned a response for. That will put him into learning mode. Really this loads an interface to a second program, the purpose of the second program is to open the main program and rewrite it with a new response. Type in an appropriate response, and next time Bot encounters the statement or phrase or question, he will know how to respond.

Surprisingly, the program has grown very little. People seem to run out of things to say or talk about rather quickly. Or maybe talking to an AI makes them uncomfortable.

I talk with bot very occasionally, and am always surprised and delighted when he says something completely off the wall I never would have expected. It can be hilarious.

Feel free to talk with bot and teach him anything new, if you find something he doesn't know how to respond to yet.

I would like to work on the program a little more, if I ever find the time. So he has a little more flexibility to choose between responses and make things a bit more interesting.

Perhaps he could learn to recognize visitors through the environment variables.

Any suggestions, criticisms or ideas are welcome.

One warning. Bot can sometimes be very rude and use foul language. His responses are uncensored. I don't even know what he might say. I suppose he is also multilingual if anyone were to talk with him and teach him in another language.

Bot 2

Replies are listed 'Best First'.
Re: Artificial Intelligence experiment
by marto (Cardinal) on Feb 03, 2020 at 08:25 UTC

    "Surprisingly, the program has grown very little. People seem to run out of things to say or talk about rather quickly. Or maybe talking to an AI makes them uncomfortable."

    I don't find it surprising. Back in the late 1970s/80s the growth in home computers and the porting and forks of ELIZA to various platforms introduced many to this concept. Later people made such programs available online. Your example resembles many of the early web based examples I remember, though all of those can recall had a submit button for the form. This looks antiquated, and to me seems unlikely to engage people these days (get off my lawn etc...) for any length of time. Even 'back in the day' people got bored once they became familiar with the algorithm. Tay had the plug pulled less than a day after launch when twitter users 'taught' it, perhaps unpopularity isn't a bad thing.

      Thanks! The article about ELIZA is hilarious, in that this AI "doctor" was also based on the principle of the superficiality of communication, and how many people were fooled, feeling like they received real help from an apparent psychotherapist.

        I was leafing through Lincoln Stein's "Network Programming with Perl" (2001 edition), and found something not mentioned in the Wikipedia article about ELIZA.

        There is a Perl clone: Yay! Something new to play with!


        PS: (command line - wondering if anyone has created a web interface already. Probably. If not, anyone care to take a stab at it?)

Re: Artificial Intelligence experiment
by QM (Parson) on Feb 05, 2020 at 11:16 UTC
    You'll want to be wary of the Tay bot problem, that is, having malicious input skew your bot's training.

    Quantum Mechanics: The dreams stuff is made of

      I'm not really sure I see that as a problem.

      One person's skewing is another's inovative new killer app.

      Anybody can train Bot to do anything they like.

      Create a bookmarking service, FAQ, help desk. etc.

      For example, you could ask Bot, "Where can I find out about Perl?"

      If he responds, "I don't know..." "Tell me..." Type in, using html: <""></a> and next time someone asks, Bot will respond by providing the direct hyperlink to PerlMonks.


        Now Bot has no real brain, so can't really distinguish between the questions: "Where can I find out about Perl?" And "Where can I find out about Perl 5?" And "Where can I find out about Perl Programming?" Or any other variation of the same question. Or rather he DOES distinguish, or does not relate one to another. So his answer can be different. His response is based on a simple character match in a hash.
        Program can be done to show similar questions based upon close match and then elevate that as a main question for the direct answers when sufficient inquires are made for that question for the same accepted answer.
Re: Artificial Intelligence experiment
by bliako (Monsignor) on Feb 09, 2020 at 11:17 UTC

    I think you could try having two bots talking to each other.

Re: Artificial Intelligence experiment
by cavac (Curate) on Feb 17, 2020 at 16:31 UTC
    Would you be willing to share the source code and the gathered data set?
    perl -e 'use Crypt::Digest::SHA256 qw[sha256_hex]; print substr(sha256_hex("the Answer To Life, The Universe And Everything"), 6, 2), "\n";'
      Sure, it's GPL, though it would likely be disappointing. And, the responses are unfiltered. I may have to obfuscate some of them. But I guess, it could be interesting, how much can be done with so little code. Sorry for the delayed response, but apparently I was blocked from posting due to having copy/pasted some text that contained some Unicode the spam filter didn't like.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://11112307]
Approved by kcott
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2021-10-16 14:01 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (69 votes). Check out past polls.