yonikremer commited on
Commit
3a9aacf
1 Parent(s): e63724c

Added timing

Browse files
Files changed (1) hide show
  1. hanlde_form_submit.py +12 -0
hanlde_form_submit.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import streamlit as st
2
  from grouped_sampling import GroupedSamplingPipeLine
3
 
@@ -74,15 +76,25 @@ def on_form_submit(model_name: str, output_length: int, prompt: str) -> str:
74
  raise ValueError(f"The prompt must be a string.")
75
  if not isinstance(output_length, int):
76
  raise ValueError(f"The output length must be an integer.")
 
 
77
  pipeline = create_pipeline(
78
  model_name=model_name,
79
  group_size=output_length,
80
  )
 
 
 
 
 
81
  generated_text = generate_text(
82
  pipeline=pipeline,
83
  prompt=prompt,
84
  output_length=output_length,
85
  )
 
 
 
86
  if not isinstance(generated_text, str):
87
  raise RuntimeError(f"The model {model_name} did not generate any text.")
88
  if len(generated_text) == 0:
 
1
+ from time import time
2
+
3
  import streamlit as st
4
  from grouped_sampling import GroupedSamplingPipeLine
5
 
 
76
  raise ValueError(f"The prompt must be a string.")
77
  if not isinstance(output_length, int):
78
  raise ValueError(f"The output length must be an integer.")
79
+ st.write(f"Loading model: {model_name}...")
80
+ loading_start_time = time()
81
  pipeline = create_pipeline(
82
  model_name=model_name,
83
  group_size=output_length,
84
  )
85
+ loading_end_time = time()
86
+ loading_time = loading_end_time - loading_start_time
87
+ st.write(f"Finished loading model: {model_name} in {loading_time} seconds.")
88
+ st.write(f"Generating text...")
89
+ generation_start_time = time()
90
  generated_text = generate_text(
91
  pipeline=pipeline,
92
  prompt=prompt,
93
  output_length=output_length,
94
  )
95
+ generation_end_time = time()
96
+ generation_time = generation_end_time - generation_start_time
97
+ st.write(f"Finished generating text in {generation_time} seconds.")
98
  if not isinstance(generated_text, str):
99
  raise RuntimeError(f"The model {model_name} did not generate any text.")
100
  if len(generated_text) == 0: