x-transformers 2.2.4__py3-none-any.whl → 2.2.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- x_transformers/entropy_based_tokenizer.py +8 -6
- {x_transformers-2.2.4.dist-info → x_transformers-2.2.5.dist-info}/METADATA +1 -1
- {x_transformers-2.2.4.dist-info → x_transformers-2.2.5.dist-info}/RECORD +5 -5
- {x_transformers-2.2.4.dist-info → x_transformers-2.2.5.dist-info}/WHEEL +0 -0
- {x_transformers-2.2.4.dist-info → x_transformers-2.2.5.dist-info}/licenses/LICENSE +0 -0
@@ -6,7 +6,11 @@ import torch.nn.functional as F
|
|
6
6
|
from torch.nn import Module
|
7
7
|
from torch.nn.utils.rnn import pad_sequence
|
8
8
|
|
9
|
-
from x_transformers.x_transformers import
|
9
|
+
from x_transformers.x_transformers import (
|
10
|
+
Decoder,
|
11
|
+
TransformerWrapper,
|
12
|
+
calc_entropy
|
13
|
+
)
|
10
14
|
|
11
15
|
import einx
|
12
16
|
from einops import repeat, rearrange, pack, unpack
|
@@ -27,12 +31,10 @@ def default(v, d):
|
|
27
31
|
class EntropyBasedTokenizer(Module):
|
28
32
|
def __init__(
|
29
33
|
self,
|
30
|
-
decoder:
|
34
|
+
decoder: Module,
|
31
35
|
entropy_threshold: float
|
32
36
|
):
|
33
37
|
super().__init__()
|
34
|
-
assert isinstance(decoder.attn_layers, Decoder)
|
35
|
-
|
36
38
|
self.decoder = decoder
|
37
39
|
self.entropy_threshold = entropy_threshold
|
38
40
|
|
@@ -55,9 +57,9 @@ class EntropyBasedTokenizer(Module):
|
|
55
57
|
|
56
58
|
# forward through a small trained decoder and get the entropies of the logits
|
57
59
|
|
58
|
-
|
60
|
+
logits = self.decoder(seq)
|
59
61
|
|
60
|
-
entropies =
|
62
|
+
entropies = calc_entropy(logits)
|
61
63
|
|
62
64
|
# get length mask for boundaries
|
63
65
|
|
@@ -4,14 +4,14 @@ x_transformers/autoregressive_wrapper.py,sha256=reLCno9Z9pchVU79tBF8OMo21LwSZ67K
|
|
4
4
|
x_transformers/belief_state_wrapper.py,sha256=YLUMk6t2MhFBEw5lHDDHJHcoCxTIkHvxTNY__GGZEKU,13374
|
5
5
|
x_transformers/continuous.py,sha256=p0sCAiH1na236ygwgL1Yyhu36eZBf9cZvoW1JyP_fFE,7073
|
6
6
|
x_transformers/dpo.py,sha256=xt4OuOWhU8pN3OKN2LZAaC2NC8iiEnchqqcrPWVqf0o,3521
|
7
|
-
x_transformers/entropy_based_tokenizer.py,sha256=
|
7
|
+
x_transformers/entropy_based_tokenizer.py,sha256=Dr7Hvb0WbdhCeD3_61jAQeONr6IWFFSCRrqBfn0d46Y,3772
|
8
8
|
x_transformers/multi_input.py,sha256=tCh-fTJDj2ib4SMGtsa-AM8MxKzJAQSwqAXOu3HU2mg,9252
|
9
9
|
x_transformers/neo_mlp.py,sha256=XCNnnop9WLarcxap1kGuYc1x8GHvwkZiDRnXOxSl3Po,3452
|
10
10
|
x_transformers/nonautoregressive_wrapper.py,sha256=2NU58hYMgn-4Jzg3mie-mXb0XH_dCN7fjlzd3K1rLUY,10510
|
11
11
|
x_transformers/x_transformers.py,sha256=Fl2CuAKTxJDOQvqwQo2FK8eO2s1iNLO-P1PP2Yw64rQ,111826
|
12
12
|
x_transformers/xl_autoregressive_wrapper.py,sha256=CvZMJ6A6PA-Y_bQAhnORwjJBSl6Vjq2IdW5KTdk8NI8,4195
|
13
13
|
x_transformers/xval.py,sha256=7S00kCuab4tWQa-vf-z-XfzADjVj48MoFIr7VSIvttg,8575
|
14
|
-
x_transformers-2.2.
|
15
|
-
x_transformers-2.2.
|
16
|
-
x_transformers-2.2.
|
17
|
-
x_transformers-2.2.
|
14
|
+
x_transformers-2.2.5.dist-info/METADATA,sha256=5hJR7TPpRznsPZrYAHsbk3Eq9E9XKrAuwybmc3r6B1s,88686
|
15
|
+
x_transformers-2.2.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
16
|
+
x_transformers-2.2.5.dist-info/licenses/LICENSE,sha256=As9u198X-U-vph5noInuUfqsAG2zX_oXPHDmdjwlPPY,1066
|
17
|
+
x_transformers-2.2.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|