Update app.py
Browse files
app.py
CHANGED
@@ -207,21 +207,21 @@ elif selected_model == "Генерация текста GPT-моделью по
|
|
207 |
num_generations = st.slider('Количество генераций', 1, 10, 2, step=1)
|
208 |
|
209 |
if st.button('Сделать гороскоп'):
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
|
|
207 |
num_generations = st.slider('Количество генераций', 1, 10, 2, step=1)
|
208 |
|
209 |
if st.button('Сделать гороскоп'):
|
210 |
+
with st.spinner('Генерация текста...'):
|
211 |
+
start_time = time.time()
|
212 |
+
input_ids = tokenizer.encode(user_text_input, return_tensors="pt").to(device)
|
213 |
+
model.eval()
|
214 |
+
with torch.no_grad():
|
215 |
+
out = model.generate(
|
216 |
+
input_ids,
|
217 |
+
do_sample=True,
|
218 |
+
num_beams=num_generations,
|
219 |
+
temperature=temperature,
|
220 |
+
top_p=0.9,
|
221 |
+
max_length=max_gen_length,
|
222 |
+
)
|
223 |
+
generated_text = tokenizer.decode(out[0], skip_special_tokens=True)
|
224 |
+
end_time = time.time()
|
225 |
+
prediction_time = end_time - start_time
|
226 |
+
|
227 |
+
st.write(f'{generated_text}')
|