GradientGuru xu song commited on
Commit
e837cb3
1 Parent(s): 350e3a4

Fix BaichuanTokenizer to fit transformers>=4.34 (#8)

Browse files

- Fix BaichuanTokenizer to fit transformers>=4.34 (75e249af814cd81849dbf0e393b87f2b07b86907)


Co-authored-by: xu song <[email protected]>

Files changed (1) hide show
  1. tokenization_baichuan.py +5 -5
tokenization_baichuan.py CHANGED
@@ -72,6 +72,11 @@ class BaichuanTokenizer(PreTrainedTokenizer):
72
  eos_token = AddedToken(eos_token, lstrip=False, rstrip=False) if isinstance(eos_token, str) else eos_token
73
  unk_token = AddedToken(unk_token, lstrip=False, rstrip=False) if isinstance(unk_token, str) else unk_token
74
  pad_token = AddedToken(pad_token, lstrip=False, rstrip=False) if isinstance(pad_token, str) else pad_token
 
 
 
 
 
75
  super().__init__(
76
  bos_token=bos_token,
77
  eos_token=eos_token,
@@ -83,11 +88,6 @@ class BaichuanTokenizer(PreTrainedTokenizer):
83
  clean_up_tokenization_spaces=clean_up_tokenization_spaces,
84
  **kwargs,
85
  )
86
- self.vocab_file = vocab_file
87
- self.add_bos_token = add_bos_token
88
- self.add_eos_token = add_eos_token
89
- self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
90
- self.sp_model.Load(vocab_file)
91
 
92
  def __getstate__(self):
93
  state = self.__dict__.copy()
 
72
  eos_token = AddedToken(eos_token, lstrip=False, rstrip=False) if isinstance(eos_token, str) else eos_token
73
  unk_token = AddedToken(unk_token, lstrip=False, rstrip=False) if isinstance(unk_token, str) else unk_token
74
  pad_token = AddedToken(pad_token, lstrip=False, rstrip=False) if isinstance(pad_token, str) else pad_token
75
+ self.vocab_file = vocab_file
76
+ self.add_bos_token = add_bos_token
77
+ self.add_eos_token = add_eos_token
78
+ self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
79
+ self.sp_model.Load(vocab_file)
80
  super().__init__(
81
  bos_token=bos_token,
82
  eos_token=eos_token,
 
88
  clean_up_tokenization_spaces=clean_up_tokenization_spaces,
89
  **kwargs,
90
  )
 
 
 
 
 
91
 
92
  def __getstate__(self):
93
  state = self.__dict__.copy()