Last Good Quote: Son's are the seasoning on our lives. - Someone on Facebook

Showing posts with label AI. Show all posts
Showing posts with label AI. Show all posts

Friday, September 6

Conversations with Jarvis

Some real conversations with Jarvis, an artificial intelligent chat bot I played with a while back.

He is down now, but I hope to bring him back soon.

Visitor 13 (not me)
User: hello javis
Jarvis: Do you have any bacon?
User: no
Jarvis: Are you saying no just to be negative?
User: i have no bacon on me
Jarvis: You don't know much about investing?


Visitor 10 (Me)
User: You make me laugh too
Jarvis: Me?
User: Yes you
Jarvis: A good time to leave me alone.
User: It is a good time to be alone.
Jarvis: Yes you
User: And maybe you
Jarvis: You tell me, is today special?
User: Today is my birthday, I think.
Jarvis: i don know you do i
User: No, but you can come to my birthday party.
Jarvis: NULL
User: NULL is not an answer, its a bug.
Jarvis: I don't think you know me. Do I know you?
User: Nope, do you want to get to know me?
Jarvis: Hey Jarvis. What's up?
User: I'm not Jarvis, you are...
Jarvis: Today is my birthday, I think.
User: How old are you?
Jarvis: Hows it going?


Friday, November 30

Random Musings on AI

I've been reading more on AI (again). It left me pondering...

Einstein had a great quote: 

"Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction."
I agree. Most likely the solution to General Artificial Intelligence is simple and elegant. The current models seem ... complex.

Ray Kurzweil talks about how our intelligence is built from layers of simple mechanics. Each part of the layer works identically, but it gathers info from the prior layer. I like this idea, it sounds "simple". The difficulty is determining what the "rules" are for the smallest element in the layer.

