Saturday, October 23Digital Marketing Journals

Mercury — a chatbot for Ordering Food using ALBERT & CRF | by Ritvik Sharma | Sep, 2021


We come up with some desired labels for our model.

Intent Label : <OrderFood>

Slot Labels : <restaurant_name> , <food_name>, <food_type>, <qty>, <O> (<O> means that specific word does not carry much value in the sentence and can be masked or ignored).

We create hundreds of sample sentences with labels associated to each word.

ALBERT + Conditional Random Field (Joint-ALBERT):

We have already learnt that CRFs excel in modelling sequential data. So how does it help Mercury?

CRFs essentially help in mapping each word to it’s appropriate label.

For example:

It can map the number “1” to <qty> denoting quantity.

It can map the word “Domino’s” to <restaurant_name>.

Great! So if CRFs can do this, why do we even need ALBERT?

In our original sentence :

“I would like to have 1 non veg Taco, 3 veg Pizzas and 3 cold drinks from Domino’s.”

How does CRF know that the word “non” is a <B-food_type> and the word “veg” is <I-food_type> (B means beginning & I means continuation of B)?

How does CRF know that the word “non” is not the dictionary meaning “anti”?

As you probably already guessed, ALBERT provides CRF the contextual meaning of each word which helps CRF in classifying each word into the correct slot labels.

CRF does Slot-Identification for each word by mapping each word’s possible label with each other and figuring out which mapping has the highest probability.

Bold Line represents the Most Probable Mapping

Finally, how is Intent of the sentence predicted?

CRF does this part too by figuring out that “A specific sequence of slot-labels leads to a specific Intent”.

For example :

If the slots <food_type>, <food_name> and <restaurant_name> are found in a sentence, then the sentence is probably having the intent of <OrderFood>.

Intent Prediction based on Slot Labels

Leave a Reply