meta-learned-memory

documentation and tutorial on adding three capabilities to the neural chatbot agent (NCA) previously described here chat-transformer

There are 3 major improvements described here:

  1. Methods to keep an elastic vocabulary embedding, allowing the number of tokens understood by the model as input or output to expand and contract throughout the lifetime of the NCA

  2. Methods to quickly encode a memory at test time using few-shot meta-learning, allowing the model to remember concepts that it can use immediately without time-consuming batch gradient descent

  3. Methods to train the model in parallel on multiple GPUs to speed up batch gradient descent, which is still required to learn how to quickly remember concepts

Elastic Vocab

Typical seq2seq models have a fixed vocabulary, ie the number of words or tokens that can be used in the input and output are fixed. We have developed a method here for keeping a vocabulary is constantly growing and occasionally pruned.

Memory

This repository builds on the chat-transformer chatbot by adding a memory mechinism to the transformer sequence2sequence chatbot based on this paper by Tsendsuren Munkhdalai et al called Metalearned Neural Memory: Teaching neural networks how to remember,here are some Google Slides from an MLCOllective Research Jam

the high level gist of it is this: the controller in the diagram above is the sequence2sequence chatbot. In addition to taking a sequence as input and outputting a sequence as output, it also sends a signal to the memory network, a key vector, this is the input to a neural network telling it to retrieve a memory. That memory recall is returned to the chatbot in the form of the value vector which the chatbot can use to inform its next response.

Data Parallelism

We explain the lines of code that recruit and parallelize training across multiple GPUs

How to Start

if you already have python 3.6 and virtual environments, create a python 3.6 virtual environment, here i used env36 for python3.6 but you can use anything

python3 -m venv env or $ python3.6 -m venv env or virtualenv --python=/usr/bin/python3.6 env

if python3.6 is your default version, then when you type python into your terminal then it should say python version 3.6.x, and for you making the virtual environment is as simple as

$ python -m venv env

otherwise it is simple to get python3.6 and virtual environments

how to install Python 3.6 on ubuntu

install virtual environment then

how to specify the Python executable you want to use

sudo add-apt-repository ppa:jonathonf/python-3.6

sudo apt-get update

sudo apt-get install python3.6

virtualenv --python=/usr/bin/python3.6 env36

When you want to run the code activate the virtual environment inside the same folder as your environment env using

$ source env/bin/activate

install dependencies

$ pip3 install -r requirements.txt

even with virtual environments, some troubleshoot might be needed

with enough google searches you can find an answer for almost any problem

save new dependences to requirements

$ pip3 freeze > requirements.txt

You can deactivate the virtual environment using the following command in your terminal:

$ deactivate

More Tips and Tricks

if you get a ImportError: No module named while at the same time in your Terminal you get

pip3 install import-ipynb

Requirement already satisfied: import-ipynb in /path/to/env/lib/python3.6/site-packages (0.1.3)

This can be fixed by providing your python interpreter with the path-to-your-module,the path

import sys

sys.path.append('/path/to/env/lib/python3.6/site-packages')

you can find this path listed here

$ python3 -m site

Order of Progression

Start with the Minimal Working Example to get the gist. Then to learn the details, start with notebook who's name starts with part_1 and follow the directions inside, moving to part_2 etc.