Package: nlpia_bot
nlpia_botUseNLP in
Actionto build a virtual assistant that actually assists! Most bots manipulate
you to make money for their corporate masters. Your bot can help protect
you and amplify your abilities and prosocial instincts.This hybrid chatbot combines 4 techniques explained inNLP in
Action:1. search: [chatterbot](https://github.com/gunthercox/ChatterBot), [will](https://github.com/skoczen/will)
2. pattern matching and response templates: Alexa, [AIML](https://github.com/keiffster/program-y)
3. generative deep learning: [robot-bernie](https://github.com/nlpia/robot-bernie), [movie-bot](https://github.com/totalgood/nlpia/blob/master/src/nlpia/book/examples/ch10_movie_dialog_chatbot.py)
4. grounding: [snips](https://github.com/snipsco/snips-nlu)The presentations for San Diego Python User Group are indocs/InstallYou’ll want to install and use the conda package manager within
Anaconda3, especially if your development environment is not a open
standard operating system like Linux.gitclonegit@github.com:nlpia/nlpia-botcdnlpia-botcondaenvcreate-nnlpia-fenvironment.yml# or environment-windoze.ymlcondaactivatenlpiapipinstall--editable.Usage$bot--helpusage:bot[-h][--version][--nameSTR][-p][-bSTR][-v][-vv][words[words...]]Commandlinebotapplication,e.g.bothowdoyouwork?positionalarguments:wordsWordstopasstobotasanutteranceorconversationalstatementrequiringabotreplyoraction.optionalarguments:-h,--helpshowthishelpmessageandexit--versionshowprogram's version number and exit
  --name STR           IRC nick or CLI command name for the bot
  -p, --persist        Don'texit.Retainlanguagemodelinmemoryandmaintaindialoguntilusersays'exit','quit'or'bye'(thisisthedefaultbehaviorifyoudonotprovideastatement)-bSTR,--botsSTRcomma-separatedlistofbotpersonalitiestoloaddefault:pattern,parul,search_fuzzy,time,eliza-v,--verbosesetlogleveltoINFO-vv,--very-verbosesetlogleveltoDEBUGExamplesYou can run bot just like any other command line app, giving it your
statement/query as an argument.$bothello# 2019-11-21 12:42:13,620 WARNING:nlpia.constants:107:            <module> Starting logger in nlpia.constants...
# 100%|█████████████████████████████████████████████████████████████████████████████████████████████| 64350/64350 [00:00<00:00, 540679.58it/s]BOT:HelloAnd if you want quicker turnaround on your bot you can just run it in
peristent mode (without any positional arguments for your statement or
words).Travis’s probabilistic reply selector is working nicely to chose a reply
from multiple sources (default settings):pattern_bots.py: regex patterns and greeting templatesfuzzy_search_bots.py: movie dialog fuzzy matchingparul_bots.py: Wikipedia searches using conventional TFIDF like a
search engineeliza_bots.py: A python port of the ELIZA therapist bottime_bots.py: A time and productivity tracker that parses your
git logs and bash history$bot(nlpia)hobs@Hobsons-MacBook-Air:~/code/chatbot/nlpia-bot$bot# 2019-11-21 12:59:05,854 WARNING:nlpia.constants:107:            <module> Starting logger in nlpia.constants...
# 100%|█████████████████████████████████████████████████████████████████████████████████████████████| 64350/64350 [00:00<00:00, 495935.48it/s]YOU:HiBOT:heythere.tiredofbreathing?YOU:HelloBOT:Howdoyoudo.Pleasestateyourproblem.YOU:WhatisanELIZAchatbot?BOT:joeynevertoldyouwewentout,didhe?YOU:^[[ABOT:Iamsorry!IdontunderstandyouYOU:WhatisanELIZAchatbot?BOT:Doesthatquestioninterestyou?YOU:Whatisachatbot?BOT:hellobarbieisaninternet-connectedversionofthedollthatusesachatbotprovidedbythecompanytoytalk,whichpreviouslyusedthechatbotforarangeofsmartphone-basedcharactersforchildren.YOU:HelloBOT:hello.YOU:HelloBOT:Howdoyoudo.Pleasestateyourproblem.YOU:bye$Work in ProgressTravis (@travis-harper): model management, context filtering, and
the addition of more conversational agentsNima (@hulkgeek): question answering bot based on his state of the
art question classifierXavier (@spirovanni): employment counselor for workforce.org and the
city of San DiegoHobson (@hobson): infrastructure (CI, webapp) and framework features
(nltk->spacy, USE vectors)Erturgrul: Turkish wikipedia QA bot (parul bot)You: What big chatbot idea would you like to make a reality?IdeasPlease submit your feature ideasgithub
issues. Here are a few
ideas to get you started.movie dialog in django database to hold the statement->response
pairsgraph schema compatible with MxGraph (draw.io) and other js
libraries for editing graphs/flow charts.ubuntu dialog corpus in dbmindfulness faq corpus in dbfamous quotes as responses to the statement “tell me something
inspiring”jokes for “tell me a joke”data science faqnlpia faqpsychology/self-help faqhtml django template so there is a web interface to the app rather
than just the command line commandbotuse Django Rest Framework to create a basic API that returns json
containing a reply to any request sent to the local host url, likehttp://localhost:8000/api?statement='Helloworld'might return
{‘reply’: ‘Hello human!’}have the command line app use the REST API from #3 rather than the
slow reloading of the csv file every time you talk to the botuse database full text search to find appropriate statements in the
database that we have a response foruse semantic search instead of text similarity (full text search or
fuzzywyzzy text matches)add embedding vectors (300D document vectors from spacy) to each
statement and response in the dbcreate a semantic index of the document vectors usingannoyso “approximate nearest neighbors” (semantic matches) can be
found quicklyload the annoy index of the document vectors every time the
server is started and use it to find the best reply in the
database.use universal sentence encodings instead of docvecs from spacy.create a UX for dialog graph creation/design:installmxgraphin the
django appcreate a basic page based on this mxgraph example so the user can
build and save dialog to the db as a graph:tutorial,example
appconvert the dialog graph into a set of records/rows in the
nlpia-bot db so it actstag different dialog graphs in the db so the user can turn them
on/off for their botallow the user to prioritize some dialogs/models over othersallow the user to create their own weighting function to
prioritize individual statements produced by the apitrain a character-based generative modeldecoder half of autoencoder to generate text based on docvecs
from spacydecoder part of autoencoder to generate text based on universal
sentence encodingstrain model to generate reply embeddings (doc vecs and/or use
vecs) using statement embeddings (dialog engine encoder-decoder
using docvecs or use vecs for the encoder halfadd a therapy/mindfulness-coach feature to respond with mindfulness
ideas to some queries/statementsadd the “translate ‘this text’ to spanish” featuretrain character-based LSTM models on english-spanish,
english-french, english-german, english<->whateveradd module for this to the django app/apiAIML engine fallbackInspirationA lot of the patterns and ideas were gleaned from other awesome
prosocial chatbots and modular open source frameworks.Mental Health CoachesWYSAfrom London is freehttps://www.techinasia.com/ai-chatbot-wysa-touchkin-penguinopen source (touchkin)?ionic?passive sensing of sleep patterns (accelerometers?)guided meditationexercise suggestionsfree text dialog with buttons to suggest repliesbased on open source touchkin/mindlogger ?list of alternative
appsReplikafrom US is paywalledpersonality profile testpay to unlock “skills” trainingYouper(thank you Maria andtangibleai.com)Open Source Frameworkswilllang: pythonweb: zeromqdb: redis, couchbase, flat file, user-definedintegrations: hipchat, rocketchat, shell, slackai-chatbot-frameworklang: pythonweb: flaskorm: flask?db: mongodbnice general json syntax for specifying intent/goals for
conversation manager (agent)rasalang: pythonweb: sanic (async)orm: sqlalchemydb: sqliterich, complex, mature frameworkbotpressjavascript (typescript)meta-framework allowing your to write your own modules in
javascriptProgram-Ypythonweb: flask (rest), sanic (async)db: aiml flat files (XML)integrations: facebook messenger, google search, kik, line, alexa,
webchat, viber