Feeds:
Posts
Comments

Humble machines

[Thoughts on machine learning – 2]

All men by nature desire to know…” Aristotle. To be wise is to admit that you don’t know, you are not sure, that is to take probabilities into account! If we want machines to be wise, that is to exhibit intelligence, then machines should admit its ignorance! For me, computer programs written with a fixed heuristic set of rules are only stupid, those which send their feedback with a shy confidence are way more intelligent. 

[Thoughts on machine learning – 1]

“There’s something magical about Recurrent Neural Networks (RNNs)” Andrej Karapthy. Such statement is not very settling for me. How for a software engineer to write a test case for something magical! I don’t think we can afford to treat a ML model as a black box. Machine Learning Interpretability is crucial.

The great OCR was one of the earliest Neural Network applications. The utility of converting hand or machine written text from scanned documents to machine-encoded text format was and still huge.

In 1998 Yann LeCun, currently Chief AI Scientist at Facebook, was working at Bell Labs on an OCR that recognizes the set of digits from 0 to 9 to be deployed and used in banks, and post offices to recognize check numbers and zip codes.

The application was a success and as a by-product of their work LeCun, who later led the invention of Convolutional Neural Network (LeNet-5), he and his team produced MINST dataset.

The dataset, which contains 60,000 training and 10,000 testing different images of 0-9 handwritten digits, then led a life on its own and became the benchmark for supervised learning algorithms.

