-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert.py
30 lines (19 loc) · 933 Bytes
/
convert.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# The following is necessary if you want to use the fast tokenizer for deberta v2 or v3
import shutil
from pathlib import Path
transformers_path = Path("/home/workstaion/anaconda3/envs/shi/lib/python3.9/site-packages/transformers")
input_dir = Path("./deberta_v2_3_fast")
convert_file = input_dir / "convert_slow_tokenizer.py"
conversion_path = transformers_path/convert_file.name
if conversion_path.exists():
conversion_path.unlink()
shutil.copy(convert_file, transformers_path)
deberta_v2_path = transformers_path / "models" / "deberta_v2"
for filename in ['tokenization_deberta_v2.py', 'tokenization_deberta_v2_fast.py', "deberta__init__.py"]:
if str(filename).startswith("deberta"):
filepath = deberta_v2_path/str(filename).replace("deberta", "")
else:
filepath = deberta_v2_path/filename
if filepath.exists():
filepath.unlink()
shutil.copy(input_dir/filename, filepath)