Intelligent AI Chatbot in Python
Why Stack Overflow recommends it
Stack Overflow users link it when they are debugging code copied from this tutorial, such as TensorFlow, NumPy and CUDA errors in the training and chatbot scripts.
Recommended by 2 people across 2 different months, 2020 to 2023.
What it is
A 35-minute Python tutorial from NeuralNine that builds a chatbot using NLTK and a Keras neural network. It covers writing an intents JSON file, preparing bag-of-words training data, training the model, and wiring up a chat loop with a short demo.
What people said
Recommends NetBreak7.0 · 2021-06 · Stack Overflow · on “Char bot Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found”
I tried making an AI chat bot in Python language using PyCharm IDE via the code given below. But, there is an error coming of tensoflow regarding cuda. I was following tutorial of NeuralNine. Here is the link of the video -> [this video] This was my code of intents.json import random import json import pickle import numpy as np import nltk from nltk.stem import WordNetLemmatizer from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Activation, Dropout from tensorflow.keras.optimizers import SGD lemmatizer = WordNetLemmatizer intents = json.loads(open('intents.json').read()) words = [] classes = [] documents = [] ignore_letters = ['!','?','.',','] for intent in
Recommends Clark · 2022-01 · Stack Overflow · on “Neural Network Error, Can anyone help me?”
I was watching the YouTube video by Neural Nine about how to create an intelligent chatbot using neural networks (link to the video = [this video] ). I followed it step by step. Everything worked fine until I tried to execute the training.py document. The following code: import random import json import pickle from tabnanny import verbose import numpy as np import nltk from nltk.stem import WordNetLemmatizer # used for the word stem (ex. work, work-ed, work-ing) from tensorflow.python.keras.models import Sequential from tensorflow.python.keras.layers import Dense, Activation, Dropout from tensorflow.python.keras.optimizer_v1 import SGD lemmatizer = WordNetLemmatizer() intents = json.loads(open('i
Cites YellowKing · 2020-12 · Stack Overflow · on “Getting modulenotfound error when importing tensorflow.keras”
I am following neural nine's tutorial on how to build a chatbot (witch can be found here [this video] ) and i had some issues installing tensorflow, but i finally did it, by first installing tensorflow-gpu , and then installing tensorflow. When i ran the program with these tensorflow imports: from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Activation, Dropout from tensorflow.keras.optimizers import SGD I get Traceback (most recent call last): File "c:/Users/User/Documents/Python Projects/chatbot/traning.py", line 9, in <module> import tensorflow.keras File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\tensorflow\__init__.py", line 41, in <m
Cites Njal_Inferno · 2020-12 · Stack Overflow · on “Python RuntimeError: error with Numpy installation”
Full error: RuntimeError: The current Numpy installation ('C:\Users\TomHu\PycharmProjects\pythonProject\venv\lib\site-packages\numpy\ init .py') fails to pass a sanity check due to a bug in the windows runtime. See this issue for more information: (a URL is here but stack overflow wouldnt allow it for some reason) I have just started using pycharm after watching a youtube video about using simple machine learning to make a chatbot ( [this video] you dont need to watch it as its unrelated to this but just if anyone cares) and the person in that used pycharm. I found it so much easier to use than the original/official python software. But I'm new to it so perhaps there is something to do with that.
Cites Juan Carlos Bellido Arenas · 2021-02 · Stack Overflow · on “Input incompatible with the layer for chatbot prediction model”
this is my traning model, I pretty much follow this tutorial [this video] except I have to use stanza package for spanish version: import random import json import pickle import numpy as np import pandas as pd import nltk from nltk.tokenize.toktok import ToktokTokenizer import stanza from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Activation, Dropout from tensorflow.keras.optimizers import SGD toktok = ToktokTokenizer() intents = json.loads(open("intents.json", "rb").read()) words = [] classes = [] documents = [] ignore_letters = ['¿','?', '!', '.', ','] nlp = stanza.Pipeline('es') for intent in intents['intents']: for pattern in intent['patterns']: word_
Cites Tom · 2021-05 · Stack Overflow · on “IndexError: list index out of range in Tensorflow chatbot”
import random import json import pickle import numpy as np import nltk from nltk.stem import WordNetLemmatizer from tensorflow.keras.models import load_model lemmatizer = WordNetLemmatizer() intents = json.loads(open('intents.json', encoding='utf-8').read()) words = pickle.load(open('words.pkl', 'rb')) classes = pickle.load(open('classes.pkl', 'rb')) model = load_model('chatbot.model') def cleanSentance(sentence): sentence_words = nltk.word_tokenize(sentence) sentence_words = [lemmatizer.lemmatize(word) for word in sentence_words] return sentence_words def bagOfWords(sentence): sentence_words = cleanSentance(sentence=sentence) bag = [0] * len(words) for w in sentence_words: for i, word in en
Cites Tom · 2021-05 · Stack Overflow · on “ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type list)”
import random import json import pickle import numpy as np import nltk from nltk.stem import WordNetLemmatizer from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Activation, Dropout from tensorflow.keras.optimizers import SGD nltk.download('punkt') nltk.download('wordnet') lemmatizer = WordNetLemmatizer() intents = json.loads(open('intents.json', encoding='utf-8').read()) words = [] classes = [] documents = [] ignore_letters = ['?', '!', '.', ',', '(', ')', '/', "'"] for intent in intents['intents']: for pattern in intent["patterns"]: word_list = nltk.word_tokenize(pattern) words.extend(word_list) documents.append((word_list, intent['tag'])) if intent['
Cites Matthew Masody · 2022-02 · Stack Overflow · on “Local Variable 'result' referenced before assignment”
I am getting an UnboundLocalError. I don't know why, I was following a tutorial on YouTube on AI Chatbots ( [this video] ), and the code was the same as his. His worked, mine didn't. Code: def get_response(intents_list, intents_json): tag = intents_list[0]['intent'] list_of_intents = intents_json['intents'] for i in list_of_intents: if i['tag'] == tag: result = random.choice(i['responses']) break return result print("GO!") while True: message = input("") ints = predict_classes(message) res = get_response(ints, intents) print(res)
Cites Nixfee · 2023-01 · Stack Overflow · on “How to fix Value Error using NLTK array in Python?”
I am getting the following error: Traceback (most recent call last): File "X:\Learning\Learning.py", line 46, in training = np.array(training) ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (26, 2) + inhomogeneous part. on this code import random import json import pickle import numpy as np import nltk import tensorflow from nltk.stem import WordNetLemmatizer from keras.models import Sequential from keras.layers import Dense, Activation, Dropout from keras.optimizers import SGD from tensorflow.python.types.doc_typealias import document lemmatizer = WordNetLemmatizer() intents = json.loads(open("X