Monday, April 9, 2012

Artificial Intelligence v/s Developer Part 1 - What the hell is this?

I am not sure whether I am the right person to talk about AI because I passed that exam in my 2nd or 3rd attempt during the B.E days. The reason why I didn't give much attention to that is I never thought I will get a chance to write an Artificial Intelligence program in my life. Only thing I was concerned on those days was about whether the AI will contain if...else statement or something else. Our HOD who took that paper was always telling that it was not an if...else program.

From those days I was in search for only one thing related to AI. Whether AI use if...else or something else. Saw some programs which the creators claim that it has AI including famous iPhone Siri .But to me, it felt that they are just presenting the error codes with polished English words converted to voice. Also I never got a chance to see source code of any AI app.

Time passed away and now I feel that I may be writing an AI program or at least will get a chance to see somebody writing an AI program and the source perhaps. This is based on some meetings with high level management of my current company which may change at any time. From the delivery point of view it is better to hire an experienced AI programmer which reduces training cost just like how I was hired for WPF & Silverlight. Anyway these meetings together with an idea of having "Voice Based Information Retrieval" system made me to think on how to implement an AI program. Being in the position of technical lead really I felt ashamed to say "I don't know how to write an AI program to convert a voice input to corresponding query commands which learns itself and finds more command patterns."

I normally hate theories .But here there is no other way without some theories.

What is intelligence

In my words "it is the art of taking decisions based on experience and acting with a feedback mechanism". Now what is experience ? It is the collection of results of previous decisions. There is no rule that the experience must be one's personal. It can be from other's experience which means from books too. Only difference is the result is not straight away suitable for the other one. ie If the result of one decision may be +ve for one and may be -ve for another one.

Ok "Results". These are the actual factor determining or influencing the art of taking decision. If the experience is ours we should give more weight to it's result than the experience of others because it proved for us. Also if we see that the experience from one particular source is giving us consistent +ve results ,don't wait to give more weight for their results.

Simply saying we are building a knowledge base and it's true that the intelligence is directly proportional to the size of that knowledge base, speed retrieval and power of processing.

What is artificial intelligence

We know how a human is possessing intelligence. If a program has got the same capabilities it's intelligent. But as being humans and we don't want anything to be like us so we simply call it as artificial intelligence because we give it the capacity or ability to become intelligent.

Machine learning

Before we think about how machine learns, we should think about how a human learns? A fresh machine installed with an AI program is clearly compared to a child. So let's start with how a child learns? Before that if we analyze the child, it / he/ she has an installed capacity of memory which functions fast based on a cache of recently accessed information and stores information as linked to each other, a high / light speed processing unit called brain,good 5 types of sensors and various out put mechanism to act the decisions which are well connected to the processor and memory.

These things are the essential requirements for building intelligence.Ok lets start from the time the child is born.As long as the sensors work properly, it will feel hunger. The brain / processor searches the knowledge base.Oh Nothing !!! If no decisions can be taken on that input take the default decision and act. What is that ?  Its simple. Just "Cry" .Even this is the default action when a he/she grew up and finds no experience in her knowledge base :-) . For developers, this is what we call hard coding / default value.

I am not sure about the western community and the Yo-Yo community in India.But a normal communities  around the world enforce the right to get mother's milk. Coming to the learning point what child learnt from it's sensors? The feeling of hunger is gone away and it seems this is an good external experience source for me. Yes it started the learning process.

Next time when it feels hunger it will look at mother without crying. Mother may understand it, else it will cry and soon a communication will establish between mother and child through eyes. Yes it learned how to communicate.

I am not a good writer or a communicator .But I believe readers got the idea and can assume how the next steps will occur. Hey...we were all experienced the same. The child sees other people coming to visit and if they brought something interesting to it such as food or toys, it adds as external experience sources. "Something interesting" here means whatever it feels through it's sensors. As the best interesting things are coming from its mom & dad, it give more weight to their experience and results.

Learning from external sources

Just put for the sake of heading. We already covered the topic.

Self learning / learning using random attempts

The child / baby became kid. I think this is the right word to denote someone who just learned how to walk and talk. Someday he happened to be alone for some time in the kitchen. His eyes sensed something on the cooking table. Yes his brain starts processing the sensed data using the experience obtained. No luck. Its empty .This time not defaulting to the cry action as it is not directly causing any problems to him. But based on the quality of the program in his brain, he may or may not decide to expand his experience. If he decide to expand the experience,  he need to make use of the concept of random numbers. There are options that he can gain more knowledge by lifting or touching it using his another sensor named hand. Or he can move close to that and feel whether its hot or not by sensor named skin. In short by selecting a random number and using his sensors he creates entries and build a database of experience or lets call this time as knowledge .If hes too smart ie created with efficient program, he will gain knowledge on how to destroy that too:-).

I mentioned the quality of the program. But I think there is no separate programs as the program is simple as an execution engine of stored experience. But the speed of execution and storage capacity may vary based on the hardware. Later some point if somebody instruct him to observe everything he will start observing things.Isn't it?

Interesting thing here is how he store the data about the object he observed. If my knowledge about brain functioning is right he keeps the image of that object in high speed small sized cache memory and everything else in the slow speed big memory but linked to the cached image. This help him to recollect details easily on seeing that object at a later point of time.

Hybrid learning

No need to explain more. When his mom is back he asks her what is that thing? She answers "Oh this is the frying pan which I used to prepare your favorite omelet'. He puts the name 'frying pan' in his cache as this is the key to identify that object later.

Developer meets AI ie The algorithm

As a developer I don't want to stop a blog post without single line of code. Here is a quick algorithm I and one of my colleague derived last Thursday. I don't think this is a complete one and you can directly start coding. Because nobody wants to reveal their trade secret :-)

IEnumerable<Sense> senses=GetAllSenses();
Experience feasible = null; //This can be a collection I think.
foreach(Experience exp in AllExperiences)
         if(exp.MatchSenses(senses) && exp.HasAtleastOneSuccess()==true)
                if(exp.BetterThan(feasible)) //BetterThan() must take care of whether its own exp or external weigth  of source etc...
if (feasible!= null)
        feasible.UpdateStatistics();// Includes changing the priority,weight of the source etc...
if(feasible ==null)
        for(;;) //Here threshold value can come.


If you has seen one of my recent facebook status,you will feel that I believe "if somebody built a truly AI system it will never close itself" .Or it will learn how it can survive itself from the early operations of Alt+F4 & Close button click. This is what I believe happening exactly between human and it's so called creator God.

What next?

If I managed to get a laptop, you can expect the below posts soon .But anyway these posts will appear on this blog over time.

Artificial Intelligence v/s Developer Part 2 - Why somebody invented the concept of random number?
Artificial Intelligence v/s Developer Part 3 - Sensing & acting / IO devices and communication.
Artificial Intelligence v/s Developer Part 4 - Multi-core processors,MapReduce & Hadoop
Artificial Intelligence v/s Developer Part 5 - Are you ready to do some AI apps like this?

Thanks to the daily 1 hr long lunch and tea time we have outside the Kochi Infopark near to the bank of a small river where these types of ideas evolve. I will miss it soon as some rules on tea time is getting enforced.


Blogger said...

You could be eligible to get a Apple iPhone 7.

Blogger said...

Ever wanted to get free Instagram Likes?
Did you know you can get these AUTOMATICALLY & TOTALLY FOR FREE by registering on Like 4 Like?

Blogger said...

If you want your ex-girlfriend or ex-boyfriend to come crawling back to you on their knees (even if they're dating somebody else now) you gotta watch this video
right away...

(VIDEO) Win your ex back with TEXT messages?