Intelligent AI Chatbot in Python

Поделиться
HTML-код
  • Опубликовано: 26 сен 2024

Комментарии • 1 тыс.

  • @JosephElliott-kx9yj
    @JosephElliott-kx9yj Год назад +249

    A bit old now, here is some updated code for anyone watching.
    import random
    import json
    import pickle
    import numpy as np
    import tensorflow as tf
    import nltk
    from nltk.stem import WordNetLemmatizer
    lemmatizer = WordNetLemmatizer()
    intents = json.loads(open('intents.json').read())
    words = []
    classes = []
    documents = []
    ignoreLetters = ['?', '!', '.', ',']
    for intent in intents['intents']:
    for pattern in intent['patterns']:
    wordList = nltk.word_tokenize(pattern)
    words.extend(wordList)
    documents.append((wordList, intent['tag']))
    if intent['tag'] not in classes:
    classes.append(intent['tag'])
    words = [lemmatizer.lemmatize(word) for word in words if word not in ignoreLetters]
    words = sorted(set(words))
    classes = sorted(set(classes))
    pickle.dump(words, open('words.pkl', 'wb'))
    pickle.dump(classes, open('classes.pkl', 'wb'))
    training = []
    outputEmpty = [0] * len(classes)
    for document in documents:
    bag = []
    wordPatterns = document[0]
    wordPatterns = [lemmatizer.lemmatize(word.lower()) for word in wordPatterns]
    for word in words:
    bag.append(1) if word in wordPatterns else bag.append(0)
    outputRow = list(outputEmpty)
    outputRow[classes.index(document[1])] = 1
    training.append(bag + outputRow)
    random.shuffle(training)
    training = np.array(training)
    trainX = training[:, :len(words)]
    trainY = training[:, len(words):]
    model = tf.keras.Sequential()
    model.add(tf.keras.layers.Dense(128, input_shape=(len(trainX[0]),), activation = 'relu'))
    model.add(tf.keras.layers.Dropout(0.5))
    model.add(tf.keras.layers.Dense(64, activation = 'relu'))
    model.add(tf.keras.layers.Dropout(0.5))
    model.add(tf.keras.layers.Dense(len(trainY[0]), activation='softmax'))
    sgd = tf.keras.optimizers.SGD(learning_rate=0.01, momentum=0.9, nesterov=True)
    model.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])
    model.fit(trainX, trainY, epochs=200, batch_size=5, verbose=1)
    model.save('chatbot_model.h5')
    print('Done')

    • @ericlacerda8949
      @ericlacerda8949 Год назад +17

      man you just saved my code by changing words.append to words.extend
      tyvm bro

    • @mr.hatem_
      @mr.hatem_ Год назад +1

      Thank you

    • @swagatrout3075
      @swagatrout3075 Год назад +5

      thaks bro
      trainX = training[:, :len(words)]
      trainY = training[:, len(words):]

    • @jihyeonku
      @jihyeonku Год назад +2

      oh my god thank you so much now it works

    • @shravanthj1447
      @shravanthj1447 Год назад +1

      sike bro

  • @smhaseeb
    @smhaseeb 3 года назад +210

    Instructions unclear, made Ultron. 😂

    • @jamieharper5665
      @jamieharper5665 Год назад +6

      😂 this had me laughing way more than I expected lol

    • @_EnderTv
      @_EnderTv 10 месяцев назад +3

      same😅

    • @marcoamir5107
      @marcoamir5107 3 месяца назад +1

      😂😂😂😂

  • @tomas5970
    @tomas5970 3 года назад +471

    Awesome content! when are we getting the biceps tutorial tho?

  • @joeljohn2679
    @joeljohn2679 3 года назад +13

    Man, you are THE ONLY ONE explaining this intent type of neural net-based chatbot. Thanks a lot

  • @1215cubs
    @1215cubs 3 года назад +209

    A much-needed updated vision of the chatbot from Tech with Tim. Love this video. From a viewer standpoint and someone who is coding along with you to program this thing. Either don't put a video of yourself on the screen, put it in the upper right-hand corner, or make it smaller. It's hard to code along with you as the camera of yourself blocks some of your code in the video.

    • @godwiniheuwa9917
      @godwiniheuwa9917 3 года назад +21

      This video is more explanatory and far better than the tech tim video, and the tech tim guy was just rushing,

    • @tomcat9761
      @tomcat9761 2 года назад +1

      question, what kind of neural network architecture used here? Is it RNN?

    • @shreyjain6447
      @shreyjain6447 2 года назад +2

      @@tomcat9761 No. It's a simple ANN

    • @mahnoorhome
      @mahnoorhome Год назад +2

      hey. where can i get source code? any idea?

    • @Krbydav328
      @Krbydav328 Год назад +1

      try watching the video

  • @alex_mahone
    @alex_mahone 3 года назад +117

    Videos on neural network theory would be fantastic! Thanks again for another great video!

    • @tomcat9761
      @tomcat9761 2 года назад +1

      question, what kind of neural network architecture used here? Is it RNN?

    • @w花b
      @w花b Год назад +1

      ​@@tomcat9761 i don't know

    • @krishsharvesh8082
      @krishsharvesh8082 Год назад

      @@tomcat9761 its ANN

  • @ChannelName991
    @ChannelName991 3 года назад +59

    Man, you are so underrated. I always search for simple examples of complex topics. After looking at your videos I am able to implement the basics in my projects easily

    • @vipulkumar9858
      @vipulkumar9858 3 года назад

      ruclips.net/channel/UC0Bn9e36XqiiNZp9ClkPUww

    • @mahnoorhome
      @mahnoorhome Год назад

      hey. where can i get source code? any idea?

    • @RhinoTimelaps
      @RhinoTimelaps 11 месяцев назад

      type it, lmao. @@mahnoorhome

  • @JacobHKent
    @JacobHKent 3 года назад +34

    when it comes to trading in the various financial markets the relevance of professional guidance should not be undervalued as it could be the key to any traders success in profit making

    • @piricontes2844
      @piricontes2844 3 года назад

      spot on! but the usual problem is discovering well grounded professionals who can be trusted. have you got any reconmendations?

    • @tamastimea1709
      @tamastimea1709 3 года назад

      i could not have said it any better.

    • @JacobHKent
      @JacobHKent 3 года назад

      @@piricontes2844 I will highly recommend Michael Branagh, he helped me secure a passive source of income, made life quiet easier for me as I no longer had to work round the clock. I'd check if he's taking new investors now, and also ask if I can share his contact information to the public.

    • @piricontes2844
      @piricontes2844 3 года назад

      @@JacobHKent i have stumbled upon a couple of articles by him, never occured to me to look him up. i would sincerely appreciated if you coild help with his contact info.

    • @bensonmccredden7102
      @bensonmccredden7102 3 года назад

      @@JacobHKent Mr Branagh is one of the most productive traders out there. i would not say hes the best at what he does but one thing is certain, hes a man of integrity and he certaainly gets results

  • @antoniorivolta
    @antoniorivolta 3 года назад +81

    I never opened a RUclips notification so fast

  • @aishikbandyopadhyay8191
    @aishikbandyopadhyay8191 3 года назад +48

    Ah! Was waiting for this only!🔥

    • @NeuralNine
      @NeuralNine  3 года назад +7

      enjoy it! :)

    • @AkashSingh-di7vu
      @AkashSingh-di7vu 3 года назад +1

      Me too🤠

    • @TalesHerman
      @TalesHerman 3 года назад

      @@NeuralNine Hello, this error is returning: *lemmatize() missing 1 required positional argument: 'word'*

  • @miyurux
    @miyurux 3 года назад +9

    Bro You are one of the most Underrated YT channel I've ever seen..... Keep up the good work : - )

  • @SimonTiger
    @SimonTiger 3 года назад +16

    So...as far as the machine learning goes, it's just a text classification algorithm. I would love to see a version of this with actual text generation as well!

    • @NeuralNine
      @NeuralNine  3 года назад +7

      I mean it would be possible to combine it with the text generation tutorial I made some time ago ^^

    • @SimonTiger
      @SimonTiger 3 года назад

      @@NeuralNine Can't seem to find it!

    • @shanereedy8336
      @shanereedy8336 3 года назад +3

      @@SimonTiger I was hoping to find a comment like yours here. This may be the video he is referring to. ruclips.net/video/QM5XDc4NQJo/видео.html

    • @mahnoorhome
      @mahnoorhome Год назад

      hey. where can i get source code? any idea?

    • @khrissxander
      @khrissxander Год назад

      @@NeuralNine YOU should really make that happen as a video!!!

  • @masthad
    @masthad 3 года назад +14

    The video got really good but we don’t really clarify what packages to download. I know you said what at the beginning at Imports but it still gives me error messages with Tensorflow.
    For example: '
    To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. '

    • @ibaadahmed5925
      @ibaadahmed5925 2 года назад

      did you get it right??

    • @mysterious4496
      @mysterious4496 Год назад

      Hey, did you find the solution?
      PLEASE help

    • @mysterious4496
      @mysterious4496 Год назад

      @@ibaadahmed5925 Hey, did you find the solution?
      PLEASE help

  • @pw5687
    @pw5687 3 года назад +11

    it would be cool if you made a video where you combined a chatbot like this with/into a discord bot!

    • @owenknowles3796
      @owenknowles3796 3 года назад +1

      you'd just use discord.py to detect when a message is sent, use that message as the input for the AI, and output the AI's output as the discord message

    • @pw5687
      @pw5687 3 года назад

      @@owenknowles3796 didn't think about that thanks! Will try when computer switches on

    • @Fuel_The_Fire
      @Fuel_The_Fire Год назад

      @@pw5687 How'd it go?

  • @BarryGoodall
    @BarryGoodall 6 месяцев назад +2

    Thank you. Great commentary and clear explanations. Easy to follow how you built up the application. Perfect.

  • @cardosofede
    @cardosofede 3 года назад +4

    Hey bro, your programming style is sophistecated 🧑‍💻

  • @dreamsauce8745
    @dreamsauce8745 3 года назад +3

    For anyone having issues with the model not running. change train_x and train_y into a tensor and adjust the input shape of the model to be 15, 5

    • @akeeme8921
      @akeeme8921 3 года назад +4

      what do you mean by change them into a tensor

    • @poojashah3131
      @poojashah3131 Год назад

      can you share the code?

  • @foggers0476
    @foggers0476 3 года назад +6

    I love your videos! They're so useful :D I've just purchased your 7 in 1 book from amazon

  • @peschebichsu
    @peschebichsu 3 года назад +8

    20:42 very interested in the theory, I like how you explain and would be cool to hear it from you

  • @MrJoeflames
    @MrJoeflames Год назад +1

    if you get an error with hist = model.fit(np.array(train_x), np.array(train_y), epochs=200, batch_size =5, verbose=1 ), just delete "accuracy in model.compile

  • @prathmeshkulkarni2079
    @prathmeshkulkarni2079 9 месяцев назад +7

    #Dec 2023-
    import random
    import json
    import numpy as np
    import pickle
    import tensorflow as tf
    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
    from tensorflow.keras.preprocessing.sequence import pad_sequences
    # Download NLTK data
    nltk.download('punkt')
    nltk.download('wordnet')
    lemmatizer = WordNetLemmatizer()
    intents = json.loads(open('intents.json').read())
    words = []
    classes = []
    documents = []
    ignore_letters = ['?', ',', '!', '.']
    for intent in intents['intents']:
    for pattern in intent['patterns']:
    word_list = nltk.word_tokenize(pattern)
    documents.append((word_list, intent['tag']))
    words.extend(word_list) # Append words to the 'words' list
    if intent['tag'] not in classes:
    classes.append(intent['tag'])
    words = [lemmatizer.lemmatize(word.lower()) for word in words if word not in ignore_letters]
    words = sorted(set(words))
    classes = sorted(set(classes))
    pickle.dump(words, open('words.pkl', 'wb'))
    pickle.dump(classes, open('classes.pkl', 'wb'))
    training = []
    output_empty = [0] * len(classes)
    for document in documents:
    bag = []
    word_patterns = document[0]
    word_patterns = [lemmatizer.lemmatize(word.lower()) for word in word_patterns]
    # Create a bag of words with 1s and 0s
    bag = [1 if word in word_patterns else 0 for word in words]
    # Create the output row
    output_row = list(output_empty)
    output_row[classes.index(document[1])] = 1
    # Append the bag and output_row as separate lists
    training.append([bag, output_row])
    # Shuffle the training data
    random.shuffle(training)
    # Split the training data into X and Y
    train_x = np.array([item[0] for item in training])
    train_y = np.array([item[1] for item in training])
    model = Sequential()
    model.add(Dense(128, input_shape=(len(train_x[0]),), activation='relu'))
    model.add(Dropout(0.5))
    model.add(Dense(64, activation='relu'))
    model.add(Dropout(0.5))
    model.add(Dense(len(train_y[0]), activation='softmax'))
    sgd = SGD(learning_rate=0.01, momentum=0.9, nesterov=True)
    model.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])
    hist = model.fit(train_x, train_y, epochs=200, batch_size=5, verbose=1)
    model.save('Chatbot_model.h5', hist)
    print("Done!")

    • @rushabhshah12200
      @rushabhshah12200 6 месяцев назад

      What in the world! Thankfully I found you and now I trained my model correctly. I was getting this error:
      78 random.shuffle(training)
      ---> 79 training = np.array(training)
      80
      81 train_x = list(training[:, 0])
      ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (392, 2) + inhomogeneous part.
      I don't know what to do with this I asked every gpts even got link of source code in github then also getting same error. I just copied your code and hit run and then thankfully it worked.

    • @shorts-zq1ss
      @shorts-zq1ss 3 месяца назад

      THANKS A LOT.

  • @lorenzoricciardi7051
    @lorenzoricciardi7051 3 года назад +3

    sooo interested to the neural network theory!!! Love this channel so much, i've learned so much, thank you!!

  • @cartf15
    @cartf15 3 года назад +2

    brother please do not stop! you are awesome

  • @juliusmakowski7665
    @juliusmakowski7665 3 года назад +7

    I have to make one for school so this is perfect timing ;^)

    • @shelby255
      @shelby255 3 года назад +1

      Our school only do pascal bruh

  • @tansimbee11
    @tansimbee11 9 месяцев назад +1

    Well done. As I am new to chatbot() and python. Your video helped to fill in all the gaps in Tim video. Thanks brother.

  • @olegsheremeta1628
    @olegsheremeta1628 Год назад +2

    training = np.array(training) throws an error!
    ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (12, 2) + inhomogeneous part.

    • @davidpadillamunoz1140
      @davidpadillamunoz1140 Год назад +1

      Sorry if it's too late, but I solved this error with the following:
      training_array = []
      for item in training:
      part1 = np.array(item[0])
      part2 = np.array(item[-1])
      list_items = [part1, part2]
      training_array.append(list_items)
      Then you can use 'training_array' np.array(training) like.

  • @leonardorossoni1177
    @leonardorossoni1177 3 года назад +15

    When will you open a Discord Server?

  • @majestro4077
    @majestro4077 Месяц назад

    the thing about this intelligent ai is just that its not context based cuz it don't have access in the conversation history

  • @scholar1234
    @scholar1234 3 года назад +3

    Never seen this type of content before, really amazing

    • @danielniels22
      @danielniels22 3 года назад

      yeah, his tutorials are very applicable. i wonder what would happen to my knowledge if i carry one of that out each day for 1 month staright

  • @stanst2755
    @stanst2755 2 года назад +1

    Nice tutorial on basic Keras NN setup. The truth is there is no need for a NN here. What it does is a simple input text selector and a random generator to output the response text. You could do the same using regexp/similar text/soundex word matching.

    • @nostravis2770
      @nostravis2770 Год назад

      I was hoping i wouldn't be the only one realizing this. Using a NN for this is such overkill.

  • @abdulalimbaig3286
    @abdulalimbaig3286 2 года назад +6

    This is an amazing tutorial brother, thanks for all the knowledge you've shared! You earned a subscriber!

  • @ratto751
    @ratto751 3 года назад +14

    Hi, great content! Although, is it possible for you to upload the code in your videos to a github repo? Thanks

    • @Yankzy
      @Yankzy 3 года назад

      That will be great!

  • @samsam3215
    @samsam3215 3 года назад +13

    this tutorial is very useful! can I have the project source code for self-learning?

  • @odiushealer4759
    @odiushealer4759 3 года назад +5

    Can you make a series on neural network theory? This video was very helpful.Thanks

  • @chingyee2804
    @chingyee2804 3 года назад +1

    Yes I’m very interested in neural network theory! 🙋‍♂️🙋‍♂️🙋‍♂️🙋‍♂️🙋‍♂️

  • @audunlarssonkleveland4789
    @audunlarssonkleveland4789 2 года назад +3

    btw if you struggle with translation to vscode on the importation of tensorflow instead type "from tensorflow.python.keras.layers ...." and so on

    • @albertdecandia2644
      @albertdecandia2644 Месяц назад

      Thank you so much!! I was going crazy trying to find a solution.

  • @TISIMTISMTISM
    @TISIMTISMTISM 3 года назад +4

    This was amazing! Thank you so much I have learned a lot :D

  • @matheusgirardiscalabrin5651
    @matheusgirardiscalabrin5651 3 года назад +1

    I was recieving TypeError at 14:30
    This solve for me
    "
    pip install self
    nltk.download('wordnet')
    import self
    words = [lemmatizer.lemmatize(self, word) for word in words if word not in ignore_letters]
    words = sorted(set(words))
    "

  • @chetanbedi07
    @chetanbedi07 3 года назад +3

    for intent in intents['intents']:
    for pattern in intent['patterns']:
    word_list = nltk.word_tokenize(pattern)
    words.append(word_list)
    documents.append((word_list, intent['tag']))
    if intent['tag'] not in classes:
    classes.append(intent['tag'])
    This showing me error
    " For pattern in intent['patterns']
    KeyError : 'patterns'
    Please help me out!

  • @arthur6999
    @arthur6999 3 года назад

    man I was just building a hard-coded chatbot, this vid came in the right time for me. thanks bro

    • @arthur6999
      @arthur6999 3 года назад

      @Hotdog_man2 Minecraft lol yea

  • @ronit.dhingra_
    @ronit.dhingra_ 3 года назад +12

    NIce video! Can you make an in-depth tutorial on making a friend-like chatbot that uses neural networks and NLP, and adapts it to modern libraries like Keras and TensorFlow? I've been making a project, but I've been having some issues.

  • @apex21.1
    @apex21.1 Год назад +2

    one thing i hated is that tensorflow couldnt download on my pc

  • @justinfranzsevilla2310
    @justinfranzsevilla2310 3 года назад +39

    Ah yes, now I can make a very own best friend who can understand me :DDDD

  • @rinshinjalal1952
    @rinshinjalal1952 3 года назад

    i have'nt watched your video before this video but now ican't stop watching your video

  • @kifercastillo7876
    @kifercastillo7876 3 года назад +16

    I would love to see a video about the theory, great video, thank you:)

  • @ok-14907
    @ok-14907 3 года назад +1

    Thanks 👍 I was actually waiting for this.

  • @Match0Man
    @Match0Man 2 года назад +14

    Hi NeuralNine, this is a great piece. I would like to ask you if this tutorial would work for another language. Would it be enough to just edit intents, to comply with the language I would like to use? And the second question, do you have some tutorial, on how to implement this bot to streamlabs chatbot for twitch?

    • @knildawild
      @knildawild Год назад +4

      I tried it with german words and all I had to do is define the language in the word_tokenize function:
      nltk.word_tokenize(pattern,language='german')

    • @mahnoorhome
      @mahnoorhome Год назад

      hey. where can i get source code? any idea?

  • @HacKyNerDz
    @HacKyNerDz 3 года назад +5

    Your videos are always amazing, always i learn a lot from your videos 🤩🤩

    • @NeuralNine
      @NeuralNine  3 года назад +4

      appreciate it :D

    • @delvinanthony2798
      @delvinanthony2798 3 года назад +2

      @@NeuralNine Hey man for some reason whenever I say Hello or one of the greetings it says a goodbye response. Any idea why?

    • @kenzyscope2396
      @kenzyscope2396 Год назад

      @@NeuralNine can i get the source code please

  • @karl4563
    @karl4563 3 месяца назад

    thank you ! needed this in my school project

  • @LamsyTech
    @LamsyTech 3 года назад +6

    Awesome work bro!
    I like your videos
    Kudos to you
    I suggest you make a tutorial video on show to deploy an AI CHATBOT to back-end server to improve responsiveness and present more details.

  • @AdwaithAbhilash-k5z
    @AdwaithAbhilash-k5z 10 месяцев назад

    This helped me learn a lot about neural networks thanks!

  • @SkynetT-model
    @SkynetT-model 3 года назад +6

    and this is how my creator came to life.

  • @rayyanmairaj5330
    @rayyanmairaj5330 3 года назад +7

    Hey NeuralNine, really like the videos.
    Could you please like zoom in to the code... Or like increase the font. Its kinda difficult to see the code especially when not on full screen.
    Even when youre showing other stuff like how to install mingw for c++... The text looks really small
    But i really love your content and learn a lot. So if you could address that i'd be stoked

  • @krishnakumare8762
    @krishnakumare8762 3 года назад +2

    Traceback (most recent call last):
    File "E:/CODEING/lapsever/test.py", line 20, in
    model = load_model("chatbotmodel.h5")
    File "C:\Users\Mr.Programmer\PycharmProjects\pythonProject\venv\lib\site-packages\tensorflow_core\python\keras\saving\save.py", line 146, in load_model
    return hdf5_format.load_model_from_hdf5(filepath, custom_objects, compile)
    File "C:\Users\Mr.Programmer\PycharmProjects\pythonProject\venv\lib\site-packages\tensorflow_core\python\keras\saving\hdf5_format.py", line 166, in load_model_from_hdf5
    model_config = json.loads(model_config.decode('utf-8'))
    AttributeError: 'str' object has no attribute 'decode'
    error

  • @yaranassar1208
    @yaranassar1208 Год назад +3

    training = np.array(training) is returning an error, can you help?
    ---------------------------------------------------------------------------
    ValueError Traceback (most recent call last)
    Cell In[24], line 26
    24 # shuffle our features and turn into np.array
    25 random.shuffle(training)
    ---> 26 training = np.array(training)
    28 # create train and test lists. X - patterns, Y - intents
    29 train_x = list(training[:, 0])
    ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (27, 2) + inhomogeneous part.

  • @johnmal1980
    @johnmal1980 Год назад +1

    Bro was years ahead

  • @amantarar9077
    @amantarar9077 3 года назад +3

    there is correction on line 51 in chatbot.py ."responses" should be replaced with "response"

    • @noorulainnoor8831
      @noorulainnoor8831 2 года назад

      I code exactly same but couldn't able to to write any msg after "GO! Bot is running". can you help me? how to sort it out

  • @suomynona7261
    @suomynona7261 2 года назад +1

    Error: No name ‘models’ in module ‘LazyLoader’

  • @27omkarmahindrakar54
    @27omkarmahindrakar54 3 года назад +3

    Can you please provide the files of the bot
    (because mine didn't worked)

  • @dax_dc2608
    @dax_dc2608 3 года назад

    UNDERRATED , u deserve a million sub

  • @confused398
    @confused398 3 года назад +3

    When I added training data to the intents.json file, I got this error, anybody who can help?
    ValueError: Input 0 of layer sequential is incompatible with the layer: expected axis -1 of input shape to have value 38 but received input with shape (None, 84)
    I figured out that the 84 is just the amount of patterns in the intents.json file, but I haven't figured out why the input shape has to have a value of 38.

  • @umarhasnain7369
    @umarhasnain7369 3 года назад +1

    Can you please zoom a bit more on the code? Would be better to understand 🙂.

  • @raghawpanpaliya7477
    @raghawpanpaliya7477 2 года назад +3

    Well, I followed along and as I ran it....this guy decided to reply "Hello" with "Talk to you later" LMAOO 😭Even a bot isnt interested in talking with me 😒

  • @steffqing
    @steffqing 2 года назад +2

    I keep getting hit by errors everywhere despite following the code a-z

  • @bloodang6793
    @bloodang6793 Год назад +4

    Hello... i have tried to copy your code now in 2023 and apparently there is an issue with training = np.array(training) since the [bag, output_row] columns don't have the same dimensions (maybe I have copied something wrong along the way...).
    I have came up with a solution that bypass the issue, although its quite a caveman style solution and I do not have the knowledge to understand its consequences, but it does not crash the code and allows me to train the chatbot.
    solution:
    when defining the dimensions of:
    output_empty = [0] * len(classes)
    instead do:
    output_empty = [0] * len(words)
    this way the dimensions of "bag" and "output_row" are the same. (It will fill the space with 0, so it shouldn't change the bot training accuracy... but what do I know :D )

    • @Kanishkaran.__
      @Kanishkaran.__ Год назад +1

      Hey what about importing tensorflow, I tried copying too but mines showing error like 'rebuild tensorflow with appropriate compiler flags'

    • @bloodang6793
      @bloodang6793 Год назад

      @@Kanishkaran.__ Not really sure, but as I figured lately its quite a lot about version compatibilities with TF and all these days. Try searching if your versions match.

    • @Kanishkaran.__
      @Kanishkaran.__ Год назад

      @@bloodang6793 What's the version used here?

    • @mysterious4496
      @mysterious4496 Год назад

      @@Kanishkaran.__ Hey, did you get a solution?

    • @Kanishkaran.__
      @Kanishkaran.__ Год назад

      @@mysterious4496 no

  • @haokaixuan
    @haokaixuan 3 года назад +1

    Hey manx nice content, always excited when you post a new video

  • @80sVectorz
    @80sVectorz 3 года назад +3

    my bot keeps saying the intent is goodbye even if I say "how are you?" it says hey or goodbye or talk to you later

    • @amulyaparitosh660
      @amulyaparitosh660 3 года назад +1

      I have similar problem.
      my bot keeps saying "hi", ""hello", "what can i do for you", even if i ask "what is your name"

    • @amulyaparitosh660
      @amulyaparitosh660 3 года назад

      please help

    • @isaacmuscat5082
      @isaacmuscat5082 3 года назад

      If there’s nothing wrong with the preprocessing you probably have to find a way to properly tune the model with a test set and a training set to prevent under or overfitting.

    • @roopeshk.r3219
      @roopeshk.r3219 3 года назад

      Hey, I have a Problem after training , type error in last 2 functions, While true, get_response

    • @delvinanthony2798
      @delvinanthony2798 3 года назад

      If you guys keep getting goodbye messages for other things change the error_threshold to 0.5 and if that doesn't work change the epochs in training.py to 800

  • @____________6063
    @____________6063 3 года назад

    Awesome tutorial, it worked right away! You definitely got me as a subscriber.

    • @ibaadahmed5925
      @ibaadahmed5925 2 года назад

      hey can u tell what extensions to download pls

  • @rakshamodi7503
    @rakshamodi7503 Год назад +2

    Sir, statement training= np.array(training) is showing error of array being inhomogeneous shape after 2 dimension. What would be the solution?

    • @dominickblue6006
      @dominickblue6006 Год назад +1

      It's because they optimizer used in 2020 is now considered legacy. I was able to run the pre-processor with the following alterations to my code.
      # Change the SGD import
      from tensorflow.keras.optimizers import SGD -> from tensorflow.keras.optimizers.legacy import SGD
      # Change the numpy training array
      training = np.array(training,) -> training = np.array(training, dtype=object)

    • @avery_person8126
      @avery_person8126 Год назад

      @@dominickblue6006 thank you

  • @kinjalkg7704
    @kinjalkg7704 3 года назад +4

    Hello, i am unable to install tensorflow!!please help

    • @Adhithya2003
      @Adhithya2003 3 года назад

      Use this video its very good and well we ruclips.net/video/zRY5lx-So-c/видео.html

    • @maxmayer3551
      @maxmayer3551 3 года назад

      tensorflow does not support python versions after 3.6.4, so you'll have to change your version

    • @ratto751
      @ratto751 3 года назад

      @@maxmayer3551 That's pure BS. It's available till Python 3.8

    • @maxmayer3551
      @maxmayer3551 3 года назад

      ​@@ratto751 I was using 3.8 and I had the same issue as this guy so I looked it up, read an article that told me tensorflow doesn't work beyond 3.6.4 so I switched versions and it completely fixed my issue. So if you really insist that my experience was purely circumstantial

    • @ratto751
      @ratto751 3 года назад

      @@maxmayer3551 Would you rather trust an article or the official TensorFlow GitHub and PyPi? I've been able to run TensorFlow on python 3.8. There must be some other problem with your PC since it works with 3.8 on mine.

  • @triplelp562
    @triplelp562 Год назад +2

    he doesn't even now what his own code is doing. I don't know from which video he pasted his but it is a good one. He can't explain one line of his code that's pretty embaressing. Don't youi think

  • @MatOgnutyun
    @MatOgnutyun 3 года назад +5

    The code is not working.
    output_row[classes.index(document[1])] = 1
    IndexError: list index out of range

  • @parkour8899
    @parkour8899 19 дней назад

    guy, you help me a lot of with this video, thanks so much!

  • @bogdannedelcu3209
    @bogdannedelcu3209 Год назад +1

    tenserflow.keras command is not working anymore, it's a naming conflict issue, you can open the __init___.py from tensorflow and edit from near the line 387 as you see: import typing as _typing
    if _typing.TYPE_CHECKING:
    from keras.api._v2 import keras
    else:
    _keras_module = "keras.api._v2.keras"
    keras = _LazyLoader("keras", globals(), _keras_module)
    _module_dir = _module_util.get_parent_dir_for_name(_keras_module)
    if _module_dir:
    _current_module.__path__ = [_module_dir] + _current_module.__path__
    setattr(_current_module, "keras", keras)

  • @anandhu5082
    @anandhu5082 3 года назад +3

    22:08 Hi, i'm new to DL.. When we use Softmax, if there are (say)two outputs in the network, it will output probabilities like [.4 ,.6] or [.1, .9] or [.5, .5] etc right? (sum always 1).. so even if we enter some gibberish as input, there will always be some output(s) above error threshold of (say) .25.
    How ill I tweak this so this won't happen? ( i mean if i enter "ahfliehf fsdlihfasdh" to bot, the outputs should be like something like [0.001, 0.00123])

  • @BrianFDeVore
    @BrianFDeVore 3 года назад +1

    This tutorial is fantastic! Thank you for sharing.

    • @vipulkumar9858
      @vipulkumar9858 3 года назад

      ruclips.net/channel/UC0Bn9e36XqiiNZp9ClkPUww

  • @mihailsoftware8219
    @mihailsoftware8219 3 года назад +16

    can i have the source code?

  • @syedsaadahmed2324
    @syedsaadahmed2324 2 года назад +1

    I am getting this error please help!
    "UnboundLocalError: local variable 'result' referenced before assignment"

    • @justgamingacademy9244
      @justgamingacademy9244 2 года назад

      received the same error. Have u found a solution to this? If so, please help me with it

  • @raivologins9299
    @raivologins9299 Год назад +1

    Line 36 'res = model.predict(np.array([bow]))[0]' if i print (res), it shows '[[nan nan nan nan nan nan]]' and nothing works
    Please help, Im struggling for like 5 days

    • @gowthamselvam2499
      @gowthamselvam2499 Год назад

      Don't waste your time, this code doesn't work

    • @raivologins9299
      @raivologins9299 Год назад

      @@gowthamselvam2499 Fr? Thank you. But I need to make chatbot. Do u have any sites where I could find tutorial?

  • @MACHINEBUILDER
    @MACHINEBUILDER 3 года назад +3

    Hey, any idea how you'd get this to run with tflite?
    Edit: Okay, I've gotten the model to run, but I realised nltk stemming is really slow. Is there a faster alternative?
    (actually I'll try figure out exactly what's taking ages)
    Edit #2: Nevermind, it all works, there's just a delay the first time the process is called for some reason (Which I'll try to trace and fix)
    Thanks for the great tutorial, can't wait to setup my own personal assistant!

  • @magmaslasher7604
    @magmaslasher7604 3 года назад +2

    Are you ever going to make a tutorial on a chatbot that generates its own responses?

  • @m.pavankalyan2650
    @m.pavankalyan2650 Год назад

    This video is really great and this AI projects series is extraordinary

  • @SaadAhmed-pu8wp
    @SaadAhmed-pu8wp 4 месяца назад

    Excellent and very helpful.. thanks a lot
    Would you make another one in which we can give command to the chatbot and it takes some action, for e.g. "open google chrome" or "close microsoft word".. TIA.

  • @morganhudson3185
    @morganhudson3185 Год назад

    bro your intro is fire

  • @raivologins9299
    @raivologins9299 Год назад +1

    Can someone please send code? I am trying to understand like 5 days why it doesn't work

  • @sobhandeepgope
    @sobhandeepgope 3 года назад +1

    Thank you very much sir, for this awesome tutorial....😍😍😍😍

  • @Lahirushub
    @Lahirushub 8 месяцев назад

    thanks, that works(some code mistakes corrects by chatGPT) nice video

  • @poojashah3131
    @poojashah3131 Год назад +1

    People getting Value Error, change model = load_model('chatbot_model.model') to model = load_model('chatbotmodel.h5')

  • @CREATIVECOMPUTEREDUCATION
    @CREATIVECOMPUTEREDUCATION Год назад +1

    Please Upload score code

  • @proflead
    @proflead 3 месяца назад

    Thanks for the tutorial!

  • @Joesignals
    @Joesignals Год назад

    I'm trying to create a chatbot for customer care, it is going to be a live support agent for industries like Telecom companies, so after I finish with all the knowledge you have shared maybe I will have some questions and everything else.

  • @deepankarpathak983
    @deepankarpathak983 3 года назад +1

    Thank you for such a wonderful content !

  • @stefanberlet7416
    @stefanberlet7416 Год назад

    training = np.array(training, dtype=object) ...works for me

  • @IvanAlexisChavezBarboza
    @IvanAlexisChavezBarboza Год назад

    Amazing tutorial, thanks for the lesson.

  • @projectlord9901
    @projectlord9901 Год назад +1

    Ok i hve a question.....why is my tensorflow and numpy showing eerors 😢

    • @its.me._.jaffery
      @its.me._.jaffery Год назад

      2023 code:
      import random
      import json
      import pickle
      import numpy as np
      import nltk
      from nltk.stem import WordNetLemmatizer
      from keras.models import Sequential
      from tensorflow.python.keras.layers import Dense, Activation, Dropout
      from keras.optimizers import SGD
      lemmetizer = WordNetLemmatizer()
      intents = json.loads(open('intents.json').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)
      # Use 'tag' if present, otherwise use 'tags'
      tag_key = 'tag' if 'tag' in intent else 'tags'
      documents.append((word_list, intent[tag_key]))
      if intent[tag_key] not in classes:
      classes.append(intent[tag_key])
      words = [lemmetizer.lemmatize(word) for word in words if word not in ignore_letters]
      words = sorted(set(words))
      classes = sorted(set(classes))
      pickle.dump(words, open('words.pkl', 'wb'))
      pickle.dump(words, open('classes.pkl', 'wb'))

  • @ArunKumar-gb6hz
    @ArunKumar-gb6hz 3 года назад

    Thanks for the Video Florian! 👏👏

  • @AL_383
    @AL_383 3 года назад

    a series about NN/ ai in general would be dope

  • @waseksamin3216
    @waseksamin3216 3 года назад

    Joey to the bot: how u doin...😎

  • @pratibhayadav4916
    @pratibhayadav4916 Год назад +1

    Is it really ai chatbot or static chatbot?

  • @mashaklepin3606
    @mashaklepin3606 Год назад

    All the people recently saying the code doesn't work... I got it working very quickly. There are a few slight changes and I'm sure if you really want to, you can figure it out.

    • @yazeedmizu3184
      @yazeedmizu3184 Год назад

      Mind sharing your knowledge with us brother?