Spaces:
Running
Running
Include EOS token
Browse files
app.py
CHANGED
@@ -86,18 +86,21 @@ dependencies.
|
|
86 |
|
87 |
text = st.text_area("Input text", DEFAULT_TEXT)
|
88 |
|
|
|
|
|
89 |
inputs = tokenizer([text])
|
90 |
[input_ids] = inputs["input_ids"]
|
|
|
91 |
|
92 |
-
if
|
93 |
-
st.caption(f":red[{
|
94 |
else:
|
95 |
-
st.caption(f"{
|
96 |
|
97 |
-
if
|
98 |
-
st.error("Please enter at least
|
99 |
st.stop()
|
100 |
-
if
|
101 |
st.error(
|
102 |
f"Please enter at most {max_tokens} tokens or try reducing the window size.",
|
103 |
icon="🚨"
|
|
|
86 |
|
87 |
text = st.text_area("Input text", DEFAULT_TEXT)
|
88 |
|
89 |
+
if tokenizer.eos_token:
|
90 |
+
text += tokenizer.eos_token
|
91 |
inputs = tokenizer([text])
|
92 |
[input_ids] = inputs["input_ids"]
|
93 |
+
num_user_tokens = len(input_ids) - (1 if tokenizer.eos_token else 0)
|
94 |
|
95 |
+
if num_user_tokens < 1 or num_user_tokens > max_tokens:
|
96 |
+
st.caption(f":red[{num_user_tokens}]/{max_tokens} tokens")
|
97 |
else:
|
98 |
+
st.caption(f"{num_user_tokens}/{max_tokens} tokens")
|
99 |
|
100 |
+
if num_user_tokens < 1:
|
101 |
+
st.error("Please enter at least one token.", icon="🚨")
|
102 |
st.stop()
|
103 |
+
if num_user_tokens > max_tokens:
|
104 |
st.error(
|
105 |
f"Please enter at most {max_tokens} tokens or try reducing the window size.",
|
106 |
icon="🚨"
|