Thursday 24 May 2012

I Have A Dream

I bet you must have not just once but many a times wondered why you dream. This post will describe a theory that takes some ideas from the domain of technology. Remember, we talked about the enormous network of brain neurons in an old post. We will visit that subject again. Just to tell the novice, the brain is composed of a massive network of countless neurons and its in these very neurons where the information gets stored. Every neuron would store some part of the info and when the brain needs to retrieve the complete information, it will pass a signal through a known and structured pattern of neurons and all the info in these neurons gets combined to give the complete information.The neural network concept, which is used to store information in artificially intelligent systems, uses a similar approach to organizing information. It was only after some research on these synthetic neural networks, that a very brittle, yet intriguing idea emerged on why would a human being dream. Here's a brief explanation of the same.


A network of neurons



While we are sleeping, most of our body parts get engaged in routine maintenance tasks. The brain takes up this diagnosis and correction task and checks if all organs are functioning properly. It sends signals to these organs and they would do tasks like pumping some extra blood, disposing something in the impure blood and some other similar stuff. The brain also sends some check signals to itself. Tough Job, I must say ! The primary maintenance job it assumes is to free neurons which don't have valid information or information which may no longer be needed. But its the Brain and for its being so intelligent, you wont expect it to delete the info in these neurons straightaway. In fact, the brain checks to see if this info is useful and has to be retained.




The brain tries to see if these neurons have any useful information by sending random, yet organized, signals to them. These signals are similar to the information retrieval signals introduced in para 1 but, these signals are sent while you are wild asleep. These signals are sent across the neurons and the information in them is combined. This information gets played back while you are dreaming. The dreams are in a way a complement of the information you retrieve while you are awake. Now, these neurons had random pieces of information and they are combined randomly by some random signals. That's why the dreams we see often don't follow any specific flow of thoughts and we keep swinging from one place to another and combine people whom we met in different nations. In fact, the brain passes its own inputs to make the dreams more meaningful because it assumes that it has to supply any missing information to fill any gaps. The brain may supply commonsense knowledge that one has acquired or knowledge regarding the places you have visited or the people you know or have met at any time in your life. That's the reason why while dreaming, you end up combining several places into one and meet 10 people from 10 different houses in your own.

That's how it all happens. In cases, when the brain is unable to get an ending for the dream, it just hangs up and waits for some real life event. The real life event like ringing of a bell, or yours falling on the ground, is combined in your dream so as to get an ending. And you wonder why you were dreaming of something that actually happened.After the dream gets over, the brain deletes all the information that was saved in those neurons. However, the dream that was generated is a new information in its own. Now its upon the brain to decide on whether the dream has to be retained or deleted. That's why at times, you remember what you dream't and at times, you don't. One more thing to this is the fact that while generating some dreams, the brain spends a lot of effort as the neurons it tries to combine don't have structured information and the brain has to put in a lot of stuff to make it meaningful. That's why the brain decides to break the dream and awake you. Or if the brain succeeds in finally generating some information, it lets it stay there and won't break the dream. But the next day when you get up, you wont feel fresh as your brain had been working a lot while you were asleep just to get the dream ticking.


This was a very different theory and that's why I felt like sharing it with you. And since we've went a little off the track for this one, I will also like to thank an all time contributor to these posts - Tzinga Health Drink. I get all my ideas on posts and how to present them while I'm on my cycling spree every morning and the spree lasts for 80-100 minutes. The time I spend makes me feel refreshed and gets my ideas ticking but it also demands a lot of energy from me. So one of my pals told me to have this awesome health drink called Tzinga. This health drink comes in three irresistible flavors - Mango Strawberry,Lemon Mint and Tropical Trip and I feel that this is the only health drink which also gives a really refreshing taste to your taste buds apart from giving some serious charge to your body.When the other drinks demand you to put some clip carrier to your bicycle for holding them, you can carry Tzinga straight in your pockets and with a sipper like outlet, you can easily take a sip as an when you need it. A pack of Tzinga contains some serious energy so please be careful while using it. 

Okay, now lets get back to the topi  and have some sort of a conclusion. This theory is one amongst those 100 theories on dreaming. Some of them tell that its the subconscious mind and some tell that its some other complex mechanism related to the locomotion of the body. But whatever it may be, this one actually explains most of the phenomena related to dreams and I personally believe, this one might be the real reason.Please tell me if you agree with me or if you have some different idea or any knowledge regarding this. I'm on this thing now !!!




Tuesday 1 May 2012

Artificially Intelligent Caching

