a chatbot framework for yioop - san jose state … · a chatbot framework for yioop by harika...

38
A Chatbot Framework For Yioop By Harika Nukala Advisor Dr. Chris Pollett Committee Members Dr. Robert Chun Dr. Leonard Wesley

Upload: phungthuy

Post on 02-Aug-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

AChatbotFrameworkForYioop

ByHarikaNukala

AdvisorDr.ChrisPollett

CommitteeMembersDr.RobertChun

Dr.LeonardWesley

SJSU Washington Square Agenda

• Problemstatement

• Introduction

• Background

• DesignandArchitecture

• ChatbotAPI

• LanguageUnderstandingAPI

• Integration

• Experiments

• ConclusionandFutureWork

• References

SJSU Washington Square

• Thegoaloftheprojectistodesignanddevelopachatbotframeworkwhichprovidesafacilityfordeveloperstocreatechatbots inYioop.

• Yioop isanopensource,PHPsearchengineanddiscussionboardportal.

• SimplyexplainedChatbotFrameworkiswherebotsarebuilt,andwheretheirbehaviorisdefined.

• Botdevelopmentframeworksaresoftwareframeworksthatabstractawaymuchofthemanualworkthatisinvolvedinbuildingchatbots.

ProblemStatement

SJSU Washington Square Introduction

• Achatbotisanartificiallyintelligentcomputerprogramthatcanconversewithhumansonmessagingplatforms.

• Anartificialintelligentchatbot canunderstanduser’sintentionandrespondaccordingly.

• Adevelopermusthaveexpertiseandspecialknowledgeinfewareaslikemachinelearningandartificialintelligencetocreatesuchchatbots.

• Tomakeiteasier,companieslikeFacebookandMicrosoftintroducedbotframeworksfordeveloperstobuildandconnectbotstousersinaconversationalinterface/channels.

• TheaimofmyprojectistocreateaChatbot FrameworkforYioop,withasimilarkindofendgoalinmind.

SJSU Washington Square KeyConcepts• Expression

AnExpressionisthetextualinputfromtheuser,thatabotneedstointerpret.Itisasentence,like“BookmeatickettoParis”or“GetmeweatherofSanJose”.

• IntentAnintentrepresentsactionstheuserwantstoperform.Itisapurposeorgoalexpressedinauser'sinput,suchasbookaflight,getweatherupdate,orreserveahotelroom.

• EntityAnentityisrelevanttoauser’sintent.Intheexpression“BookmeatickettoParis”,“Paris”isanentityoftypelocation.

SJSU Washington Square

• FacebookandMicrosofthavelarge-scalebotframeworksdesignedanddevelopedtoproduceamassnumberofchatbots.

• Alldevelopersfacethesamekindofproblemswhilecreatingbots.Theyare:botsrequirebasicinputandoutput;theymusthavelanguageunderstandingskills;andtheymustbeabletoconnectwiththeuserinaconversationalinterface.

• Theseframeworksprovidetoolsthathelpdeveloperstobuildbotsanddefinetheirbehaviorusingaprogramminglanguage.

PreliminaryWorkSummary

SJSU Washington Square

• Facebook Messenger platform provides Receive and Send API that allowsdevelopers to make bots interact with businesses.

• The Facebook Bot Engine (Wit.ai) depends on concept of Machine Learning.

• User feed the Bot engine with sample conversations so that it can handle manydifferent variations of the same questions.

• Wit.ai parses a message into structured data (Understand) or predict the nextaction your bot should perform (Converse).

PreliminaryWorkSummary(Contd.)

SJSU Washington Square PreliminaryWorkSummary(Contd.)

SJSU Washington Square

• Microsoft announced its Bot Framework roughly at the same time asFacebook.

• MicrosoftprovidesanSDKthatcanbeviewedastwocomponents:1. BotConnector,theintegrationFramework2. LUIS.ai,thenaturallanguageunderstandingservicecomponent

PreliminaryWorkSummary(Contd.)

SJSU Washington Square

• Bothwit.ai andluis.ai areexternalwebserviceswhichareconsumedasabackendserviceinchatbotapplicationsusingaRESTcall.Thismakesinteractionsbetweenusersandbotsslower.

• WecreatedourownLanguageprocessingAPIinYiooptomakeconversationsfasterbetweenusersandbots.

PreliminaryWorkSummary(Contd.)

