Tuesday 9 May 2023

AI framework for self learning Q&A agent

 Pantomath AI bot framework

Definition: A pantomath is a person who wants to know and knows everything.

What is Pantomath

Pantomath is an AI framework inspired by human learning pattern developed with ZERO cost using ZERO propriety software or framework using open source R that can learn any subject and respond to a query when asked about it. It can learn any domain, topic and subject and keeps getting better and more knowledgeable with time and experience.

Why Pantomath?

· Pantomath has been designed on the idea of general AI which has the capability of learning different domains.
· While different enterprise solutions may be present they concentrate towards a particular domain
· It has been developed from open source framework hence there is no attached proprietary price.
· Business can easily enable Pantomath to automate FAQs, knowledge management, menu handling, computer trouble shooting etc.? If anything that has the pattern of resolving a query and does not need a detailed conversation or diagnosis, Pantomath can scale extremely well and can save significant cost while improving Customer Satisfaction.
· It has one of the best research oriented, scalable, technical back-end developed.

Pantomath: How does it work?

Steps

1. Enter few sample Q&A on different topics for it to start the learning & conversation.
2. On given the sample it tries to learn how it can answer questions on same topics asked differently or similar questions on the same topic.
3. And with each conversation it reinforces and reconfirms its knowledge.
4. If it does not know a topic it confirms it does not know about it and asks for more knowledge materials or hints to be fed into it.
5. With more conversations it learns more about language subtlety and gathers knowledge about different topics. (Just like us).

Pantomath: How does it constantly learn?

Pantomath’s learning model has been inspired from David Kolb’s learning model and human learning pattern from birth to adulthood.

David Kolb’s learning model

1. Concrete Experience- (a new experience of situation is encountered, or a reinterpretation of existing experience).
2. Reflective Observation (of the new experience. Of particular importance are any inconsistencies between experience and understanding).
3. Abstract Conceptualization (Reflection gives rise to a new idea, or a modification of an existing abstract concept).
4. Active Experimentation (the learner applies them to the world around them to see what results). Reference: https://medium.com/@johnharrydsouza/david-kolb-s-cycle-of-learning-2777d150d09e#.xitj0ph53

Human learning development


1. After Birth – A baby is born with basic human instincts while it gradually learns initial movements.
2. Toddler – It starts interacting with environment, still learning basic movements with the guidance by parents at this stage being very critical.
3. Childhood – It has almost completed learning its basic movements, while most of its learning coming from interacting with environment while asking for guidance much less.
4. Adulthood – It has learned most of its survival skills from learning independently from environment while rarely needing guidance now.

Learning trajectory for the algorithm with experience
Similarly the bot with more experience and maturity needs less guidance and is more self-sufficient.

Pantomath: Stages of development

Text similarity – It is implemented using text similarity pattern matching and recommending responses that might be best suitable for the current question.
A string metric is a metric that measures similarity or dissimilarity (distance) between two text strings for approximate string matching or comparison. Corpus-Based similarity is a semantic similarity measure that determines the similarity between words according to information gained from large corpora.

Neural Net – After that we would like to implement an ANN (Artificial Neural Net) to understand the weightage of different words used in the conversation and recommend the best response.
Reinforcement learning is an area of Machine Learning. Reinforcement. It is about taking suitable action to maximize reward in a particular situation. It is employed by various software and machines to find the best possible behavior or path it should take in a specific situation.

Reinforcement Learning – Next stage would be assigning an agent to the bot which will interact with its environment and would be rewarded for the right response and penalized for the wrong response. Thus the agent with time will learn and adjust itself to better responses.
Neural networks are a set of algorithms, modeled loosely after the human brain, that are designed to recognize patterns. It is a network or circuit of neurons, or in a modern sense, an artificial neural network, composed of artificial neurons or nodes.

Working code example

The below sample use case is to feed Pantomath with sample computer trouble shooting scenarios.
Some records of the initial set being.
Internally it creates an auto mapping rule in its brain. Let’s see how the mapping table looks internally at each stage of conversation.
Initial stage, it creates auto tags for all the sample issues provided which would help it to recommend a solution using text similarity pattern via string metric. –
*Trouble shooting steps are as above sample and I haven’t rewritten them to save space.
Scenario 1 - Show a result based on probability match
First issue we asked the bot –
mouse not moving correctly
Bot suggests –
"Check if the mouse is securely plugged into the computer. If not, plug it in completely.\r\n· Check to see if the cord has been damaged. If so, the mouse may need replacing.\r\n· If you are using a cordless mouse, try pushing the connection button on the underside of the\r\nmouse to reestablish a connection.\r\n· Clean the mouse, especially on the bottom.
Which if we move up on the sample provided we see is a solution for the issue –
Then the bot reconfirms if I am happy with the solution it provided. If I say YES, it responds.
"Glad to hear i could help and it has made me wiser"