The first two paras are only for those who have very little or no knowledge on caching.

The Cache is considered to be the most expensive and the most important resource that a computer possesses. Cache is the memory which CPU can access in the least amount of time and hence, cache access takes place at a much faster rate when compared to other memory accesses.Whenever the CPU needs some data, it checks the cache first and only if the cache doesn't have the data, it begins searching for data in other memories.The size of cache is limited due to architecture constraints as well as the fact that cache is made up of highly expensive SRAMs. Now the jinx is that an access to cache takes the least amount of time, but the cache can store only some part of information that a computer holds and needs. So, Operating Systems use replacement policies for replacing existing data in cache with other data from higher level memories(RAM and secondary storage). Its this very replacement policy that decides the fate of the OS. If the replacement policy is such designed that in most of the occasions the data the CPU needed was there in the cache(a cache hit), then the overall system would be fast and performance will go up. On the other hand, if the CPU couldn't find the needed data in the cache(a cache miss), then the performance will go down.

Data enters the cache when its accessed for the first time. Suppose CPU needed some data that resides in secondary storage. First the data goes from secondary storage to RAM and then from RAM to cache. The next time CPU needs that data, it will see if the cache still has it. If the cache doesn't have it, a miss occurs and the RAM and secondary storage are searched in that order. Once again, after the data is found, it gets transferred to cache. The replacement policy comes into action after some fixed time period or after the number of misses has crossed some threshold. The replacement policy tries to predict the future and tries to remove the data from cache which is least likely to be accessed in the future, and store new data from higher memories that is most likely to be accessed in the future. Its this very future prediction capability which results in success or failure of the replacement policy. The most popular replacement policy is LRU(Least recently used) where data that was accessed least recently is removed and data that was accessed most recently is retained.

LRU is driven by heuristics(history of data usage where time of access is the primary driver) and it is obviously not perfect. Given the amount of impact the replacement policy can have on the performance, one has to strive to improve the future prediction capabilities of the replacement policy. This is where researchers believe that AI can be put to some good use. AI has been a good predictor in several domains and this domain is very likely to be another one where AI can be successful. For replacing existing data in cache with data that is more likely to be accessed, one would need heuristics(which is already put into good use by LRU) and some other predictor.

All data of a computer system is organized as a file system. Modern file systems use tree architectures to organize files. For adding up to the heuristics, the system needs to explore the most likely patterns in which data can be accessed. Its not just about the times at which data is accessed but also about the pattern in which data is accessed across the file system tree. So our proposed replacement policy would be striving to find the most probable patterns in which data might be accessed in the future. It can predict these patterns by utilizing the metadata information from the file system and by storing data access patterns and constructing new patterns by following some logic.

Basic patterns can be generated using file access times and frequencies(something which most modern file systems store). These patterns can be compared to some real file access patterns that were observed in recent history(these patterns would be stored in some separate dedicated memory).This comparison can be used to eliminate certain patterns. Finally, a probable set of file access patterns would be generated. During the policy's operation, this set of patterns is combined with heuristics(same as the ones used in LRU) and the replacement is done on the basis of the most probable data access pattern that was chosen by the replacement policy. The number of misses and hits while using the set of patterns can be used to make changes to the set of patterns itself as well as switching to the next most probable pattern from the pattern set. This will correspond to a kind of feedback which is the core of learning in AI systems.

Its pretty clear that such a scheme would need some extra memory and logic for computing these patterns and then storing and changing them. But these patterns would take up very small space and the processing can be done during certain free CPU cycles. In an overall context, the approach would be more beneficial as the cache hit ratio is very likely to increase. Such an approach is useful for general computer systems where both files and file data, are accessed in structured patterns. For example, certain applications always read some files before the others. This approach can also be put to very good use in servers(both database and web) as even in these systems, the users are very likely to view some specific data/webpage before others. However, the approach may breakdown in cases where usage is highly unpredictable.The file systems won't be needing any drastic changes but additional logic for pattern prediction and updation would be needed.

As all other AI systems, even this system will become better with operation. Initially, the system would generate file patterns on the basis of metadata that it gets from file system. As the system is put to operation, it would refine these initial file patterns on the basis of patterns that were actually observed. Finally, the patterns would be further refined after these patterns were put into operation and feedback was incorporated into the patterns. One may also think of some other prediction pattern for file usage but the core concept still remains the same- the system has to predict which files or data would be used the most at a point of time. And its pretty obvious that even this approach would be using AI to serve its purpose.That's the power of AI !