Text Classification Using BERT & Tensorflow | Deep Learning Tutorial 47 (Tensorflow, Keras & Python)

Поділитися
Вставка
  • Опубліковано 27 сер 2021
  • Using BERT and Tensorflow 2.0, we will write simple code to classify emails as spam or not spam. BERT will be used to generate sentence encoding for all emails and after that we will use a simple neural network with one drop out layer and one output layer.
    What is BERT? • What is BERT? | Deep L...
    Code: github.com/codebasics/deep-le...
    Do you want to learn technology from me? Check codebasics.io/?... for my affordable video courses.
    Deep learning playlist: • Deep Learning With Ten...
    Machine learning playlist: • Machine Learning Tutor...
    🔖Hashtags🔖
    #BERTModel #bertmodelnlppython #BERTtextclassification #BERTtutorial #tensorflowbert #tensorflowberttutorial
    🌎 My Website For Video Courses: codebasics.io/?...
    Need help building software or data analytics and AI solutions? My company www.atliq.com/ can help. Click on the Contact button on that website.
    🎥 Codebasics Hindi channel: / @codebasicshindi
    #️⃣ Social Media #️⃣
    🔗 Discord: / discord
    📸 Dhaval's Personal Instagram: / dhavalsays
    📸 Instagram: / codebasicshub
    🔊 Facebook: / codebasicshub
    📱 Twitter: / codebasicshub
    📝 Linkedin (Personal): / dhavalsays
    📝 Linkedin (Codebasics): / codebasics
    ❗❗ DISCLAIMER: All opinions expressed in this video are of my own and not that of my employers'.

