Update README.md
Browse files
README.md
CHANGED
|
@@ -7,10 +7,7 @@ The following code load and test the models on colab notebook.
|
|
| 7 |
|
| 8 |
## Prerequisites
|
| 9 |
|
| 10 |
-
1.
|
| 11 |
-
```bash
|
| 12 |
-
pip install torch transformers pandas scikit-learn huggingface_hub
|
| 13 |
-
|
| 14 |
|
| 15 |
```python
|
| 16 |
from huggingface_hub import login
|
|
@@ -19,23 +16,22 @@ import torch.nn as nn
|
|
| 19 |
from transformers import RobertaForSequenceClassification, RobertaTokenizer
|
| 20 |
from torch.utils.data import Dataset, DataLoader
|
| 21 |
import pandas as pd
|
|
|
|
|
|
|
| 22 |
from sklearn.metrics import accuracy_score
|
| 23 |
-
from huggingface_hub import login
|
| 24 |
from transformers import AutoModel, AutoTokenizer
|
| 25 |
-
import pandas as pd
|
| 26 |
-
|
| 27 |
from huggingface_hub import login
|
| 28 |
-
|
|
|
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
import pandas as pd
|
| 34 |
-
import numpy as np
|
| 35 |
-
from sklearn.metrics import accuracy_score
|
| 36 |
-
import re
|
| 37 |
|
| 38 |
# Define the preprocessing and dataset class
|
|
|
|
|
|
|
|
|
|
| 39 |
class NewsDataset(Dataset):
|
| 40 |
def __init__(self, texts, labels, tokenizer, max_len=128):
|
| 41 |
self.texts = texts
|
|
|
|
| 7 |
|
| 8 |
## Prerequisites
|
| 9 |
|
| 10 |
+
1. Import the required Python packages:
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
```python
|
| 13 |
from huggingface_hub import login
|
|
|
|
| 16 |
from transformers import RobertaForSequenceClassification, RobertaTokenizer
|
| 17 |
from torch.utils.data import Dataset, DataLoader
|
| 18 |
import pandas as pd
|
| 19 |
+
import numpy as np
|
| 20 |
+
import re
|
| 21 |
from sklearn.metrics import accuracy_score
|
|
|
|
| 22 |
from transformers import AutoModel, AutoTokenizer
|
|
|
|
|
|
|
| 23 |
from huggingface_hub import login
|
| 24 |
+
```
|
| 25 |
+
2. Log in by using the account (see our Ed private post & email sent to TAs, thanks!):
|
| 26 |
|
| 27 |
+
```python
|
| 28 |
+
login("Replace with the key")
|
| 29 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
# Define the preprocessing and dataset class
|
| 32 |
+
|
| 33 |
+
1. Run the following preprocessing code
|
| 34 |
+
|
| 35 |
class NewsDataset(Dataset):
|
| 36 |
def __init__(self, texts, labels, tokenizer, max_len=128):
|
| 37 |
self.texts = texts
|