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.
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"
- How To Run Logistic Regression In R
- How to Generate Random Numbers in Python
- How to Create DataFrame in R Using Examples
- How To Solve Linear Equations Using Sympy In Python
- How to Plot a Histogram in Python
- How To Iterate Over Rows In A Dataframe In Pandas
- How To Write DataFrame To CSV In R
- How To Plot Histogram In R
- Learn And Code Confusion Matrix With Python