Spaces:
Runtime error
Runtime error
Alexander Seifert
commited on
Commit
•
70689b0
1
Parent(s):
a9def1c
change counting for to_layer
Browse files- src/subpages/attention.py +15 -13
src/subpages/attention.py
CHANGED
@@ -96,7 +96,7 @@ class AttentionPage(Page):
|
|
96 |
"act_n_components": 8,
|
97 |
"act_default_text": """Now I ask you: what can be expected of man since he is a being endowed with strange qualities? Shower upon him every earthly blessing, drown him in a sea of happiness, so that nothing but bubbles of bliss can be seen on the surface; give him economic prosperity, such that he should have nothing else to do but sleep, eat cakes and busy himself with the continuation of his species, and even then out of sheer ingratitude, sheer spite, man would play you some nasty trick. He would even risk his cakes and would deliberately desire the most fatal rubbish, the most uneconomical absurdity, simply to introduce into all this positive good sense his fatal fantastic element. It is just his fantastic dreams, his vulgar folly that he will desire to retain, simply in order to prove to himself--as though that were so necessary-- that men still are men and not the keys of a piano, which the laws of nature threaten to control so completely that soon one will be able to desire nothing but by the calendar. And that is not all: even if man really were nothing but a piano-key, even if this were proved to him by natural science and mathematics, even then he would not become reasonable, but would purposely do something perverse out of simple ingratitude, simply to gain his point. And if he does not find means he will contrive destruction and chaos, will contrive sufferings of all sorts, only to gain his point! He will launch a curse upon the world, and as only man can curse (it is his privilege, the primary distinction between him and other animals), may be by his curse alone he will attain his object--that is, convince himself that he is a man and not a piano-key!""",
|
98 |
"act_from_layer": 0,
|
99 |
-
"act_to_layer":
|
100 |
}
|
101 |
|
102 |
def render(self, context: Context):
|
@@ -119,16 +119,13 @@ class AttentionPage(Page):
|
|
119 |
max_value=10,
|
120 |
step=1,
|
121 |
)
|
122 |
-
from_layer = (
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
step=1,
|
130 |
-
)
|
131 |
-
or None
|
132 |
)
|
133 |
to_layer = (
|
134 |
st.slider(
|
@@ -136,11 +133,16 @@ class AttentionPage(Page):
|
|
136 |
key="act_to_layer",
|
137 |
value=0,
|
138 |
min_value=0,
|
139 |
-
max_value=len(lm.model.transformer.layer),
|
140 |
step=1,
|
141 |
)
|
142 |
-
|
143 |
)
|
|
|
|
|
|
|
|
|
|
|
144 |
with col2:
|
145 |
st.subheader("–")
|
146 |
text = st.text_area("Text", key="act_default_text", height=240)
|
|
|
96 |
"act_n_components": 8,
|
97 |
"act_default_text": """Now I ask you: what can be expected of man since he is a being endowed with strange qualities? Shower upon him every earthly blessing, drown him in a sea of happiness, so that nothing but bubbles of bliss can be seen on the surface; give him economic prosperity, such that he should have nothing else to do but sleep, eat cakes and busy himself with the continuation of his species, and even then out of sheer ingratitude, sheer spite, man would play you some nasty trick. He would even risk his cakes and would deliberately desire the most fatal rubbish, the most uneconomical absurdity, simply to introduce into all this positive good sense his fatal fantastic element. It is just his fantastic dreams, his vulgar folly that he will desire to retain, simply in order to prove to himself--as though that were so necessary-- that men still are men and not the keys of a piano, which the laws of nature threaten to control so completely that soon one will be able to desire nothing but by the calendar. And that is not all: even if man really were nothing but a piano-key, even if this were proved to him by natural science and mathematics, even then he would not become reasonable, but would purposely do something perverse out of simple ingratitude, simply to gain his point. And if he does not find means he will contrive destruction and chaos, will contrive sufferings of all sorts, only to gain his point! He will launch a curse upon the world, and as only man can curse (it is his privilege, the primary distinction between him and other animals), may be by his curse alone he will attain his object--that is, convince himself that he is a man and not a piano-key!""",
|
98 |
"act_from_layer": 0,
|
99 |
+
"act_to_layer": 5,
|
100 |
}
|
101 |
|
102 |
def render(self, context: Context):
|
|
|
119 |
max_value=10,
|
120 |
step=1,
|
121 |
)
|
122 |
+
from_layer = st.slider(
|
123 |
+
"from layer",
|
124 |
+
key="act_from_layer",
|
125 |
+
value=0,
|
126 |
+
min_value=0,
|
127 |
+
max_value=len(lm.model.transformer.layer) - 1,
|
128 |
+
step=1,
|
|
|
|
|
|
|
129 |
)
|
130 |
to_layer = (
|
131 |
st.slider(
|
|
|
133 |
key="act_to_layer",
|
134 |
value=0,
|
135 |
min_value=0,
|
136 |
+
max_value=len(lm.model.transformer.layer) - 1,
|
137 |
step=1,
|
138 |
)
|
139 |
+
+ 1
|
140 |
)
|
141 |
+
|
142 |
+
if to_layer <= from_layer:
|
143 |
+
st.error("to_layer must be >= from_layer")
|
144 |
+
st.stop()
|
145 |
+
|
146 |
with col2:
|
147 |
st.subheader("–")
|
148 |
text = st.text_area("Text", key="act_default_text", height=240)
|