Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model:
|
| 4 |
+
- google-bert/bert-base-uncased
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
You can load the laff model using the following steps:
|
| 8 |
+
|
| 9 |
+
```
|
| 10 |
+
from transformers import BertTokenizer, BertForSequenceClassification
|
| 11 |
+
from base_models import BinaryClassificationBertModel
|
| 12 |
+
|
| 13 |
+
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 14 |
+
|
| 15 |
+
base_model_name = "bert-base-uncased"
|
| 16 |
+
tokenizer = BertTokenizer.from_pretrained(base_model_name, torch_dtype=torch.float16)
|
| 17 |
+
base_model = BertForSequenceClassification.from_pretrained(base_model_name, num_labels=1,torch_dtype=torch.float16)
|
| 18 |
+
|
| 19 |
+
model = BinaryClassificationBertModel(base_model)
|
| 20 |
+
model.load_state_dict(torch.load("laff_model/bert-base-laff.pth"))
|
| 21 |
+
model.to(device)
|
| 22 |
+
```
|