Scenario 2 - Store queries which it could not resolve
Next scenario let’s try to ask a question which it may not know and needs to learn externally.
Let’s ask-
Not able to use the mouse
Bot says
Sorry i can’t help you regarding this. I will pass you to the next level engineer
And we see in its internal memory map it has made another entry with the new query and auto tags and there is no TroubleShootingSteps corresponding to it as it does not know how to solve it.

So the bot goes back to its human handler and tells this is a topic it does not know and haven’t been able to learn from the conversations and asks it to provide some knowledge.

Scenario 3 - show multiple options ordered based on similarity - learn based on the option chosen - Next time show the better option
Next scenario let’s try to ask a question for which it may have multiple recommendation
Let’s ask-
"keyboard problem"
Bot gives two recommendation
[1] "Make sure the keyboard is connected to the computer. If not, connect it to the computer.\r\nIf you are using a wireless keyboard, try changing the batteries.\r\nIf one of the keys on your keyboard gets stuck, turn the computer off and clean with a damp\r\ncloth.\r\nUse the mouse to restart the computer."
and
[2] "Clean the keys thoroughly"
BOT then asks me to confirm which actually solved the ticket so that it can refine its learning. I said 2 as the second recommendation solved the ticket for me. Bot responds -
"Glad to hear i could help and it has made me wiser"
And we see in its internal memory map it has made another entry with the new query and auto tags the number 2 solution for this question, so next time on being asked the same thing it can respond better,
So when again asked the same question
"keyboard problem"
It responds
[1] "Clean the key throughly"                                                                                                                                                          
and
[2] "Make sure the keyboard is connected to the computer. If not, connect it to the computer.\r\nIf you are using a wireless keyboard, try changing the batteries.\r\nIf one of the keys on your keyboard gets stuck, turn the computer off and clean with a damp\r\ncloth.\r\nUse the mouse to restart the computer."                                 
Interestingly on learning from its last interaction it now suggests Clean the keys thoroughly as the first option and the other one as the next option.  

Scenario 4 - The user does not like any option chosen, store queries which it could not resolve
Next scenario let’s again try to ask a question but we don’t choose its recommendation
Let’s ask-
“The mouse is slow"     
Bot gives me a recommendation  
[1] "Restart your computer.\r\n· Verify that there is at least 200-500 MB of free hard drive space. To do so, select Start and\r\nclick on My Computer or Computer. Then highlight the local C drive by clicking on it once.\r\nSelect the Properties button at the top left-hand corner of the window; this will display a\r\nwindow showing …                                             
BOT then asks me to confirm if I found the recommendation usable to which I said NO.
BOT responds –
"Sorry i could not help you. We will add content to fulfill your request in future."
And we see in its internal memory map it has made another entry since it realized it needs to learn more on this issue. So the bot goes back to its human handler and tells this is a topic it does not know enough of and asks to give more hint so that it can give a better hint next time.
What Pantomath is not
· Pantomath is not a conversational agent. It is a Q&A agent. Though it learns from each conversation and remembers how the user responded to its previous answers it does not remember personal conversational context or non-business critical facts.
· Pantomath is not a diagnosis tool. Though it may with time, learn to suggest recommendation for general questions, it is not build to find the root-cause using series of questions.
· Pantomath cannot go and open tickets for you in another environment. It provides information to the user, but it cannot take action for them.

Conclusion

Business on a daily basis employs enormous human resource to respond to user questions on various topics. While some of them need complex diagnosis, most of them are rudimentary and repetitive in nature. Pantomath can be easily deployed and scaled to automate a major proportion of this task. It’s an AI platform developed based on human learning pattern. It learns from conversations and asks for help wherever it needs, and gets more mature with time. It can adjust to any domain and learn any topic.
Business can easily enable Pantomath to automate
· FAQs
· knowledge management
· menu handling
· Computer trouble shooting etc.
If anything that has the pattern of resolving a query and does not need a detailed conversation or diagnosis, Pantomath can scale extremely well. It is extremely cost effective as it is completely build without using any third party enterprise component.

Saturday 29 April 2023