SJSU Washington Square Architecture

LookslikeRobotJ

SJSU Washington Square Design

SJSU Washington Square SampleKnowledgebase

SJSU Washington Square ChatbotAPI

• TheChatbotAPIallowsdeveloperstocreatechatbotsandconfiguretheminYioop.

• Userscaninteractwithachatbotfromanygroupthreadthatabotisconfiguredtoworkfor.

• ThisAPIactsasaconnecterandroutesmessagesbetweenusersandchatbot.

• ThisAPIprovidewebbasedconsolesothatdevelopersaddknowledgetospecificbots.

SJSU Washington Square

• Thebotusershavemanyofthesamequalitiesasthenormalusers.

• ThemaindifferenceisthebotusersarecontrolledprogrammaticallybybotuniquetokenandbotcallbackURL.

ChatbotAPI(Contd.)

SJSU Washington Square ChatbotAPI(Contd.)

• ToverifytheauthenticityofthetokensentbythechatbotAPI,thebotapplicationhasaprocedurethatextractsthetokenfromtheHTTPPOSTrequest,parsesthetoken,verifyitscontents,andverifyitssignature.

SJSU Washington Square AddanIntent

• Anintentrepresentsataskoractiontheuserwantstoperform.

• Intentsmatchuserrequestswiththeactionsthatshouldbetakenbychatbot,soonemustaddintentstohelpchatbotunderstanduserrequestsandrespondtothem.

SJSU Washington Square AddanEntity

• Entitiesarethekeyinformationforadomain-specificchatbot.

• Anentityisacollectionofsimilarobjectslikealocation,person’sname,number.

SJSU Washington Square EditanEntity/AddanEntityvalue

• Entityvaluesarelikeinstancesofaclass.

• Forexample,locationisanentityandSanJose,Chicago,Seattlearetheentityvaluesoflocationentity.

SJSU Washington Square AddanExpression

• Expressionsaresentencesrepresentingexamplesofuserqueriesthatachatbotisexpectedtoreceiveandinterpret.

• Expressionsarelabeledintermsofintentsandentities.

• Entitiesaredetectedandlabeledautomaticallyifchatbothasalreadylearnt.

SJSU Washington Square

• ThelanguageunderstandingAPIallowsbotstounderstandtheuserqueryandextractmeaningfulinformationoutofit.

• Itpredictswhatbotshoulddobasedontheuserquery.

• Inshort,therearetwothingsthattheLanguageunderstandingAPIcanpossiblydo—

• IntentClassificationusingTF-IDFalgorithm• EntityExtractionusingpatternmatchingtechnique

LanguageUnderstandingAPI

SJSU Washington Square

Tokenization

Removingstopwords

Stemming

IntentClassification

EntityExtraction

Rawtext

ExecutionFlow

Languageprocessing

IntentandEntities

(tokenize)

(stopwordsRemover)

(stemTerms)

(TF-IDF)

(patternMatching)

BasicNLPAnalysis

SJSU Washington Square ClassifyIntent(TF-IDF)

• Morefrequenttermsinacollectionofsentencesofanintentaremoreimportant,i.e.moreindicativeoftheintent.

Intent Expression

GetWeather Whatisweatherin&location

GetWeather Howisweatherin&location

GetWeather Isitrainyin&location

BookFlight Bookflightfrom&sourceto&destination

Intent Term Frequency

GetWeather weather 2

GetWeather rainy 1

BookFlight Book 1

BookFlight flight 1

SJSU Washington Square TF-IDF(Contd.)

• Onemeasureofhowimportantawordmaybeisits termfrequency (tf),howfrequentlyawordoccursinacollectionofsentencesofanintent.

𝑡𝑓#,% =frequencyoftermtinasetofsentencesS

𝑡𝑓#,% = S(e%𝑡𝑓#,(𝑑𝑓# =intentfrequencyofterm t

=numberofintentscontainingterm t𝑖𝑑𝑓#=inversedocumentfrequencyofterm t,

= 1 + 𝑙𝑜𝑔( 123456

)

(N:totalnumberofintents)

SJSU Washington Square TF-IDF(Contd.)

• Atypicalcombinedtermimportanceindicatoristf-idf :

𝑡𝑓 − 𝑖𝑑𝑓#,% = 𝑡𝑓#,%´𝑖𝑑𝑓#

• Atermoccurringfrequentlyintheintentbutrarelyintherestofthecollectionhashighweight.

