-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Lines 10 to 25 in 05e2ffb
| import config as CFG | |
| class Scorer(nn.Module): | |
| def __init__(self): | |
| super(Scorer, self).__init__() | |
| self.tokenizer = BertTokenizer.from_pretrained(CFG.BERT_MODEL) | |
| self.model = BertModel.from_pretrained(CFG.BERT_MODEL) | |
| self.fc = nn.Linear(self.model.config.hidden_size, 1) | |
| def forward(self, article, summary): | |
| inputs = self.tokenizer(article, summary, padding='longest', truncation="longest_first" , return_tensors='pt').to(CFG.DEVICE) | |
| outputs = self.model(**inputs) | |
| x = self.fc(outputs.pooler_output) | |
| return x | |
| class Siamese(nn.Module): |
Text pieces or pairs are tokenized individually and move to GPU. This is very slow.
At least we should tokenize them after a batch is loaded.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels