-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
41 lines (34 loc) · 947 Bytes
/
main.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
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
# -*- coding:utf-8 -*-
__author__ = 'Shining'
__email__ = 'mrshininnnnn@gmail.com'
# dependency
# built-in
import os
# public
import torch
from lightning import seed_everything
# private
from config import Config
from src.trainer import LitTrainer
class PI2NLI(object):
"""docstring for PI2NLI"""
def __init__(self):
super(PI2NLI, self).__init__()
self.config = Config()
self.initialize()
def initialize(self):
# get trainer
self.trainer = LitTrainer(self.config)
# setup random seed
seed_everything(self.config.seed, workers=True)
# enable tokenizer multi-processing
if self.config.num_workers > 0:
os.environ['TOKENIZERS_PARALLELISM'] = 'true'
# others
torch.set_float32_matmul_precision('high')
def main() -> None:
pi2nli = PI2NLI()
pi2nli.trainer.train()
if __name__ == '__main__':
main()