Have initially built this for a stock bot project. I have made this bot modular so that it is easy for users to add, edit utterances and slots based on their own requirements.
This bot complies and trains on itself upon initialization.
Detection of Intent and Slots uses SVM and CRF respectively.
Building of the bot is still in progress.
-
Creating Environment
- conda create -n venv python=3.7 scikit-learn pandas numpy pickle nltk itertools spacy
-
Activating Environment
- conda activate venv
-
Installing other packages
- pip install python-telegram-bot pycrfsuite
- python -m spacy download en_core_web_sm
- pip install snips-nlu
- Edit run.py
- Change TokenKey = "your own token key"
- Use cmd and execute python run.py
- Make sure that snips-nlu is installed
- Go to Dataset/YAML folder
- Create YAML File with the format provided (use smalltalk.yaml, intent should be groupname_intent)
- Converting YAML to JSON Command line:
snips-nlu generate-dataset en dataset.yaml > dataset.json- Cut Json file to Dataset/Converted
- Go to Training/Training.py
- Find and edit:
def train():
trainingfile = "Dataset\\Converted\\yourfile.json"
intentdataset(trainingfile)
slotdetection(trainingfile)
- Training will automatically run when run.py is initiated
- Response is Grouped by groupname in different py files, for smalltalk, smalltalk.py etc. Refer to utils\utterance.py getreply function for reference
- Function names should be the same as intent
-
Folders
- conversation Where all the responses are stored
- Dataset Where all training data YAML/JSON files are stored
- models Where all the trained models are deposited
- Slotsfill ( In progress ) Intended for slot request and replies
- Training Script to train models
- utils Script which handles Conversations
-
Files
- Conversation/smalltalk.py
- Handles all smalltalk replies
- Conversation/fallback.py
- Handles all fallback replies
- Training/Training.py
- Trains models for an intelligent chatbot
- Utils/slots.py
- Slots detection script ( In Progress )
- Utils/utterance.py
- Intent detection script( In Progress )
- Handles Intent to Responses and slot filling
- ./run.py
- Trains Model on initialization
- Stores Global Variables
- Interface with Telegram
- Interface with utterance.py
- Conversation/smalltalk.py