How To Run Code From Git Repo In Google Collab GPU Notebook
In this post, I will show you how to run code BERT-Keyword-Extractor in Google Collab notebook. You can download following repo.
github.com/ibatra/BERT-Keyword-Extractor
First create a new notebook by going to File > New Python 3 Notebook
We need to turn on GPU option for this notebook. To do that go to edit > notebook settings and select GPU as hardware selector.
We need to install tensorflow-gpu to run this code. Do using following pip command.
!pip install tensor-gpu==2.0.0
Lets import the tensorflow now.
import tensorflow as tf
Now clone the repo.
!git clone https://github.com/ibatra/BERT-Keyword-Extractor
If you do ls, you should see BERT-Keyword-Extractor git directory.
We also need to install nltk punkt package.
import nltk
nltk.download('punkt')
Install following two libraries too.
!pip install pytorch_pretrained_bert
!pip install seqeval
Now we are ready to run the Bert code.
Lets first generate the model. Run following code.
cd BERT-Keyword-Extractor
!python main.py --data "maui-semeval2010-train" --lr 2e-5 --batch_size 32 --save "model.pt" --epochs 3
Once it is completed you should see model.pt in your current directory.
Test it using following command.
!python keyword-extractor.py --sentence "BERT is a great model" --path "model.pt"
Related Topics
Related Notebooks
- How To Run Logistic Regression In R
- How To Code RNN and LSTM Neural Networks in Python
- How To Take String Input From Command Line In Python
- How To Take Integer Input From Command Line In Python
- Five Ways To Remove Characters From A String In Python
- Learn And Code Confusion Matrix With Python
- How to Generate Embeddings from a Server and Index Them Using FAISS with API
- Return Multiple Values From a Function in Python
- How To Write DataFrame To CSV In R