• Stars
    star
    398
  • Rank 107,665 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created over 4 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple chatbot implementation with PyTorch.

Implementation of a Contextual 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).

The approach is inspired by this article and ported to PyTorch: https://chatbotsmagazine.com/contextual-chat-bots-with-tensorflow-4391749d0077.

Watch the Tutorial

Alt text

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

Customize

Have a look at intents.json. You can customize it according to your own use case. Just define a new tag, possible patterns, and possible responses for the chat bot. You have to re-run the training whenever this file is modified.

{
  "intents": [
    {
      "tag": "greeting",
      "patterns": [
        "Hi",
        "Hey",
        "How are you",
        "Is anyone there?",
        "Hello",
        "Good day"
      ],
      "responses": [
        "Hey :-)",
        "Hello, thanks for visiting",
        "Hi there, what can I do for you?",
        "Hi there, how can I help?"
      ]
    },
    ...
  ]
}

More Repositories

1

ml-study-plan

The Ultimate FREE Machine Learning Study Plan
2,793
star
2

pytorchTutorial

PyTorch Tutorials from my YouTube channel
Python
1,705
star
3

MLfromscratch

Machine Learning algorithm implementations from scratch.
Python
1,210
star
4

python-fun

Some fun and useful projects with Python
Jupyter Notebook
710
star
5

python-engineer-notebooks

Jupyter Notebook
688
star
6

snake-ai-pytorch

Python
596
star
7

chatbot-deployment

Deployment of PyTorch chatbot with Flask
CSS
327
star
8

python-docker-tutorial

Learn how to dockerize Python scripts and a Python web app
Python
279
star
9

ai-typing-assistant

AI powered local typing assistant built with Ollama
Python
268
star
10

python-github-action-template

Schedule a Python script with GitHub Actions
Python
251
star
11

pytorch-examples

Jupyter Notebook
215
star
12

python-task-automation

Useful Python scripts to help you be more productive
Python
144
star
13

tensorflow-course

Tensorflow Beginner Course from my YouTube channel
Jupyter Notebook
111
star
14

streamlit-demo

Build an interactive web app with streamlit and scikit-learn
Python
109
star
15

ml-deployment

Different tutorials how to deploy Machine Learning models
Python
99
star
16

youtube-analyzer

Extract statistics for a YouTube channel with the YouTube Data API
Python
80
star
17

ml-app-salaryprediction

Salary Prediction Web App With Streamlit
Jupyter Notebook
80
star
18

flask-todo

Simple Flask Todo App
HTML
63
star
19

docker-fastapi-ml

Python
48
star
20

google-sheets-finance-automation

Python
44
star
21

python-knowledge

Useful python knowledge
Python
33
star
22

fitness-app-python-harperdb

Manage your favorite workouts with Python and HarperDB
Python
23
star
23

blogposts-pythonengineer

Repo with articles for the python-engineer.com website. New authors are welcome!
21
star
24

patrickloeber

17
star
25

tweet-scheduler

Schedule Tweets with Flask and Heroku
HTML
13
star
26

patricks-workouts

Displays my Apple Health data in a Steamlit App.
Python
10
star
27

photo-tagging-app-cloudinary

Upload, tag, and analyze your photos in Python with Cloudinary
Python
9
star
28

harperdb-cloudfunction-example

Use HarperDB cloudfunctions to send an email
JavaScript
7
star
29

whoop-analyzer

Analyze Whoop Workout data with Python
Python
5
star
30

patloeber.com-images

2
star