КОМЕНТАРІ • 145

  • @codebasics
    @codebasics  2 роки тому +1

    Check out our premium machine learning course with 2 Industry projects: codebasics.io/courses/machine-learning-for-data-science-beginners-to-advanced

    • @symaafsha6921
      @symaafsha6921 2 роки тому

      Sir can i use this bert layer code with LSTM/GRU for better accuracy ? @codebasics.
      It will be clear if you answer it?

    • @shreyshukla8168
      @shreyshukla8168 5 місяців тому

      Import tensorflow_text = text
      Not working my Jupiter not book
      Mene install bhi kara to
      Colud not find a version that satisfied esa error aa raha he anybody please help

  • @amoghdeshpande8068
    @amoghdeshpande8068 2 роки тому +14

    I think these are the most underrated videos on deep learning. The concepts are explained so well. Please keep making more videos.

  • @codebasics
    @codebasics  2 роки тому +18

    I had previously uploaded this video but code in that video had some issues handling imbalance in the classes. I've fixed those issues and recorded this new video. Thanks Abhishek and few others who pointed out the issues.

    • @mudassaraliansari8969
      @mudassaraliansari8969 2 роки тому

      Hello, sir I was trying to seach "feature engineering codebasics" your playlist was not coming .After that I have to go to your youtube channel and from there I viewed that playlist.Please check if that problem is facing my me only .

    • @Knight-Walker
      @Knight-Walker 2 роки тому +1

      Thanks for making the video again. I appreciate the work you do for everyone.

    • @rayyanamir8560
      @rayyanamir8560 2 роки тому

      @@mudassaraliansari8969 Same is happening with his machine learning playlist. Its not visible on his playlist but if i search it on search bar, It appears. Very strange.

  • @fuehnix
    @fuehnix Рік тому +2

    Oh thank god, finally someone who explains well AND covers the topic in enough depth to be useful.

  • @mahedihassanshawon4821
    @mahedihassanshawon4821 Рік тому +1

    Underrated channel tbh..He needs more recognition. Thanks a lot for supporting us.

  • @maxhuttmann4760
    @maxhuttmann4760 2 роки тому +1

    You are awesome, this is first actual slow enough and easy BERT starting video i've seen and suited me very much!

  • @sanketsonu6701
    @sanketsonu6701 2 роки тому +2

    Thanks. Very well explained. You explains the hidden insights which clears all doubts and make concepts simple and easy to understand.

  • @MS-BeatrizBosques
    @MS-BeatrizBosques Рік тому +2

    Thank you so much for your videos! You don't know how much you have helped me. I was really scared to dive into transformers but you have made it very easy to understand.

  • @mahsasharifi2230
    @mahsasharifi2230 2 роки тому +2

    As soon as I watched this video I subscribed your channel. The videos and tutorials are super useful. Thanks for sharing these valuable knowledge with us for free :)

  • @kathira5691
    @kathira5691 Рік тому +2

    I am getting No matching distribution found for tensorflow_text==2.12 error while installing tensorflow_text using pip.Could you please help on this.Thank you

  • @sudharsanb9391
    @sudharsanb9391 2 роки тому +2

    sir i have seen your Complete Data analyst roadmap and Data Science roadmap video.I was very amazing.I request you to upload a video on Complete roadmap for learning DSA with resources.so that it can help students like me in placements.Thank You

  • @ss-dy1tw
    @ss-dy1tw 2 роки тому +4

    Thank u so much, need more videos related to NLP, need more advanced concepts/projects in NLP area

    • @codebasics
      @codebasics  2 роки тому +5

      yes I will start working on NLP soon

  • @dronacharyulu755
    @dronacharyulu755 Рік тому +1

    can we use the hidden layers(only CLS) generated from the bert model as a features , to train the tfdistilled bert for binary classification task

  • @junaidreshi2472
    @junaidreshi2472 2 роки тому +1

    What about using sequence_output vectors as input to LSTM as it needs 3D input?

  • @rahil1575
    @rahil1575 2 роки тому

    Thanks for the video.can you please let us know,how can we proceed if the text input is high (more no of tokens)

  • @roopagowda9271
    @roopagowda9271 Рік тому

    Hello...can you please confirm if removal of stopwords,numbers,stemming etc is required in this case ?

  • @pearlrodrigues3036
    @pearlrodrigues3036 Рік тому

    Thank you so much for your videos! But i have a doubt since balancing the data in multi label classification doesn't help cause words have similar meanings ,what can be done?

  • @bhuvneshsaini93
    @bhuvneshsaini93 2 роки тому

    Hi, Last dense layer throws an error if classes more than 2, example spam, ham ,social. How to set output (Dense) (None, 1) 769 dropout[0][0] to output (Dense) (None, 3) 769 dropout[0][0]

  • @mchafe
    @mchafe 2 роки тому

    Please Sir, how can I use BERT Embedding as input to Embedding layer of an LSTM.
    Thanks

  • @natreven1122
    @natreven1122 Рік тому +1

    Thank you very much! You really helped me!

  • @buddhikaweerasinghe4113
    @buddhikaweerasinghe4113 2 роки тому

    How do we save the model & use in a another application ? It throws an error when I load the trained model from saved path.

  • @ayushbhalani7242
    @ayushbhalani7242 2 роки тому

    Can a BERT model be used for a task like scoring resumes according to job description ?

  • @slatan7239
    @slatan7239 2 роки тому

    How can I download the datasets which is used in this video? Can you give me the link?

  • @anjalipatel9028
    @anjalipatel9028 3 місяці тому

    When I am using bert,then it is not necessary to remove stop word from corpus?

  • @smartoo80
    @smartoo80 3 місяці тому

    @codebasics what if I have more then one category who to deal with that

  • @kennethnavarro3496
    @kennethnavarro3496 2 роки тому

    Bro watching these tutorials make me want to blow my brain up with the amount of times you mention your previous videos.

  • @LordPBA
    @LordPBA Рік тому

    wonderful!! but... what if we have 3 or more categories instead of just 2? Thanks a lot

  • @African-lady
    @African-lady Рік тому

    Thank you so much for this video. This is very helpful for my master's project. Please the model you built in the video, is it a fine-tuning of the last layer of BERT or completely retraining all BERT layers?

  • @umarghaffar9149
    @umarghaffar9149 2 роки тому

    Hi sir, Thank you for this amazing video. I have followed your video and used bert model for text classification and the accuracy of my model is very low. Can you help me

  • @hssp1534
    @hssp1534 2 роки тому

    Sir I have downloaded BERT encoder and preprocess as a rar file from the link. Please tell me how to use them in the coding? I dont want to load the files through http url but from the files i downloaded. Would be of great help, Thank you!

  • @francisatoyebi
    @francisatoyebi 2 роки тому

    Please help,
    How can I input SMOTE for oversampling in this model?

  • @jatayubaxi4553
    @jatayubaxi4553 2 роки тому

    Great video. Very easy to follow.

  • @hiralpatel1838
    @hiralpatel1838 26 днів тому

    Hi, if I have multiple categories that I want to sort my data into (right now in this video there are 2: ham and spam) how might I adjust this model? The sigmoid activation function would not be usable correct?

  • @AI_4214
    @AI_4214 Рік тому

    Thanks for the video, I am getting an error saying failed to covert Numpy array to Tensor.

  • @guillaumeguitarian9642
    @guillaumeguitarian9642 Рік тому

    Hi, thanks for the Vid.
    Is it possible to make that code run with and AMD GPU ?

  • @verma_raunit
    @verma_raunit 7 місяців тому +4

    The code do not work now.

  • @rutvisheth2634
    @rutvisheth2634 Рік тому

    if my task is classification with Bert and RNN-specially BiGRU then what output of BERT I need to use ? Pooled or sequential? If I am using Pooled then I am getting error of dimension as rnn requires 3d tensor. Please help with it.

  • @codewithgtm
    @codewithgtm Рік тому

    Which algorithm we are using for the text classification here? Can anyone tell me please?

  • @maxw5667
    @maxw5667 2 роки тому

    Very useful video, thanks a lot!

  • @pwchan9748
    @pwchan9748 2 роки тому

    is it possible to add custom tokens or synonyms to the Bert model? for example, J=J, Q=Q, A = Apple, something like these. if it's possible, how to do it on Tensorflow?

  • @sapnilpatel1645
    @sapnilpatel1645 2 роки тому

    Very useful video. Thank you so much.

  • @nekopus
    @nekopus 2 роки тому

    anyway, can we convert this transfer learning to tflite format?

  • @Sandesh.Deshmukh
    @Sandesh.Deshmukh 8 місяців тому +1

    Well Explained ..Thank you for this wonderful explanation 👏

    • @codebasics
      @codebasics  8 місяців тому +1

      Glad you liked it!

  • @souvikghosh1735
    @souvikghosh1735 2 роки тому

    Sir How do I download the dataset?Can You provide the link

  • @hadianasliwa
    @hadianasliwa 10 місяців тому

    when running this code
    return bert_encoder(preprocessor)['pooled_output']
    I'm getting an error :
    TypeError: Exception encountered when calling layer 'keras_layer_7' (type KerasLayer).
    pruned(input_ids, input_mask, segment_ids) missing required arguments: input_ids, segment_ids.
    Call arguments received by layer 'keras_layer_7' (type KerasLayer):
    • inputs={'input_type_ids': 'tf.Tensor(shape=(2, 128), dtype=int32)', 'input_word_ids': 'tf.Tensor(shape=(2, 128), dtype=int32)', 'input_mask': 'tf.Tensor(shape=(2, 128), dtype=int32)'}
    • training=None

  • @shanumathew5449
    @shanumathew5449 10 місяців тому

    Can you do Spoiler Detection with BERT ? I have been trying for some time but I am not able to.

  • @champruban3612
    @champruban3612 Рік тому

    helo sir, I want to know one thing for code mixing language like hindi in english letter does Muril BERT understand this hinglish which is english letter wriiten hindi pronounciation

  • @rajm5349
    @rajm5349 2 роки тому

    sir for getting embed values u explained grapes and banana r similar, then when we relate it to mails, it mean that the mails which r coming r not similar to his current situation and that result to spam

  • @serhatkalkan2339
    @serhatkalkan2339 2 роки тому

    Is there much to adjsut for multiple classification?

  • @varunsayalauthor
    @varunsayalauthor Рік тому

    Great video. I am facing an issue installing tensorflow_hub: cannot import name 'deserialize_keras_object' from partially initialized module 'keras.saving.legacy.serialization' . Any thoughts?

  • @sciadventure
    @sciadventure Рік тому +1

    Perfectly Expalined! Thanks a lot.

    • @shreyshukla8168
      @shreyshukla8168 5 місяців тому

      Import tensorflow_text = text
      Not working my Jupiter not book
      Mene install bhi kara to
      Colud not find a version that satisfied esa error aa raha he anybody please help

  • @spider853
    @spider853 Рік тому +6

    I knew Jeff Bezos and banana has a lot in common 🤣 Great video btw

  • @saumyabansal3549
    @saumyabansal3549 2 роки тому

    How can we apply BERT on multiclass classification problem?

  • @subratasaha4446
    @subratasaha4446 Рік тому

    Sir If it is a multi class classification the where should I change the code

  • @user-kt2en3cv8n
    @user-kt2en3cv8n 4 місяці тому

    what i have to search in kaggle to get that dataset

  • @maxlgemeinderat9202
    @maxlgemeinderat9202 2 роки тому

    Hi, great video! What would you to to fine tune this model? :)

  • @harsh2014
    @harsh2014 Рік тому

    Thanks for this nice tutorial !

  • @bhupendrapatel7617
    @bhupendrapatel7617 2 роки тому

    Using same code, I got error "Cast string to float is not supported
    [[node binary_crossentropy/Cast (defined at :1) ]] [Op:__inference_train_function_85259]
    Function call stack:
    train_function". I tried to solve error on my end but did not.

  • @stanislavzamecnik3049
    @stanislavzamecnik3049 2 роки тому

    Thanks for the video. You are amazing!

  • @kisholoymukherjee
    @kisholoymukherjee Рік тому

    Thanks for the great explanation. Really heplful

  • @DiAd188
    @DiAd188 2 роки тому

    Hi Sir,
    Instead of your output I'm getting:
    Keys : ['input_mask', 'input_type_ids', 'input_word_ids']
    Shape : (1, 128)
    Word Ids : Tensor("strided_slice_3:0", shape=(12,), dtype=int32)
    Input Mask : Tensor("strided_slice_4:0", shape=(12,), dtype=int32)
    Type Ids : Tensor("strided_slice_5:0", shape=(12,), dtype=int32)
    Do you know why I would get this output?

  • @sudarshanaramireddy373
    @sudarshanaramireddy373 2 роки тому

    Is there a code for NLP Model without labels (i mean Unsupervised ML) ?, i am struggling to find ;)

  • @rohitnarwal3538
    @rohitnarwal3538 Рік тому +1

    I can't find the dataset can someone help me

  • @maheshreddy6871
    @maheshreddy6871 2 роки тому

    You are teaching in Nice manner. Can we have NER task Architecture explanation for Bert & How it is Working and some code for implementation of NER

  • @kemingwu2880
    @kemingwu2880 2 роки тому +1

    very helpful,thank you!

  • @ashwinideshmukh2198
    @ashwinideshmukh2198 2 роки тому

    sir what if i have multilabel dataset like 6 labels

  • @tanmayparanjape3733
    @tanmayparanjape3733 2 роки тому

    Can you please show how to plot the loss graph?

  • @arindammukherjee391
    @arindammukherjee391 2 роки тому

    Can you please show a real time deployment of a model like this on AWS

  • @amityadav5797
    @amityadav5797 2 роки тому

    everything work fine but when i m trying to fit the model it is giving me error as " ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type float)." I m stuck so bad anyhelp would be appreiciatable, thank you in advance

  • @AreebaBatool-nt2hz
    @AreebaBatool-nt2hz Місяць тому

    can you provide me the link of this data set

  • @shakes115
    @shakes115 2 роки тому +1

    Great Video! By the way, a small typo, the percentage of spam is 747/(4825+747),

  • @yusufsAnt31
    @yusufsAnt31 2 роки тому

    great video, thanks sir!

  • @kathira5691
    @kathira5691 Рік тому +1

    Thanks for sharing this nice well explained concept.

    • @shreyshukla8168
      @shreyshukla8168 5 місяців тому

      Import tensorflow_text = text
      Not working my Jupiter not book
      Mene install bhi kara to
      Colud not find a version that satisfied esa error aa raha he anybody please help

  • @sulaimankhan956
    @sulaimankhan956 Рік тому

    Sir, I need code as Classifier without sequential layers.

  • @sadikaljarif9635
    @sadikaljarif9635 2 роки тому

    what is bert_preprocess???can i use this for distilbert for fake news detection???

  • @shezanmahmud1621
    @shezanmahmud1621 2 роки тому

    How can I set up learning rate here?

  • @arvindmewada7355
    @arvindmewada7355 2 роки тому

    Can we put bert output into SVM

  • @shreyshukla8168
    @shreyshukla8168 5 місяців тому

    Import tensorflow_text = text
    Not working my Jupiter not book
    Mene install bhi kara to
    Colud not find a version that satisfied esa error aa raha he anybody please help

  • @rabailmushtaq147
    @rabailmushtaq147 2 роки тому

    I see this error when I try to run the Bert pre-processor and Bert encoder
    OSError: SavedModel file does not exist at: C:\Users\admin\AppData\Local\Temp\tfhub_modules\602d30248ff7929470db09f7385fc895e9ceb4c0\{saved_model.pbtxt|saved_model.pb}
    can you please tell me what's wrong ?

  • @arkeshashah4650
    @arkeshashah4650 2 роки тому

    very nice Explanation, very helpful to me. Thanks. Can You make Video on ELMO Word embedding?

  • @nastaran1010
    @nastaran1010 5 місяців тому +1

    Hello. I remember you said that, NN is not suitable for working with text, as some disadvantages. why you used NN as a model here?.

  • @yonahcitron226
    @yonahcitron226 2 роки тому

    please do more in-depth stuff on NLP!!

  • @meceffeukada3767
    @meceffeukada3767 2 роки тому

    What's the point of inputs classes (spam/ham) here ? why you didn't use them ?

  • @prabhamelady1680
    @prabhamelady1680 2 роки тому

    very nice video sir. Thanks

  • @Areshk
    @Areshk 5 місяців тому

    I have almost 1200+ labels, It is a good idea to use this model?

  • @tanusreenath3857
    @tanusreenath3857 Рік тому

    Can you share the dataset link

  • @reemaljaber
    @reemaljaber 2 роки тому

    i copied your steps but the model is extremely slow how could i fix it .. it takes hours and hours;(?

  • @adamatom2826
    @adamatom2826 2 роки тому +3

    Thanks for these great videos. Quick question - I have watched your whole maching learning+deep learning series so far, and I'm wondering: are there ways one can tell whether the models discussed in the ML videos (linear regression, logistic, random forest, etc) versus a neural network is better suited to a situation? Or can you only know by testing all of them out, like in a GridSearchCV? Could you perhaps discuss this in a video?

    • @codebasics
      @codebasics  2 роки тому +4

      Neural networks are best for unstructured data (images, text, audio, video) and when the training dataset is huge. For structured data statistical models are preferred.

    • @adamatom2826
      @adamatom2826 2 роки тому

      @@codebasics Thanks so much for replying and for selflessly producing these videos.

  • @precious_orim
    @precious_orim Рік тому

    Thank you so much sir pls where can I find the code?

  • @mithilanavishka4531
    @mithilanavishka4531 2 роки тому

    If the value is more than 0.5, how can it be a spam email? Why can't they be ham email?

  • @williamjiang1089
    @williamjiang1089 2 роки тому +1

    Hey, thanks for the video. I was wondering at the end for inferences, you get decimal values like 0.8 which leans towards "Spam". However, is there a way to specifically return "Spam" with like 80% confidence or something like that, instead of just the decimal values?

    • @aditya_01
      @aditya_01 2 роки тому

      yes right a custom function like def funct(score): if score>=0.5 return (score*100,"spam") else return (100-score*100,"Ham")

    • @himeshkoli8607
      @himeshkoli8607 2 роки тому

      @@aditya_01 or else we can use np.where function to classify spam and ham

  • @sanity5277
    @sanity5277 8 місяців тому

    dude you are awesome

  • @pythonking_stem1527
    @pythonking_stem1527 Рік тому

    Man, You are a legend!

  • @muhammadaminkhan9328
    @muhammadaminkhan9328 Рік тому

    Thank you sir for your valuable lectures. Can you direct me to one of your content about XLNet Model?

  • @luiscao7241
    @luiscao7241 2 роки тому +2

    Thank you very much for the useful lesson. Can you tell me what the output format of multi-class text classification?

    • @anonanon9660
      @anonanon9660 2 роки тому

      Simply add number of neurons as the number of classes in the last layer (in this video he used one, so change it), one-hot encode the classes, use a loss function that is used for multi-class classification.

  • @meceffeukada3767
    @meceffeukada3767 2 роки тому

    how can i adapt the dense layer in the case of multiclass classification ?

    • @kmnm9463
      @kmnm9463 2 роки тому

      You can set the activation function as 'softmax' instead of 'sigmoid' in the final layer of the model.

  • @sulaimankhan956
    @sulaimankhan956 Рік тому

    very interested

  • @AreebaBatool-nt2hz
    @AreebaBatool-nt2hz Місяць тому

    which data set

  • @christopherrahme780
    @christopherrahme780 2 роки тому

    Thanks a lot for the video.
    This is great for binary classification. Any idea on how to do the same when we have more than two classes? (e.g. science, technology, linguistics, other)

  • @kunwarankush6030
    @kunwarankush6030 2 роки тому

    sir, please make one video on named entity recognization using bert