Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +69 -8
src/streamlit_app.py
CHANGED
|
@@ -61,14 +61,60 @@ with left_col:
|
|
| 61 |
st.subheader("Stability Test Settings")
|
| 62 |
stability_test = st.checkbox("Enable stability testing", value=False)
|
| 63 |
|
|
|
|
| 64 |
stability_iterations = {}
|
|
|
|
|
|
|
| 65 |
if stability_test:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
st.write("Set stability iterations for selected LLMs:")
|
| 67 |
for llm in selected_llms:
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
if stability_enabled:
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
with right_col:
|
| 74 |
# Calculate costs
|
|
@@ -82,10 +128,22 @@ with right_col:
|
|
| 82 |
for llm in selected_llms:
|
| 83 |
base_runs = run_counts[llm]
|
| 84 |
stability_runs = stability_iterations.get(llm, 0)
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
-
total_input_tokens =
|
| 88 |
-
total_output_tokens =
|
| 89 |
|
| 90 |
input_cost = (total_input_tokens / 1_000_000) * llm_data[llm]["input_cost_per_m"]
|
| 91 |
output_cost = (total_output_tokens / 1_000_000) * llm_data[llm]["output_cost_per_m"]
|
|
@@ -95,9 +153,12 @@ with right_col:
|
|
| 95 |
"Model": llm,
|
| 96 |
"Base Runs": base_runs,
|
| 97 |
"Stability Test Iterations": stability_iterations.get(llm, 0),
|
|
|
|
|
|
|
|
|
|
| 98 |
"Total Runs": total_runs,
|
| 99 |
-
"Total Input Tokens": total_input_tokens,
|
| 100 |
-
"Total Output Tokens": total_output_tokens,
|
| 101 |
"Input Cost ($)": input_cost,
|
| 102 |
"Output Cost ($)": output_cost,
|
| 103 |
"Total Cost ($)": total_cost
|
|
|
|
| 61 |
st.subheader("Stability Test Settings")
|
| 62 |
stability_test = st.checkbox("Enable stability testing", value=False)
|
| 63 |
|
| 64 |
+
# Global settings for stability testing
|
| 65 |
stability_iterations = {}
|
| 66 |
+
stability_data_percentages = {}
|
| 67 |
+
|
| 68 |
if stability_test:
|
| 69 |
+
st.write("Global Stability Settings:")
|
| 70 |
+
use_subset = st.checkbox("Test stability on a subset of data", value=False)
|
| 71 |
+
|
| 72 |
+
if use_subset:
|
| 73 |
+
default_percent = st.slider(
|
| 74 |
+
"Default data percentage for stability tests",
|
| 75 |
+
min_value=10,
|
| 76 |
+
max_value=100,
|
| 77 |
+
value=50,
|
| 78 |
+
step=5,
|
| 79 |
+
help="Percentage of the input data to use for stability testing"
|
| 80 |
+
)
|
| 81 |
+
|
| 82 |
st.write("Set stability iterations for selected LLMs:")
|
| 83 |
for llm in selected_llms:
|
| 84 |
+
st.markdown(f"**{llm} Stability Settings**")
|
| 85 |
+
col1, col2 = st.columns(2)
|
| 86 |
+
|
| 87 |
+
with col1:
|
| 88 |
+
stability_enabled = st.checkbox(f"Test stability", value=False, key=f"stability_{llm}")
|
| 89 |
+
|
| 90 |
if stability_enabled:
|
| 91 |
+
with col1:
|
| 92 |
+
iterations = st.number_input(
|
| 93 |
+
f"Iterations",
|
| 94 |
+
min_value=2,
|
| 95 |
+
value=10,
|
| 96 |
+
step=1,
|
| 97 |
+
key=f"iterations_{llm}"
|
| 98 |
+
)
|
| 99 |
+
stability_iterations[llm] = iterations
|
| 100 |
+
|
| 101 |
+
with col2:
|
| 102 |
+
if use_subset:
|
| 103 |
+
custom_percent = st.number_input(
|
| 104 |
+
f"Data %",
|
| 105 |
+
min_value=5,
|
| 106 |
+
max_value=100,
|
| 107 |
+
value=default_percent,
|
| 108 |
+
step=5,
|
| 109 |
+
key=f"percent_{llm}",
|
| 110 |
+
help="Percentage of the input data to use"
|
| 111 |
+
)
|
| 112 |
+
stability_data_percentages[llm] = custom_percent / 100.0
|
| 113 |
+
else:
|
| 114 |
+
stability_data_percentages[llm] = 1.0
|
| 115 |
+
|
| 116 |
+
if llm != selected_llms[-1]:
|
| 117 |
+
st.markdown("---")
|
| 118 |
|
| 119 |
with right_col:
|
| 120 |
# Calculate costs
|
|
|
|
| 128 |
for llm in selected_llms:
|
| 129 |
base_runs = run_counts[llm]
|
| 130 |
stability_runs = stability_iterations.get(llm, 0)
|
| 131 |
+
data_percentage = stability_data_percentages.get(llm, 1.0)
|
| 132 |
+
|
| 133 |
+
# Calculate total runs
|
| 134 |
+
if stability_runs == 0:
|
| 135 |
+
total_runs = base_runs
|
| 136 |
+
effective_data_percentage = 1.0 # No stability testing, use full data
|
| 137 |
+
else:
|
| 138 |
+
total_runs = base_runs * stability_runs
|
| 139 |
+
effective_data_percentage = data_percentage # Use configured percentage for stability testing
|
| 140 |
+
|
| 141 |
+
# Calculate tokens based on data percentage
|
| 142 |
+
effective_input_tokens = input_tokens * effective_data_percentage
|
| 143 |
+
effective_output_tokens = output_tokens * effective_data_percentage
|
| 144 |
|
| 145 |
+
total_input_tokens = effective_input_tokens * total_runs
|
| 146 |
+
total_output_tokens = effective_output_tokens * total_runs
|
| 147 |
|
| 148 |
input_cost = (total_input_tokens / 1_000_000) * llm_data[llm]["input_cost_per_m"]
|
| 149 |
output_cost = (total_output_tokens / 1_000_000) * llm_data[llm]["output_cost_per_m"]
|
|
|
|
| 153 |
"Model": llm,
|
| 154 |
"Base Runs": base_runs,
|
| 155 |
"Stability Test Iterations": stability_iterations.get(llm, 0),
|
| 156 |
+
"Data Percentage": f"{data_percentage * 100:.0f}%" if stability_runs > 0 else "100%",
|
| 157 |
+
"Effective Input Tokens": int(effective_input_tokens),
|
| 158 |
+
"Effective Output Tokens": int(effective_output_tokens),
|
| 159 |
"Total Runs": total_runs,
|
| 160 |
+
"Total Input Tokens": int(total_input_tokens),
|
| 161 |
+
"Total Output Tokens": int(total_output_tokens),
|
| 162 |
"Input Cost ($)": input_cost,
|
| 163 |
"Output Cost ($)": output_cost,
|
| 164 |
"Total Cost ($)": total_cost
|