File size: 3,862 Bytes
daeb223
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
from dataclasses import dataclass, field
from .. import models


@dataclass
class RetroDataModelArguments:
    pass


@dataclass
class DataArguments(RetroDataModelArguments):
    max_seq_length: int = field(
        default=512,
        metadata={"help": ""},
    )
    max_answer_length: int = field(
        default=30,
        metadata={"help": ""},
    )
    doc_stride: int = field(
        default=128,
        metadata={"help": ""},
    )
    return_token_type_ids: bool = field(
        default=True,
        metadata={"help": ""},
    )
    pad_to_max_length: bool = field(
        default=True,
        metadata={"help": ""},
    )
    preprocessing_num_workers: int = field(
        default=5,
        metadata={"help": ""},
    )
    overwrite_cache: bool = field(
        default=False,
        metadata={"help": ""},
    )
    version_2_with_negative: bool = field(
        default=True,
        metadata={"help": ""},
    )
    null_score_diff_threshold: float = field(
        default=0.0,
        metadata={"help": ""},
    )
    rear_threshold: float = field(
        default=0.0,
        metadata={"help": ""},
    )
    n_best_size: int = field(
        default=20,
        metadata={"help": ""},
    )
    use_choice_logits: bool = field(
        default=False,
        metadata={"help": ""},
    )
    start_n_top: int = field(
        default=-1,
        metadata={"help": ""},
    )
    end_n_top: int = field(
        default=-1,
        metadata={"help": ""},
    )
    beta1: int = field(
        default=1,
        metadata={"help": ""},
    )
    beta2: int = field(
        default=1,
        metadata={"help": ""},
    )
    best_cof: int = field(
        default=1,
        metadata={"help": ""},
    )
    
    
@dataclass
class ModelArguments(RetroDataModelArguments):
    use_auth_token: bool = field(
        default=False,
        metadata={"help": ""},
    )
        
        
@dataclass
class SketchModelArguments(ModelArguments):
    sketch_revision: str = field(
        default="main",
        metadata={"help": ""},
    )
    sketch_model_name: str = field(
        default="monologg/koelectra-small-v3-discriminator",
        metadata={"help": ""},
    )
    sketch_tokenizer_name: str = field(
        default=None,
        metadata={"help": ""},
    )
    sketch_architectures: str = field(
        default="ElectraForSequenceClassification",
        metadata={"help": ""},
    )
            
            
@dataclass
class IntensiveModelArguments(ModelArguments):
    intensive_revision: str = field(
        default="main",
        metadata={"help": ""},
    )
    intensive_model_name: str = field(
        default="monologg/koelectra-small-v3-discriminator",
        metadata={"help": ""},
    )
    intensive_tokenizer_name: str = field(
        default=None,
        metadata={"help": ""},
    )
    intensive_architectures: str = field(
        default="ElectraForQuestionAnsweringAVPool",
        metadata={"help": ""},
    )
    
    
@dataclass
class RetroArguments(
    DataArguments, 
    SketchModelArguments, 
    IntensiveModelArguments,
):
    def __post_init__(self):
        # Sketch
        model_cls = getattr(models, self.sketch_architectures, None)
        if model_cls is None:
            raise AttributeError
        self.sketch_model_cls = model_cls
        self.sketch_model_type = model_cls.model_type
        if self.sketch_tokenizer_name is None:
            self.sketch_tokenizer_name = self.sketch_model_name
        # Intensive
        model_cls = getattr(models, self.intensive_architectures, None)
        if model_cls is None:
            raise AttributeError
        self.intensive_model_cls = model_cls
        self.intensive_model_type = model_cls.model_type
        if self.intensive_tokenizer_name is None:
            self.intensive_tokenizer_name = self.intensive_model_name