mandeep-rathee commited on
Commit
56e886c
·
verified ·
1 Parent(s): fdb50b1

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +7 -1
README.md CHANGED
@@ -4,6 +4,7 @@ base_model:
4
  - google-bert/bert-base-uncased
5
  ---
6
 
 
7
  You can load the laff model using the following steps:
8
 
9
  ```
@@ -11,6 +12,11 @@ import torch
11
  from transformers import BertTokenizer, BertForSequenceClassification
12
  from base_models import BinaryClassificationBertModel
13
 
 
 
 
 
 
14
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
15
 
16
  base_model_name = "bert-base-uncased"
@@ -18,6 +24,6 @@ tokenizer = BertTokenizer.from_pretrained(base_model_name, torch_dtype=torch.flo
18
  base_model = BertForSequenceClassification.from_pretrained(base_model_name, num_labels=1,torch_dtype=torch.float16)
19
 
20
  model = BinaryClassificationBertModel(base_model)
21
- model.load_state_dict(torch.load("laff_model/bert-base-laff.pth"))
22
  model.to(device)
23
  ```
 
4
  - google-bert/bert-base-uncased
5
  ---
6
 
7
+
8
  You can load the laff model using the following steps:
9
 
10
  ```
 
12
  from transformers import BertTokenizer, BertForSequenceClassification
13
  from base_models import BinaryClassificationBertModel
14
 
15
+ from huggingface_hub import hf_hub_download
16
+
17
+ file_path = hf_hub_download(repo_id="mandeep-rathee/laff-model", filename="bert-base-laff.pth")
18
+
19
+
20
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
21
 
22
  base_model_name = "bert-base-uncased"
 
24
  base_model = BertForSequenceClassification.from_pretrained(base_model_name, num_labels=1,torch_dtype=torch.float16)
25
 
26
  model = BinaryClassificationBertModel(base_model)
27
+ model.load_state_dict(torch.load(file_path, map_location=device))
28
  model.to(device)
29
  ```