• Thescoreofeachintentisthesumoftf-idf weightofeachqueryterminsetofsentences.

𝑆𝑐𝑜𝑟𝑒 𝑞, 𝑆 = å#e>𝑡𝑓 − 𝑖𝑑𝑓#,%

• Thetopscoredintentisreturnedasclassifiedintent.

ExtractEntities

• Theentitiesarekeyinformationtoperformanaction.

• Theseentitiesareextractedfromuser’srequestbyusingmatchingkeywordsorthepatternmatchingtechnique(similarwordingpatternfromanexistingdatabase).

• Forexample,whenauserasks,“HowistheweatherinSanJose”.Theexpressionwehaveinknowledgebaseisgeneralizesas“whatisweatherin(.*)”.

• Patternmatchingtechniqueisappliedonbothsentencesandextract“SanJose”asentityvalue.

SJSU Washington Square Experiments–TestingandUseCases

• After integrating the chatbot framework in the Yioop search engine, weperformed some experiments to see how chatbot works and how theyinteract with users in Yioop discussion groups.

• To evaluate the chatbot framework, we need to create chatbot applications.I created a Weather Bot and Stock Bot services with unique bot token forauthenticity.

SJSU Washington Square UseCase– WeatherBot

• I created a Weather Bot application with unique bot token for authenticity.

• The Weather Bot service performs action that intend to give weatherupdates for user requested location.

• This bot service calls the yahoo weather service which is an external API toget weather information.

• The bot service URL and unique bot token must be provided as Bot tokenand Bot callback URL in weather bot account in order to have aconversation with users in Yioop discussion groups. These bots must beadded to the Yioop groups the user chosen to interact.

• ThebothaslearnttwoexpressionswithgetWeather intent.

n Square UseCase– WeatherBot(Contd.)

SJSU Washington Square UseCase– WeatherBot(Contd.)

Conversation between a user (ramya) and a weather bot (weatherbot)

SJSU Washington Square UseCase– WeatherBot(Contd.)

The Entity knowledge base is updated with new entity values ‘Seattle’ and‘San Jose’

SJSU Washington Square UseCase– StockBot

• Similar to the Weather Bot, we created a Stock Bot application with uniquebot token for authenticity and respective bot account.

• The Stock Bot service calls the yahoo finance, an external API to get thecurrent stock price of the user asked stock symbol.

UseCase– StockBot(Contd.)

SJSU Washington Square UseCase– StockBot(Contd.)

Conversation between a user (ramya) and a stock bot user (stockbot)

SJSU Washington Square ConclusionandFutureWork

• In this project, a new module called Chatbot Development Framework isdeveloped for Yioop.

• This bot framework is useful for developers to create new chatbots, trainthem quickly in the Yioop social site. Yioop bots are more like human whenit interacts with users and makes conversational experience moreenjoyable.

• IamexcitedtoprovideapreliminaryavailabilityofthechatbotFrameworkforYioop.Thisframeworkcanbeextendedandimprovedbyaddingtoolsorfacilitieslikeconversationstatemanagement,scheduledconversations,languagespecificbots,abotsearchandbotrecommendations.

SJSU Washington Square References

[1]Wit.ai,“docs,”2016.[Online].Available:https://wit.ai/docs

[2]developers.facebook.com,“docs,”2016.[Online].Available:https://developers.facebook.com/docs/messenger-platform

[3]docs.botframework.com,“core-concepts,”2016.[Online].Available:https://docs.botframework.com/en-us/core-concepts/overview/#navtitle

[4]docs.microsoft.com,“LUIS,”2017.[Online].Available:https://docs.microsoft.com/en-us/azure/cognitive-services/LUIS/Home

[5] api.slack.com, “bot-users,” [Online]. Available: https://api.slack.com/bot-users

SJSU Washington Square References(Contd.)

[6] Seekquarry.com, “Resources,” 2015. [Online]. Available:https://www.seekquarry.com/p/Resources.[Accessed:09-Sep-2015].

[7]C.Manning,P.RaghavanandH.Schutze, Introductionto informationretrieval,1sted. Cambridge: Cambridge University Press, 2009. [Online]. Available:https://nlp.stanford.edu/IR-book/

[8]Patternmatching.(2017).Retrievedfromhttps://en.wikipedia.org/wiki/Pattern_matching

Thank You!

Demo