JuanJoseMV commited on
Commit
f397f4b
1 Parent(s): 8e7d1f2

Adding special tokens

Browse files
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -19,6 +19,7 @@ finetunned_BERT = BertTextGenerator(finetunned_BERT_model_name, tokenizer='bert-
19
  finetunned_RoBERTa_model_name = "JuanJoseMV/XLM_RoBERTa_text_gen"
20
  finetunned_RoBERTa = BertTextGenerator(finetunned_RoBERTa_model_name, tokenizer=finetunned_RoBERTa_model_name)
21
 
 
22
  special_tokens = [
23
  '[POSITIVE-0]',
24
  '[POSITIVE-1]',
@@ -28,6 +29,12 @@ special_tokens = [
28
  '[NEGATIVE-2]'
29
  ]
30
 
 
 
 
 
 
 
31
  finetunned_BERT.tokenizer.add_special_tokens({'additional_special_tokens': special_tokens})
32
  finetunned_BERT.model.resize_token_embeddings(len(finetunned_BERT.tokenizer))
33
 
 
19
  finetunned_RoBERTa_model_name = "JuanJoseMV/XLM_RoBERTa_text_gen"
20
  finetunned_RoBERTa = BertTextGenerator(finetunned_RoBERTa_model_name, tokenizer=finetunned_RoBERTa_model_name)
21
 
22
+ ## Add special tokens
23
  special_tokens = [
24
  '[POSITIVE-0]',
25
  '[POSITIVE-1]',
 
29
  '[NEGATIVE-2]'
30
  ]
31
 
32
+ BERT.tokenizer.add_special_tokens({'additional_special_tokens': special_tokens})
33
+ BERT.model.resize_token_embeddings(len(BERT.tokenizer))
34
+
35
+ RoBERTa.tokenizer.add_special_tokens({'additional_special_tokens': special_tokens})
36
+ RoBERTa.model.resize_token_embeddings(len(RoBERTa.tokenizer))
37
+
38
  finetunned_BERT.tokenizer.add_special_tokens({'additional_special_tokens': special_tokens})
39
  finetunned_BERT.model.resize_token_embeddings(len(finetunned_BERT.tokenizer))
40