mohsenfayyaz commited on
Commit
708d3e0
1 Parent(s): e654c3a

Delete DecompX/src/globenc_utils.py

Browse files
Files changed (1) hide show
  1. DecompX/src/globenc_utils.py +0 -49
DecompX/src/globenc_utils.py DELETED
@@ -1,49 +0,0 @@
1
- import torch
2
- from dataclasses import dataclass
3
- from typing import List, Optional, Tuple, Union
4
-
5
- @dataclass
6
- class GlobencConfig():
7
- include_biases: Optional[bool] = True
8
- bias_decomp_type: Optional[str] = "absdot" # "absdot": Based on the absolute value of dot products | "norm": Based on the norm of the attribution vectors | "equal": equal decomposition | "abssim": Based on the absolute value of cosine similarites | "cls": add to cls token
9
- include_bias_token: Optional[bool] = False # Adds an extra input token as a bias in the attribution vectors
10
- # If the bias_decomp_type is None and include_bias_token is True then the final token in the input tokens of the attr. vectors will be the summation of the biases
11
- # Otherwise the bias token will be decomposed with the specified decomp type
12
-
13
- include_LN1: Optional[bool] = True
14
-
15
- include_FFN: Optional[bool] = True
16
- FFN_approx_type: Optional[str] = "GeLU_ZO" # "GeLU_LA": GeLU-based linear approximation | "ReLU": Using ReLU as an approximation | "GeLU_ZO": Zero-origin slope approximation
17
- FFN_fast_mode: Optional[bool] = False
18
-
19
- include_LN2: Optional[bool] = True
20
-
21
- aggregation: Optional[str] = None # None: No aggregation | vector: Vector-based aggregation | rollout: Norm-based rollout aggregation
22
-
23
- include_classifier_w_pooler: Optional[bool] = True
24
- tanh_approx_type: Optional[str] = "ZO" # "ZO": Zero-origin slope approximation | "LA": Linear approximation
25
-
26
- output_all_layers: Optional[bool] = False # True: Output all layers | False: Output only last layer
27
- output_attention: Optional[str] = None # None | norm | vector | both
28
- output_res1: Optional[str] = None # None | norm | vector | both
29
- output_LN1: Optional[str] = None # None | norm | vector | both
30
- output_FFN: Optional[str] = None # None | norm | vector | both
31
- output_res2: Optional[str] = None # None | norm | vector | both
32
- output_encoder: Optional[str] = None # None | norm | vector | both
33
- output_aggregated: Optional[str] = None # None | norm | vector | both
34
- output_pooler: Optional[str] = None # None | norm | vector | both
35
-
36
- output_classifier: Optional[bool] = True
37
-
38
-
39
- @dataclass
40
- class GlobencOutput():
41
- attention: Optional[Union[Tuple[torch.Tensor, Tuple[torch.Tensor]], Tuple[torch.Tensor], torch.Tensor]] = None
42
- res1: Optional[Union[Tuple[torch.Tensor, Tuple[torch.Tensor]], Tuple[torch.Tensor], torch.Tensor]] = None
43
- LN1: Optional[Union[Tuple[torch.Tensor, Tuple[torch.Tensor]], Tuple[torch.Tensor], torch.Tensor]] = None
44
- FFN: Optional[Union[Tuple[torch.Tensor, Tuple[torch.Tensor]], Tuple[torch.Tensor], torch.Tensor]] = None
45
- res2: Optional[Union[Tuple[torch.Tensor, Tuple[torch.Tensor]], Tuple[torch.Tensor], torch.Tensor]] = None
46
- encoder: Optional[Union[Tuple[torch.Tensor, Tuple[torch.Tensor]], Tuple[torch.Tensor], torch.Tensor]] = None
47
- aggregated: Optional[Union[Tuple[torch.Tensor, Tuple[torch.Tensor]], Tuple[torch.Tensor], torch.Tensor]] = None
48
- pooler: Optional[Union[Tuple[torch.Tensor], torch.Tensor]] = None
49
- classifier: Optional[torch.Tensor] = None