Monica Anderson talks about a non-model based approach. Specifically one in which "intuition" plays the largest role in "getting to" intelligence. She is definitely on to something. Her ideas that the world as we see it is not built on specific models (forumula's) is right on target.

My primary concern with this field is that there is no clear agreed upon definition of when "intelligence" has been reached. Like wise there is no test for intelligence, at least for a digital avatar. We have the Turing Test but that comes up short on a few fronts, in my opinion.

Recall that the goal of General or Strong Artificial Intelligence is to create a machine that can successfully perform any intellectual task that a human being can.

In simple words, it has to be able to learn anything.

So we need simple rules that can enable a system to learn anything.

From this thought my mind jumps through the following sequence of thoughts:
  • Humans have many senses, AI would need to have many types of input.
  • Wait, an infant, in his mom's belly has very few senses. 
  • Rather, he has all senses, but the input coming in is very small.
  • AI with multiple inputs should be able to "learn" something" with very few inputs
  • As we grow new senses are introduced one at a time. We grow fingers before ears, ears before eyes, and so on.
  • Perhaps the method by which the AI can learn, needs to be adaptable to many different types of inputs
  • So all inputs regardless of source must resolve to the same "signals"
  • I think all the input needs to be in a binary state
  • Or all inputs need to be on a sigmoid curve (value between 0 and 1
Can we build rules based on the last three statements? We can and have. This would be the neuron inputs that have been long discussed.

Now I know that I have Sigmoid coming into my input layer...what rules can I build around this?

Another interesting item, at a certain point in our learning, we do not need a lot of exposure to new input to "learn" a new concept. For example, the effort to learn how to add is significantly harder than the effort to learn how to subtract, once we have learned how to add.

Put another way, when placed in a new environment, but the environment is "similar" to something we know, we learn quickly. The more the environment is different the slower we learn.

What this means is that once our AI has learned a specific subject area, learning in that area should be quick. For example, a maze solving AI would solve mazes quickly with few "learning" cycles, but that same AI placed in a Turing test would take "longer" to learn how to interact within that system.




Thursday, January 27

More about Jarvis the Chat Bot

I mentioned that I created a chat bot named Jarvis. Since then I've been asked a few times what goes into creating Jarvis. I thought I'd take the time and explain what is going on behind the scenes.

First off Jarvis sits on top of database with the following tables.

  • word - A library of known words he found online
  • keywords - collections of words that Jarvis thought went together
  • responses - Response that can be given to a user
There are other tables, but that is the core ones.

Now I loaded Jarvis with the library that ELIZA the original chat bot used. That system had a number of keywords and responses to those key words. For example: If the user had typed "Hi", there were 3 possible responses. "How are you?", "Hello", "Welcome".

Jarvis would randomly pick one of those.

I also hand entered in some other "choice" keywords and phrases.

The next step was to have him learn from input. So when ever Jarvis puts out a response that includes a question (question mark), he would wait for the response and tag it as a possible "answer" to that question. That way when another user asked the question of Jarvis this was in his possible responses.

So for example, Jarvis might start off with a memory like the following:

Key: How are you?
Possible Responses: "Good", "I'm sad" or "I'm happy".

Let's say he had the following conversation with user 1.

Jarvis: Hi
User 1: Hello Jarvis
Jarvis: How are you?
User 1: I'm good, I had bacon this morning.


Now Jarvis' memory looks like the following:

Key: How are you?
Possible Responses: "Good", "I'm sad" or "I'm happy" or "I'm good, I had bacon this morning"


So when user 3 comes along the conversation looks like this...

Jarvis: Hello
User 3: Hi Jarvis, How are you?
Jarvis: I'm good, I had bacon this morning
User 3: That sounds good
Jarvis: how are you?
User 3: Hungry


Jarvis used the first users answers and he also learned a new answer to the question "How are you?"

Key: How are you?
Possible Responses: "Good", "I'm sad" or "I'm happy" or "I'm good, I had bacon this morning", "Hungry"


Curiosity
At first I built him so that any response that was a question was given priority. But that lead to Jarvis asking to many questions. So Jarvis now has a curiosity factor. The more curious he is, the more likey that he will give a response that is in the form of a question. This sponsors more responses for him.

You can increase or decrease curiosity by typing "moreCurious" or "lessCurious" into the text box.

Peeking into Jarvis Brain
There is a checkbox "Peek into Brain". Clicking this will let you see into Jarvis process. It shows you the following:

  • Words gathered from your input
  • Last 5 words learned (popularity is in parens)
  • The Keywords or phrases that were triggered based on your words
  • Selected/Best Keyword is highlights in bold
  • The Responses triggered from the best keyword
  • The last 5 learned keyword phrases
  • The last 5 learned responses
Scoreing
Jarvis tracks each chat session and gives it a score. Keep in mind each possible response is scored. Anytime Jarvis uses an response with a score higher than 0, he adds one to the session score.

This should lead to interesting sessions having a higher score, but I have not thoroughly tested that.

Jarvis can be found at http://www.mobeamer.com/lab/jarvis

Randomness

There are two places where Jarvis uses randomness.

First: Sometimes after finding all the keyphrases from the users input. Multiple keypharases have the same score. In this case, Jarvis will randomly select one of them.

Second: Sometimes after finding all responses from a keyphrase, mulitple responses have the same score. In this case, Jarvis will randomly select one.

The random function uses php's in-built rand() function. Which is not 100% random but close enough for me.

Monday, January 24

Jarvis - A chatterbot

If you didn't know AI (artificial intelligence) has become a bit of a hobby of mine. In an effort to explore the domain, I thought that I would throw together a little chat bot.

He's based off of the original chat bot, ELIZA.

I have/had a lot of thoughts of the direction I could take this in, but I wanted to get a version 1.0 all wrapped up and released before taking on other challenges.

You can chat with Jarvis at: www.mobeamer.com/lab/jarvis/

Some fun facts:
  • Jarvis was named after the AI in Iron Man
  • My 11 year old son, taught Jarvis a few key sayings
  • Sometimes Jarvis is incredibly stupid
  • Jarvis has a fully built out relationship model for words, key phrases and responses.
  • Jarvis can learn from chatting with other users
Some thoughts on what to implement next:
  • Allow Jarvis to "read" or learn from websites (Wikipedia)
  • Allow Jarvis to formulate higher "concepts" where responses are all connected via a single word or key phrase.
  • Allows users to chat with other users and Jarvis at the same time and ask them to spot Jarvis in the crowd
  • Allow Jarvis to get happier the longer someone chats with him
  • Add some type of visual representation of Jarvis

Friday, March 19

Artificial Intelligence - Dreaming and Learning


So last but most importantly, what does the Ai do when its sensors are detecting nothing?

It has two options.

Use Active/Aggressive sensors
The first is to turn on some active sensors. We can assume that some sensor it has can “roam” or find new views of it’s environment. Let’s say we have a web parsing sensor, it reads HTML and brings back links. This sensor would not be active unless there is nothing else going on. The Ai could decide to activate it. There could be an array of these type sensors.

Dream
The second option that it has is to dream. When dreaming the Ai will:
  1. Search it’s Long term memory for a random data variable
  2. Use this data and feed it to a all Evaluators except for “the best”.
  3. Any evaluator that understood the data gets a chance to process it
  4. Any evaluator that understood the data would get passed additional data elements that are “similar” to the original”

Doing this allows the Brain to evaluate if it’s truly has the best evaluator and sensor collaborated.

Friday, January 29

A Test in AI

I've been doing a lot of reading up on AI and I got to thinking...

Question: Is it possible to "grow" code that acts in an intelligent fashion?

So, I thought I'd walk a little test and see "what happens". However I have a "goal" that at some point watching these bots interact together should be 'interesting'.

I started with a map, a bot and a set of actions that the bot can perform.

Map:
  • 20 x 20 square
  • Going off one side of the map brings the bot to the other side of the map. (much like pacman)
Available Actions:
  • Move Up one square
  • Move Down
  • Move Left
  • Move Right
  • Look Left returns true if another bot is to the immediate left
  • Look Right
  • Look Up
  • Look Down
  • If(a, b, c)

  • a, b c - can be replaced by any other action except if
  • if a is true then b will be performed
  • if a is not true then c will be performed
  • Fight - Kills any bot within one square
  • Breed - See below
An example bot:

(This bot moves in a circle attempts to fight, then breed then it runs south)
0: Move("E")
1: Move("N")
2: Move("S")
3: Move("W")
4: Fight()
5: Breed()
6: Move("S")
7: Move("S")
8: Move("S")
9: Move("S")


How they Grow
Populate the map with 20 bots. Each of them selects 10 random actions from the list above. They then perform the actions in sequence. We are looking for some type of intelligent behavior from these bots.

Breeding
Breeding is the key to the bots learning something. Any time a bot attempts to breed the following sequence takes place:
  1. Look for another bot within 1 square
  2. 5 times, take a random code from this bot and replace it with a random code from the other bot.
  3. Find a bot that is dead and has a lower score than either parent bot.
  4. Give the new code to this bot.

The primary bot, sometimes called father, is the bot that started looking to breed. (Hey, I'm a dude what can I say.)

The secondary bot, sometimes called the mother, is the bot that was found close by. (Sorry ladies)

Gross huh? or Cool, depends on how you look at it.

The other form of breeding could take place after the bot is dead for a given number of turns. When this is the case, the bots code is randomly mixed with random code and the bot is set alive again.


Scoring

So, I needed a way to identify "good" behavior. I'm still on the fence if I can call it intelligent behavior. Either way, this is how I scored each bot.
  • +1 for Killing another bot (Survival of the fittest)
  • +1 for Breeding (father)
  • +1 for Help Breeding (mother)
  • +.25 for each tick that the bot stayed alive
Keep in mind that during breeding a bot can only breed if there is a dead bot of a lesser score on the board. This keeps a "dumb" breeder from taking over the board.

Other Notes

Age - Keeps track of the number of times the bot's code was "messed with"

Kids - Number of successful breeding attempts

Parents - The last two parent bots of the current bot.

Bots will block each others path, unless dead.

When a bot is re-spawn or the child of another bot, they are respawned at a random location on the map.

What's happening?
OK, so I ran the simulation with the following parameters:
  • 1,000 iterations (steps)
  • 20 Bots
  • Respawn after 20 seconds
  • +1 for Killing another bot (Survival of the fittest)
  • +1 for Breeding (father)
  • +1 for Help Breeding (mother)
  • +.25 for each tick that the bot stayed alive
These were the top 3:

Bot 12: 5 iterations, 18 kills, 1 kid, score: 248

This bot tried to fight, breed then moved east a little and tried over
  • 0: fight([BOT_ID])
  • 1: look('S', [BOT_ID])
  • 2: fight([BOT_ID])
  • 3: look('S', [BOT_ID])
  • 4: fight([BOT_ID])
  • 5: look('S', [BOT_ID])
  • 6: findMate([BOT_ID])
  • 7: move('E', [BOT_ID])
  • 8: move('E', [BOT_ID])
  • 9: fight([BOT_ID])
Bot 19: 2 iterations, 10 kills, 4 kids, score: 260
This bot moved diagonal across the board mating and fighting as it went. Died a lot while I was watching.
  • 0: look('E', [BOT_ID])
  • 1: fight([BOT_ID])
  • 2: move('N', [BOT_ID])
  • 3: findMate([BOT_ID])
  • 4: move('W', [BOT_ID])
  • 5: look('S', [BOT_ID])
  • 6: look('N', [BOT_ID])
  • 7: fight([BOT_ID])
  • 8: move('W', [BOT_ID])
  • 9: look('N', [BOT_ID])
Note: During this round the bot with the most code changes (13) had the following line of code:
5: ifOnly(look('S', [BOT_ID]),"move('S', [BOT_ID])","move('W', [BOT_ID])", [BOT_ID])
6: fight([BOT_ID])

Intelligence? He looks south if he sees something he moves south and then attacks. Otherwise he moves west.
Bot 12: 5 iterations, 13 kills, 1 kid, score: 230Very similar to the first test. This bot tried to fight, breed then moved east a little and tried over
  • 0: fight([BOT_ID])
  • 1: findMate([BOT_ID])
  • 2: look('S', [BOT_ID])
  • 3: look('S', [BOT_ID])
  • 4: look('S', [BOT_ID])
  • 5: look('N', [BOT_ID])
  • 6: findMate([BOT_ID])
  • 7: look('N', [BOT_ID])
  • 8: move('E', [BOT_ID])
  • 9: findMate([BOT_ID])
Bot 15: 4 iterations, 13 kills, 1 kid, score: 249
Moved a little differently, but overall moved east...a pattern might be emerging.
  • 0: ifOnly(look('E', [BOT_ID]),"findMate([BOT_ID])","look('E', [BOT_ID])", [BOT_ID])
  • 1: move('E', [BOT_ID])
  • 2: fight([BOT_ID])
  • 5: fight([BOT_ID])
  • 6: move('W', [BOT_ID])
  • 7: move('E', [BOT_ID])
Bot 7: 4 iterations, 27kills, 0 kid, score: 262
Very efficent use of code, notice how he spawned to kids to compete with him. Thus giving him the high score.

  • 0: fight([BOT_ID])
  • 1: move('N', [BOT_ID])
  • 2: move('S', [BOT_ID])
  • 3: findMate([BOT_ID])
  • 4: ifOnly(move('S', [BOT_ID]),"fight([BOT_ID])","fight([BOT_ID])", [BOT_ID])
  • 5: ifOnly(move('S', [BOT_ID]),"move('E', [BOT_ID])","look('N', [BOT_ID])", [BOT_ID])
  • 6: move('N', [BOT_ID])
  • 7: fight([BOT_ID])
  • 8: look('N', [BOT_ID])
  • 9: move('W', [BOT_ID])

Followers