Guru Mantras – What works for a successful AI, ML & Data Science implementation

  • Value of the problem - Before you start solving your analytics use case, ask yourself – how significant the change will be for the business if you get the perfect answer to your question. If the change is not significant enough don’t even bother to start solving it. With enough data most questions can be solved but is it worth the effort ?
  • You get paid for the business solution not the technical engineering - The objective of your project should be a business problem or a strategic solution. If you see yourself solving a tactical or IT problem, remember you are impacting the means to an end but not the end.
  • We ourselves are the most advanced intelligence - Whenever you are thinking of a problem try to think how our brain would have solved it. Although our solutions are not as sophisticated as the brain they were all inspired by them Like when you basket a ball think how our brain considers different things like our height, distance from the basket, strength of the wind, our angle from the basket etc. and then determines the strength of our throw and how it gets better with time. So when you build the machine how it should process the same things and get better with time.
  • What is success ? Understand from your customer what success means to them. Define success as part of the project scope. Try not to promise any particular number that you will achieve as part of your algorithm outcome like 95% accuracy as part of the scope. Explain the algorithm outcomes. Try to explain what the algorithm does in a simplistic manner. The business will be much more open to include algorithmic outcomes as part of their decision making processes if they have some intuition of what the algorithm does.
  • Some MLs are black boxes. Understand that some ML models given enough data to train works. We actually tell it how to understand and process the data. We actually don’t know how internally it is differentiating. For example we are currently running a project to differentiate between a clean and messy room. And we have tremendous success but we really don’t know how it internally differentiates between the two.

  • Remember AI winter. AI winter is a period of reduced funding and interest in artificial intelligence research. The AI winter was a result of hype, due to over-inflated promises by developers, unnaturally high expectations from end-users, and extensive promotion in the media The term was coined by analogy to the idea of a nuclear winter. It has happened in 70 and 80s. So do not be pressurized to say yes to something which the business says they have read about or seen somewhere else. Understand there is a lot of false hype around and you should be sure what you are promising can be build in a feasible manner.
  • Cannot build castle on air Algorithms are almost as good as the data – in terms of quality and size, and the infra on which it runs. So before you engage that data scientist ask your self do I have the required data in terms of both size and format and in consistent quality available on my repository to run the algorithm on. And also do I have the processing power and big data infra set up to handle that processing. If you don’t have these, building the algo should not be your first priority. Do remember, many of the concepts we are using now were always there it’s our processing power which have brought them back to spotlight.

    • Don’t fight the big techs Use domain knowledge that you have gathered over years of being in business i.e. tricks of trade or domain business knowledge. It can be years of building cars, manufacturing things or making software products.
    1. · Avoid direct competition with the tech giants. If the product is too generic in nature they will build it faster and better with their deep resources.
    2. · Integrate data science closely with business products. Analytics should be out of the box and intuitive. If required collaborate with the tech giants’ offerings but never give away domain expertise.
    3. · Enable data science teams with domain knowledge. Celebrate people who are domain experts and make them part of the data science team.
    And we know big tech 4 – (Facebook, Amazon, Microsoft, Google) strengths.
    1. Deep funds available to do experimental innovation. Significantly less pressure to go profitable.
    2. Army of engineers and scientists.
    3. Vast computer infra. So vast that a company can rent their unused infra and it can become one of world’s biggest business (read AWS)
    • Systems are difficult to bring together I often see people talking about planning to bring systems together like taking walk on a park. It is rather like swimming across Arctic ocean. Think about bringing Twitter and Facebook together and identifying both are same person.In most cases the PII data cannot be used due to data security.Data level is a great challenge.
    • Few things are difficult to predict and action Stock market is one such example.
    1. It highly depends on the principle of game theory. That is you are very much dependent what others are doing. In a way you are trying to predict other’s behavior rather than the market.
    2. Lot of fake and misleading news in the net
    3. Influencing factors keep changing. We never knew Trump tweets can change the course of the market. But you can appreciate the trend in the long run.


    Application of YOLO - and things i figured on the way

     1. YOLO is a pre-trained model you can reuse for most of classes already added. if you want to get a list of the object please check the file coco.names which will have the list of 80 classes. Initially i tried recreating the yolo.h5 model by running yad2k.py over yolo.cfg and yolo.weights which i later figured was not required and reused pre-trained weights.


    2. Its important to understand the concept of -
    Encode Bounding boxes, Intersection over unoin and non-max suppression, anchor boxes.
    Good place to refresh one's understanding -

    3.As said earlier, though the YOLOv3 model should let you detect the object from the 80 classes mentioned, to detect any additional class you will need to custom train the YOLO model.

    4.Finally though it may not be required to run the model, but to apply it to actual use cases one should be clear of the concept of CNNs. Few blogs i will suggest are -
    https://victorzhou.com/blog/keras-cnn-tutorial/
    https://victorzhou.com/blog/intro-to-cnns-part-1/

    I tried the YOLO pre-trained weights and below are the results -