Neural Machine Chatbot using seq2seq
Clone or download

README.md

Neural Chatbot

Neural Network Chatbot from Google's Neural Machine Translation

Using seq2seq(RNN) 

Training (django Version)

  • Download Source to $PROJECT
    git clone git@github.com:crazia/NM-chatbot.git
  • Install MeCab (한글 형태소 분석용)
    bash <(curl -s https://raw.githubusercontent.com/konlpy/konlpy/master/scripts/mecab.sh)
  • Install requirements
    cd NM-chatbot
    pip install -r requirements.txt    
  • Make migration
    python manage.py migrate
  • Create Super User for admin (id/password)
    python manage.py createsuperuser
  • Make initial data
    python manage.py makedata --initial
  • Run Server
    python manage.py runserver
    python manage.py makedata

Training (Console Version)

  • Make training data
    mkdir -p /tmp/nmt_chat

Just example!

make traing data for requesting

    echo -e "안녕?\n넌 누구니?\n잘 지내?" > train.req

make traing data for replying

    echo -e "안녕!\n난 코에이?\n응 잘 지내" > train.rep

make test data for requesting

    echo -e "안녕?\n넌 누구니?" > test.req

make test data for replying

    echo -e "안녕!\n난 코에이" > test.rep

make vocab file for training. train.all means a merged file from train.req & train.rep

    python $PROJECT_ROOT/core/bin/generate_vocab.py < train.all > vocab.req
    cp vocab.req vocab.rep

copy all file to '/tmp/nmt_chat'

    cp train.req train.rep test.req test.rep vocab.req vocab.rep /tmp/nmt_chat
  • Do training

    Go to Project's ROOT directory and run training

python -m core.nmt \
    --attention=scaled_luong \
    --src=req --tgt=rep \
    --vocab_prefix=/tmp/nmt_chat/vocab  \
    --train_prefix=/tmp/nmt_chat/train \
    --dev_prefix=/tmp/nmt_chat/test  \
    --test_prefix=/tmp/nmt_chat/test \
        --out_dir=/tmp/chat_model \
    --num_train_steps=12000 \
    --steps_per_stats=100 \
    --num_layers=4 \
    --num_units=128 \
    --dropout=0.2 \
    --metrics=bleu
  • Test chatbot

    Go to Project's ROOT directory and edit constants.py for out_dir and run

export OUT_DIR='DIRECTORY FOR MODEL'
python manage.py runserver

check http://localhost:8000

한글 설명