vinodjsr / NLP-based-Chatbot-in-PyTorch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NLP based Chatbot in PyTorch

Simple chatbot implementation with PyTorch.

  • The implementation should be easy to follow for beginners and provide a basic understanding of chatbots.

  • The implementation is straightforward with a Feed Forward Neural net with 2 hidden layers.

  • Customization for your own use case is super easy. Just modify intents.json with possible patterns and responses and re-run the training (see below for more info).

In this article on Medium I explain some NLP concepts that underlies building Chatbots.


Installation

Create an environment

Whatever you prefer (e.g. conda or venv)

mkdir myproject
$ cd myproject
$ python3 -m venv venv

Activate it

Mac / Linux:

. venv/bin/activate

Windows:

venv\Scripts\activate

Install PyTorch and dependencies

For Installation of PyTorch see official website.

You also need nltk:

pip install nltk

If you get an error during the first run, you also need to install nltk.tokenize.punkt: Run this once in your terminal:

$ python
>>> import nltk
>>> nltk.download('punkt')

Usage

Run

python train.py

This will dump data.pth file. And then run

python chat.py

About


Languages

Language:Python 45.5%Language:CSS 26.1%Language:JavaScript 18.1%Language:HTML 10.3%