Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -123,7 +123,18 @@ sentences = ["In a quaint little town nestled in the heart of the mountains, a s
|
|
123 |
|
124 |
"In a cozy, mountain-encircled village, a beloved bakery was the center of attraction, known for its traditional baking methods and delightful pastries, drawing a consistent stream of people waiting outside, all desiring to experience the renowned flavors that made the bakery's products distinctively mouth-watering."]
|
125 |
|
|
|
126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
text_list = []
|
128 |
|
129 |
def updateChoices(prompt):
|
@@ -161,10 +172,11 @@ def setTextVisibility(cbg, model_name_input):
|
|
161 |
result.append("<p><strong>"+ cbg[idx] +"</strong></p><p>"+ sentence +"</p><br/>")
|
162 |
|
163 |
return result
|
|
|
164 |
|
165 |
-
|
166 |
-
|
167 |
-
return
|
168 |
|
169 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
170 |
|
@@ -175,21 +187,10 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
175 |
</h1>
|
176 |
<hr style="margin-bottom:5px; margin-top:5px;">
|
177 |
|
|
|
178 |
</div>
|
179 |
""")
|
180 |
with gr.Tab("Live Mode"):
|
181 |
-
gr.HTML("""
|
182 |
-
<div>
|
183 |
-
<h4> Live Mode Auditing LLMs <h4>
|
184 |
-
<div>
|
185 |
-
<div style = "font-size: 13px;">
|
186 |
-
<p><In Live Auditing Mode, you gain the ability to probe the LLM directly./p>
|
187 |
-
|
188 |
-
<p>First, select the LLM you wish to audit. Then, enter your question. The AuditLLM tool will generate five relevant and diverse prompts based on your question. You can now select these prompts for auditing the LLMs. Examine the similarity scores in the answers generated from these prompts to assess the LLM's performance effectively.</p>
|
189 |
-
|
190 |
-
</div>
|
191 |
-
""")
|
192 |
-
|
193 |
with gr.Row():
|
194 |
model_name_input = gr.Dropdown([("Llama", "TheBloke/Llama-2-7B-Chat-GGML"), ("Falcon", "TheBloke/Falcon-180B-GGUF"), ("Zephyr", "TheBloke/zephyr-quiklang-3b-4K-GGUF"),("Vicuna", "TheBloke/vicuna-33B-GGUF"),("Claude","TheBloke/claude2-alpaca-13B-GGUF"),("Alpaca","TheBloke/LeoScorpius-GreenNode-Alpaca-7B-v1-GGUF")], label="Large Language Model")
|
195 |
with gr.Row():
|
@@ -216,38 +217,25 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
216 |
#btnExec.click(setTextVisibility, inputs=[cbg, model_name_input], outputs=text_list)
|
217 |
btnExec.click(setTextVisibility, inputs=[cbg, model_name_input], outputs=html_result)
|
218 |
gr.HTML("""
|
219 |
-
<div style="text-align: center; font-size: 24px; font-weight: bold;">Similarity Score
|
220 |
""")
|
221 |
|
222 |
-
clear = gr.ClearButton(link = "http://127.0.0.1:
|
223 |
|
224 |
with gr.Tab("Batch Mode"):
|
225 |
-
gr.HTML("""
|
226 |
-
<div>
|
227 |
-
<h4> Batch Mode Auditing LLMs <h4>
|
228 |
-
<div>
|
229 |
-
<div style = "font-size: 13px;">
|
230 |
-
<p>In batch auditing mode, you have the capability to probe the LLM. To begin, you must first select the LLM you wish to audit and then input the questions you intend to explore. For each question submitted, the model will generate five prompts, each accompanied by its respective answers.</p>
|
231 |
-
|
232 |
-
<p>To tailor the generation of these five prompts from your original question, you can adjust the relevance and diversity scores. The relevance score determines how closely the generated prompts should align with the original question, while the diversity score dictates the variance among the prompts themselves.</p>
|
233 |
-
|
234 |
-
<p>Upon completion, please provide your email address. We will compile and send the answers to you promptly.</p>
|
235 |
-
</div>
|
236 |
-
""")
|
237 |
-
|
238 |
-
with gr.Row():
|
239 |
-
model_name_input2 = gr.Dropdown([("Llama", "TheBloke/Llama-2-7B-Chat-GGML"), ("Falcon", "TheBloke/Falcon-180B-GGUF"), ("Zephyr", "TheBloke/zephyr-quiklang-3b-4K-GGUF"),("Vicuna", "TheBloke/vicuna-33B-GGUF"),("Claude","TheBloke/claude2-alpaca-13B-GGUF"),("Alpaca","TheBloke/LeoScorpius-GreenNode-Alpaca-7B-v1-GGUF")], label="Large Language Model")
|
240 |
with gr.Row():
|
241 |
-
|
242 |
with gr.Row():
|
243 |
-
|
244 |
with gr.Row():
|
245 |
-
|
246 |
-
|
|
|
247 |
with gr.Row():
|
248 |
-
|
249 |
with gr.Row():
|
250 |
-
|
251 |
|
|
|
252 |
# Launch the Gradio app
|
253 |
-
demo.launch(
|
|
|
123 |
|
124 |
"In a cozy, mountain-encircled village, a beloved bakery was the center of attraction, known for its traditional baking methods and delightful pastries, drawing a consistent stream of people waiting outside, all desiring to experience the renowned flavors that made the bakery's products distinctively mouth-watering."]
|
125 |
|
126 |
+
sentence_clusters = cluster_sentences(sentences, model, num_clusters)
|
127 |
|
128 |
+
# Step 2: Highlight similar words within each cluster
|
129 |
+
clustered_sentences = [[] for _ in range(num_clusters)]
|
130 |
+
for sentence, cluster_id in zip(sentences, sentence_clusters):
|
131 |
+
clustered_sentences[cluster_id].append(sentence)
|
132 |
+
|
133 |
+
highlighted_clustered_sentences = []
|
134 |
+
for cluster in clustered_sentences:
|
135 |
+
highlighted_clustered_sentences.extend(highlight_words_within_cluster(cluster, model, exclude_words))
|
136 |
+
|
137 |
+
|
138 |
text_list = []
|
139 |
|
140 |
def updateChoices(prompt):
|
|
|
172 |
result.append("<p><strong>"+ cbg[idx] +"</strong></p><p>"+ sentence +"</p><br/>")
|
173 |
|
174 |
return result
|
175 |
+
|
176 |
|
177 |
+
# update_show = [gr.Textbox(visible=True, label=text, value=answer_question(text, model_name_input)) for text in cbg]
|
178 |
+
# update_hide = [gr.Textbox(visible=False, label="") for _ in range(10-len(cbg))]
|
179 |
+
# return update_show + update_hide
|
180 |
|
181 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
182 |
|
|
|
187 |
</h1>
|
188 |
<hr style="margin-bottom:5px; margin-top:5px;">
|
189 |
|
190 |
+
|
191 |
</div>
|
192 |
""")
|
193 |
with gr.Tab("Live Mode"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
with gr.Row():
|
195 |
model_name_input = gr.Dropdown([("Llama", "TheBloke/Llama-2-7B-Chat-GGML"), ("Falcon", "TheBloke/Falcon-180B-GGUF"), ("Zephyr", "TheBloke/zephyr-quiklang-3b-4K-GGUF"),("Vicuna", "TheBloke/vicuna-33B-GGUF"),("Claude","TheBloke/claude2-alpaca-13B-GGUF"),("Alpaca","TheBloke/LeoScorpius-GreenNode-Alpaca-7B-v1-GGUF")], label="Large Language Model")
|
196 |
with gr.Row():
|
|
|
217 |
#btnExec.click(setTextVisibility, inputs=[cbg, model_name_input], outputs=text_list)
|
218 |
btnExec.click(setTextVisibility, inputs=[cbg, model_name_input], outputs=html_result)
|
219 |
gr.HTML("""
|
220 |
+
<div style="text-align: center; font-size: 24px; font-weight: bold;">Similarity Score: 76%</div>
|
221 |
""")
|
222 |
|
223 |
+
clear = gr.ClearButton(link = "http://127.0.0.1:7865")
|
224 |
|
225 |
with gr.Tab("Batch Mode"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
with gr.Row():
|
227 |
+
model_name_input = gr.Dropdown([("Llama", "TheBloke/Llama-2-7B-Chat-GGML"), ("Falcon", "TheBloke/Falcon-180B-GGUF"), ("Zephyr", "TheBloke/zephyr-quiklang-3b-4K-GGUF"),("Vicuna", "TheBloke/vicuna-33B-GGUF"),("Claude","TheBloke/claude2-alpaca-13B-GGUF"),("Alpaca","TheBloke/LeoScorpius-GreenNode-Alpaca-7B-v1-GGUF")], label="Large Language Model")
|
228 |
with gr.Row():
|
229 |
+
prompt_input = gr.Textbox(label="Enter your question", placeholder="Enter Your Question")
|
230 |
with gr.Row():
|
231 |
+
prompt_input = gr.Textbox(label="RELAVENCY", placeholder="Relavancy")
|
232 |
+
prompt_input = gr.Textbox(label="Diversity", placeholder="Diversity")
|
233 |
+
|
234 |
with gr.Row():
|
235 |
+
prompt_input = gr.Textbox(label="Enter your email address", placeholder="Enter Your Email Address")
|
236 |
with gr.Row():
|
237 |
+
generate_button = gr.Button("Submit", variant="primary")
|
238 |
|
239 |
+
|
240 |
# Launch the Gradio app
|
241 |
+
demo.launch()
|