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 Generate Random Numbers in Python
- How to Analyze the CSV data in Pandas
- How to Visualize Data Using Python - Matplotlib
- How to Plot a Histogram in Python
- 3 Ways to Rename Columns in Pandas DataFrame
- How To Drop One Or More Columns In Pandas Dataframe
- How To Handle nan In Numpy
- How to Export Pandas DataFrame to a CSV File
- How To Read CSV File Using Python PySpark