Chat Bot With PyTorch - NLP And Deep Learning - Python Tutorial (Part 3)

preview_player
Показать описание
In this Python Tutorial we build a simple chatbot using PyTorch and Deep Learning. I will also provide an introduction to some basic Natural Language Processing (NLP) techniques.

1) Theory + NLP concepts (Stemming, Tokenization, bag of words)
2) Create training data
3) PyTorch model and training
4) Save/load model and implement the chat

Resource:
This tutorial was inspired and adapted from the following article:

📚 Get my FREE NumPy Handbook:

📓 Notebooks available on Patreon:

If you enjoyed this video, please subscribe to the channel!

NLTK:

You can find the code on GitHub:

PyTorch Beginner Course:

Please checkout my website to see all tutorials:

You can find me here:

Icons:

#PyTorch #NLP #DeepLearning

----------------------------------------------------------------------------------------------------------
* This is a sponsored or an affiliate link. By clicking on it you will not have any additional costs, instead you will support me and my project. Thank you so much for the support! 🙏
Рекомендации по теме
Комментарии
Автор

To solve this: RuntimeError: Expected object of scalar type Long but got scalar type Int for argument #2 'target' in call to _thnn_nll_loss_forward

Change this line: labels = labels.to(device)
With this one: labels = labels.to(device, dtype=torch.int64)

codeplot
Автор

For Windows users struggeling with problems with the DataLoader: You need to include everthing from "dataset = ChatDataset()" to end in "if __name__ == '__main__':". If it then runs very slow with cuda, change line "train_loader = DataLoader(dataset = dataset, batch_size=batch_size, shuffle=True, num_workers = 2)" to "train_loader = DataLoader(dataset = dataset, batch_size=batch_size, shuffle=True, num_workers = 2, persistent_workers=True)"

secrety
Автор

If anyone facing error related to multiprocessing. Then try changing the value of num_workers = 0. This is because, if num_workers > 0 then the dataloader uses multiple workers to load the data in parallel. The error occurs due to the child worker tries to starts sending the data before the main process has finished its initialization phase.

Also, you can try by adding

if __name__ == '__main__':
import multiprocessing


# Your code goes here


this at top of your code, before importing anything.

alokraj
Автор

Thanks for putting so much effort to teach us. The visualizations come handy a lot. Although I didn't understand PyTorch part much. but I will check out your PyTorch series.

Thank you very much. Slapped that like and subscribe button. Keep making such quality videos!!!

akashverma
Автор

Hello, i have a question.
If the input size and output size increase, such as the input size becoming around 250, do we need to adjust the values of the hyperparameters, such as epoch, batch size, learning rate, or hidden layers? Or do you have any suggestions for determining the hyperparameters? Thank you for your time to read and respond. I appreciate it.

ndrvndr
Автор

hi! very useful and comprehensive!
as a beginner I made the most of it!!!
🌺🌺🌺

mahdiehalirezaei
Автор

Great video... I hope you would do a video on how you will validate this or how to validate chatbot to show if it's overfitting....

Thanks..

tomcat
Автор

Anyone can help me with this exception if I enter another question different in sysntax to chatbot he didn't recognize it ? If it has the same meaning, it give me response if I enter the same pattern ?

sohairmahmoud
Автор

I am getting this error "Can't get attribute 'ChatDataset' on <module '__mp_main__' from 'C:\\Projects\\Artificial Intelligence\\train.py"
Please Help

verifiednahihu
Автор

isnt this NN with only one hidden layer? wich is self.l2 ? and l1 is the input layer and l3 is the output layer ?

oz
Автор

hi i am facing this issue can someone please help me "only integer scalar arrays can be converted to a scalar index"

hamzanallwala
Автор

when and where did you initialise the weights to the neurons ?

anonymousgod
Автор

Thanks a lot for this tutorial! You're awesome!

tashifhoda
Автор

question, at 10:56 why did you do outputs = model(words) rather than outputs = model.forward(words)?

python.programmer
Автор

ITS WORKS FOR ME!! For Window users


Error :
if _name_ == '__main__':
freeze_support()



train_loader = DataLoader(dataset=dataset, batch_size=batch_size, shuffle=True, num_workers=2) #Replace this with the below line of code
train_loader = DataLoader(dataset=dataset, batch_size=batch_size, shuffle=True)



labels = labels.to(device) #Replace this with the below line of code

labels = lables.to(device).long()
or
labels = labels.to(device, dtype=torch.int64)

Geek
Автор

thank you very much. can you pls show us the accuracy value also?

souravjyoti
Автор

I am getting this error please help sir.
Everything in the code is the same as yours
.
.
Traceback (most recent call last):
File "E:\Charusat\5thSem\SGP\Code\Chatbot\train.py", line 84, in <module>
outputs = model(words)
File "C:\Python39\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Python39\lib\site-packages\torch\nn\modules\module.py", line 201, in _forward_unimplemented
raise NotImplementedError
NotImplementedError

parthshah
Автор

Hi there, I seem to be getting an error with the device part:

Traceback (most recent call last):
File "C:\Users\ProfK\Desktop\Kyko\train.py", line 72, in <module>
device = torch.device('cuda' if torch.cuda.is_avaliable() else 'cpu')
AttributeError: module 'torch.cuda' has no attribute 'is_avaliable'

(currently using pytorch version 1.7.1+cpu, which I installed using pip)

dr_von_kraft
Автор

is this bot replies from the set of answers only? and how to train this bot?

deepanshiagarwal
Автор

How can we get the graphs from the training?

anupamdungdung