source (https://www.mdpi.com/2076-3417/9/15/3169)

The MNIST is created by modifying samples from NIST or The National Institute of Standards and Technology original datasets and hence the M in the name.

Almost 20 years later and in 2017 a group of researchers collected a drop-in replacement they called Fashion-MNIST which is a dataset of Zalando’s fashion articles ( shoes, bags, pants .. and who cares) images consisting again of a 60,000 training and a 10,000 testing images classified into 10 classes.

The Fashion-MNIST creators were bold enough to propose this dataset as a new benchmark for Computer Vision image classification algorithms claiming that MNIST is a solved problem and no longer an enough challenge, which I think true!

Extended MNIST or EMNIST is also introduced the same year 2017. This time the dataset includes both digits and letters.

Yet another variation following MNIST tradition is Kaggle American Sign Language MNIST presented also 2017. The dataset contains thousands of images of hand gestures represent for 24 English letters (excluding J and Z which require motion).

Experimenting with MNIST dataset is like the Hello World of Computer Vision, Image Classification and  Neural Networks, honoring this tradition I am collecting and experimenting with MINST, Fashion MNIST, EMINST and Sign Language MNIST mainly using TensoFlow but sometimes comparing implementations and performances with other frameworks as well.

Stay safe,

Salam

This is the fourth post in a series of posts discussing the results of my survey of a three of the well known chatbots engines and my observations while trying to build a conversational sentiment-aware chatbot using them.

Wit.ai

Wit.ai was acquired by Facebook in 2015. Wit.ai is an NLP based chatbot development platform that supports many languages and is offered as a hosted service.

Labeeb Wit.ai Architecture

Labeeb Wit.ai Architecture

Since Wit.ai is proprietary technology there is not much published information about its architecture. Also, Wit.ai provides only NLU and it doesn’t provide any of the features of Dialog Management. Programming interfaces for Wit.ai are available in JavaScript and Python.

Labeeb built on top of Wit.ai is composed of:

  1. Set of training examples for different entities that include all intents as well because Wit.ai doesn’t distinguish intents from entities.
  2. Http Service running on Express HTTP Server listening to call back from Facebook Messenger input channel.
  3. Custom Dialog Management which figures out what is the best response out of a set of utterances based on where we are in the dialog and what is recognized intent. It also, when required, investigates the sentiment analysis sent along with the request and customizes the response accordingly.
  4. Facebook connector: responsible for registering webhooks, verifying request signature to make sure it is coming from an authentic source and for processing incoming messages from Facebook Messenger.

Machine Learning

Not much is published about Machine Learning algorithms employed by Wit.ai to perform NLP/NLU.

Sentiment Analysis: again and similar to RASA Wit.ai doesn’t provide sentiment analysis, however, using Facebook Messenger as an input channel, which obviously very well supported, avails NLU service from Facebook AI, in such case an additional sentiment data node in the request message is sent by Facebook Messenger through webhook back to Labeeb Wit.ai based chatbot, I can then use this information to customize the response the bot is sending back.

Tooling

Wit.ai has a very nice web interface through which chatbot developer can easily train the NLU engine by providing examples and highlighting the entities and their values.

Wit.ai User Interface

Developers Support

According to Wit.ai website, Wit.ai service is used by 200,000 developers worldwide. Documentation is reasonable, searching “Wit.ai” + tutorial results in 10,900 hits compared to 6000 hits for a similar search for Rasa and approx. 96000 for searching for Dialogflow + Tutorial.

 Integration

Wit.ai doesn’t provide ready connectors to any of the input channels however it provides Python, Node.JS, Ruby API’s in addition to Http endpoints.

Salam,

This is the third post in a series of posts discussing the results of my survey of a three of the well known chatbots engines and my observations while trying to build a conversational sentiment-aware chatbot using them.

Dialogflow

Dialogflow is a platform owned by Google and offered as a hosted service to allow developers to build a conversational user interface for application and devices.

Labeeb Dialogflow Architecture

Labeeb Dialogflow Architecture

Dialogflow provides NLP, Dialog Management, and a wide spectrum of ready connectors to Google Assistant, and most of the well know messaging platforms. Dialogflow integration with Google assistant enables voice interaction with the developed chatbot out of the box. Integration with Google Assistant is provided with a single click and only minimal configuration is required.

Labeeb built using Dialogflow is composed of:

  1. Set of intents, entities and the associated training examples for each of them. Dialogflow documentation recommends 10-15 training examples per intent, however, I used an amount of training examples similar to other implementations to try to have a fair comparison between the bots.
  2. Set of conversation contexts, which helps the engine track the dialog and select the right response.
  3. Fulfillment, which is the custom code that is plugged into each intent and executed by the engine before sending the response back to the input channel. This fulfillment is a JavaScript code that in case of Labeeb is defined inline within Dialogflow, it can be also run on a separate server and then called when needed. The fulfillment code is also responsible for investigating the sentiment analysis sent along with the request and customizes the response accordingly.
  4. Integration with Google Assistant.

Again and similar to Wit.ai, not much is published about NLP/NLU algorithms used by Dialogflow.

Sentiment Analysis: Dialogflow offers sentiment analysis readily available within the request itself however it is enabled only for enterprise plans, not on the free one. Also when testing the Labeeb Dialogflow chatbot integrated with Google Assistant I found that sentiment analysis data is not passed, I opened a case with Dialogflow support but till the time of writing this report I didn’t receive their feedback yet.

Tooling

Dialogflow is by far the richest environment with tools. For example test console is panel is available in the main page itself, diagnosis tool that developer can use to look into the request and response JSON is also there and inline code editor for fulfillment. Tooling also extends to cover analytics and a rich set of prebuilt bots that developer can install and customize.

Dialogflow User Interface

Developers Support

Dialogflow has the largest community, over 800,000 developers, also a huge number of online resources, approx. 96000 hits when searching for Dialogflow + Tutorial, and books.

Integration

Dialogflow offers a comprehensive set of integration connectors with messaging platforms including a unique connector for telephony and also integration with Amazon Lex.

Large set of Connectors

Salam,

Recently I encountered another interesting idea when it comes to writing a research paper, distill.pub provides a new way to write a research peer-reviewed paper which instead of using rigid PDF, it actually uses HTML and encourages researchers to present their ideas as an interactive document where you can see graphs and equations and possibly change them and see results inside the paper itself!

This is, in fact, the second flavor of “writing a research paper as a Jupiter Notebook” where instead of writing about your experiment what is better than putting your experiment code and allowing the readers to run the code and generate the graphs inline within the text of your paper.

This is the second post in a series of posts discussing the results of my survey of a three of the well known chatbots engines and my observations while trying to build a conversational sentiment-aware chatbot using them.

Rasa Stack

Rasa is an open-source NLP and Dialog Management library for intent classification and entity extraction for building chatbots. Being open-source Rasa gives the flexibility of deploying the developed chatbot on any platform, in the cloud or on-premises. Using Rasa Stack I built the first version of the chatbot and I will call it Labeeb Alpha

Labeeb Rasa Architecture

Labeeb RASA Version Block Diagram

Rasa has two main components:

  1. Rasa NLU: this is the NLP engine of Rasa, basically where model training happens following the selected pipeline. Rasa NLU pipeline is the sequence of processing steps NLU preforms on training examples one by one in order to learn the model.
  2. Rasa Core: this is the dialog management which predicts next action based input from Rasa NLU.

Machine Learning

Rasa NLU uses Support Vector Classifier algorithm for Intents recognition and Entity extraction. The classifier is applied to vector representations of words, where each word is represented by a dense numeric vector. Rasa provides pre-trained models using publicly available training datasets; however, these models are available only in English. Chatbot developer can also update the model with additional examples. The data is provided through a markdown file following the below format:

Sentiment Analysis: No sentiment analysis service is provided out of the box from RASA, I, therefore, used twinword (https://www.twinword.com) which provides open and free API’s.

Tooling

RASA has the least rich set of tools compared to Wit.ai and DialogFlow. Rasa has an interactive tool built as Node.JS application that chatbot developer can use to generate “stories”, which are examples of conversations, then Rasa Core can be trained on these examples.

Developers Support

Installation of RASA was not straightforward for me, part of the problem is that framework apparently evolves quickly and most of the online materials are already outdated although the ones I checked were released only months ago.

Rasa community is very small compared to DialogFlow, and Wit.ai, however, it is the leading open-source with a community of 2000+ members, 200+ contributor, and 300,000+ downloads from 2016 to 2018 (Rasa Community Update, 2018)

Integration

At the time of writing this report, the current version of RASA 0.14 supports integration through webhooks with Slack, Telegram, Twilio and Facebook Messenger. Integration requires running “ngrok” for secure tunneling from public internet endpoint to locally running service.

Salam,

Chatbot in Education

Since 1960 we have progressively moved from computer-based training to conversational tutoring chatbots with NLP capabilities. Those tutoring bots are an exciting application of AI in Education. However, critics have pointed to chatbots mechanical question-answer type of communication and the lack of emotional intelligence as two of the main obstacles hindering the successful application of tutoring bots.

In this blog and possibly in the coming three or four, I am sharing with you the results of my survey of the current state of tools and frameworks that would allow educational technology software designers to build intelligent tutoring systems that are conversational and emotionally intelligent.

The number of chatbot frameworks, engines and tools are huge, I counted more than 28 different chatbot engine during this survey, therefore and for practical reasons I am exploring three different frameworks chosen based on popularity measured by the number of downloads and developer community size and also to represent different types of tools available.

Also, I am not going to try implementing full emotions state synthesis and analysis from facial expression, voice tone…etc, that would be also not very feasible within a reasonable amount of time, instead I will explore only possible ways to sentiment analysis using these chatbot engines.

In addition to that, building full-fledged tutoring system would require a lot of work, so instead, I am testing each framework on building “Labeeb” which is a chatbot that simply interviews students for their feedback after finishing an educational course.

Example Conversation

The following is a conversation example that Labeeb should be able to conduct:

LabeebHi, my name is Labeeb what is your name?
StudentMy name is Yaser
LabeebGlad I am talking to you Yaser 🙂 , I knew that you’re an OMSCS student, if I am right, what was the last course you took?
StudentIt was Machine Learning
LabeebAlright, and how do you briefly describe the difficulty level of this course: Machine Learning?
StudentIt was rather difficult
LabeebOh, I am sorry to hear that 😦 , how do you describe the assignments of this course?
StudentAssignments were long and required a lot of effort
LabeebToo bad 😦 , how do you describe the TA’s and Professors?
StudentTA’s were quite good
LabeebGood, good 🙂 , how do you describe the lectures?
StudentLectures were nice as well
LabeebIt seems that you have some likes and dislikes about this course, OK this is the last question, I promise :), so on a scale from 1 to 5 where 1 is the worst and 5 is the best, how do you rate this course?
Student2
LabeebThat was a nice review, good luck in your courses, thanks
StudentBye
LabeebBye, bye

The frameworks I picked for this project are:

Staring next blog, I will discuss Labeeb implementation using these chatbot engines one by one. Keep following.

MOOCS and The Dark Ages

Before MOOCS is my new definition for the dark ages. Dark Ages is used to describe the era of deprived education, stagnating culture and hierarchical elite clergy. Early 2009 Udacity launched its services, before that, in an unprecedented move from such reputable university, MIT opened a lot of its courses and made it available completely free online! It is the time to learn if you have the passion and the patience. I remember the time when I used to travel from Al-Menufeya for almost 100 KM to buy a new book on some new hot programming language. Now with couple of clicks I can attend a course taught by the language inventor himself! For a techie comm moi this is heaven on earth!

Georgia Tech three years ago has launched a massive and now very popular MSc. GT OMSCSprogram completely online, the program which costs a fraction of the on-campus counterpart is a leap step toward democratizing fine education and make it available to the masses.

I proudly would like to add that I am a student in this program, I have finished 5 courses of the total 10, about to finish the sixth and planning to graduate late 2019.

My experience with this program is fantastic so far, in a coming post I am going to share more about that!

Salam,

Assalamo-alykom,

A question that I always ask when interviewing candidates applying to software engineering posts goes as the following:

In some programming languages,  you can call static method using the name of the object or the name of the class alike, if you have this choice in your programming language will you call that method using class name or object name knowing that both are syntactically valid ?

Frequently I get answers like “it doesn’t matter”, and more than often I get a strong confirmation “I will use the class name” but then when I ask why, candidates start mumbling with extra-galactic languages!

Amr Noman and me during Sustainable Refactoring workshop

Amr Noman and me during Sustainable Refactoring workshop

What I am expecting as an answer, although I don’t often get it, is: yes, I will use class name because otherwise I will obscure the fact that the method is actually static!

The mere action of using object name, although  syntactically possible, has undermined the readability and impaired the semantic of the code.

In my not very humble opinion, writing code is no different than writing a novel or a poem, in all these good writing style goals of clarity, simplicity and creativity are due.

Earlier this year, I have invited Amr Noman form Agile Academy to run a workshop for
my team about “Sustainable Refactoring”. Amr was discussing different refactoring techniques like method extraction when he said “Your code should read like a story” I couldn’t agree more!

How you choose your methods and classes’ names, how each method name is consistently or inconsistently named, whether your code is extracted into a number of reusable methods or you are just copying and pasting codes everywhere and whether your sequence of method calls can be read in a natural flow that conveys what this code is doing,  this is what adds meaning to your code beyond the basic syntax.

Salam for now,