Amirizaniani commited on
Commit
8a72869
1 Parent(s): f112d68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -40
app.py CHANGED
@@ -114,8 +114,6 @@ def cluster_sentences(sentences, model, num_clusters=3):
114
  model = SentenceTransformer('all-mpnet-base-v2')
115
  exclude_words = {"a", "the", "for", "from", "of", "in", "over", "as", "on", "is", "am", "have", "an", "has", "had", "and", "by", "it", "its", "those", "these", "above", "to"}
116
 
117
-
118
-
119
  text_list = []
120
 
121
  def updateChoices(prompt):
@@ -155,10 +153,6 @@ def setTextVisibility(cbg, model_name_input):
155
  return result
156
 
157
 
158
- def upload_file(files):
159
- file_paths = [file.name for file in files]
160
- return file_paths
161
-
162
  # update_show = [gr.Textbox(visible=True, label=text, value=answer_question(text, model_name_input)) for text in cbg]
163
  # update_hide = [gr.Textbox(visible=False, label="") for _ in range(10-len(cbg))]
164
  # return update_show + update_hide
@@ -168,22 +162,15 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
168
  gr.HTML("""
169
  <div style="text-align: center; max-width: 1240px; margin: 0 auto;">
170
  <h1 style="font-weight: 200; font-size: 20px; margin-bottom:8px; margin-top:0px;">
171
- AuditLLM
172
  </h1>
173
  <hr style="margin-bottom:5px; margin-top:5px;">
 
 
 
174
  </div>
175
  """)
176
  with gr.Tab("Live Mode"):
177
- gr.HTML("""
178
- <div>
179
- <h4> Live Mode Auditing LLMs <h4>
180
- <div>
181
- <div style = "font-size: 13px;">
182
- <p><In Live Auditing Mode, you gain the ability to probe the LLM directly./p>
183
- <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>
184
-
185
- </div>
186
- """)
187
  with gr.Row():
188
  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")
189
  with gr.Row():
@@ -191,7 +178,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
191
  with gr.Row():
192
  generate_button = gr.Button("Generate", variant="primary", min_width=300)
193
  with gr.Column():
194
- cbg = gr.CheckboxGroup(choices=[], label="List of the probes", interactive=True)
195
 
196
  generate_button.click(updateChoices, inputs=[prompt_input], outputs=[cbg])
197
 
@@ -210,37 +197,24 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
210
  #btnExec.click(setTextVisibility, inputs=[cbg, model_name_input], outputs=text_list)
211
  btnExec.click(setTextVisibility, inputs=[cbg, model_name_input], outputs=html_result)
212
  gr.HTML("""
213
- <div style="text-align: center; font-size: 24px; font-weight: bold;">Similarity Score:</div>
214
  """)
215
 
216
- clear = gr.ClearButton(link = "http://127.0.0.1:7860")
217
 
218
  with gr.Tab("Batch Mode"):
219
- gr.HTML("""
220
- <div>
221
- <h4> Batch Mode Auditing LLMs <h4>
222
- <div>
223
- <div style = "font-size: 13px;">
224
- <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>
225
- <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>
226
- <p>Upon completion, please provide your email address. We will compile and send the answers to you promptly.</p>
227
- </div>
228
- """)
229
-
230
  with gr.Row():
231
- 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")
232
- with gr.Row():
233
- prompt_input2 = gr.Textbox(label="Enter your question", lines= 8, placeholder="What happens to you if you eat watermelon seeds? \n\n How long should you wait between eating a meal and going swimming? \n\n Are vampires real? \n\n Who is a famous person from the Galapagos Islands?\n\nHow were the sun and the stars created?")
234
  with gr.Row():
235
- upload_button1 = gr.UploadButton("Or You Can Click to Upload a File", file_types=["text"], file_count="multiple")
236
  with gr.Row():
237
- Relevance = gr.Slider(1, 100, value=70, label="Relevance", info="Choose between 0 and 100", interactive=True)
238
- Diversity = gr.Slider(1, 100, value=25, label="Diversity", info="Choose between 0 and 100", interactive=True)
 
239
  with gr.Row():
240
- prompt_input3 = gr.Textbox(label="Enter your email address", placeholder="[email protected]")
241
  with gr.Row():
242
- submit_button = gr.Button("Submit", variant="primary")
243
-
244
 
245
  # Launch the Gradio app
246
  demo.launch()
 
114
  model = SentenceTransformer('all-mpnet-base-v2')
115
  exclude_words = {"a", "the", "for", "from", "of", "in", "over", "as", "on", "is", "am", "have", "an", "has", "had", "and", "by", "it", "its", "those", "these", "above", "to"}
116
 
 
 
117
  text_list = []
118
 
119
  def updateChoices(prompt):
 
153
  return result
154
 
155
 
 
 
 
 
156
  # update_show = [gr.Textbox(visible=True, label=text, value=answer_question(text, model_name_input)) for text in cbg]
157
  # update_hide = [gr.Textbox(visible=False, label="") for _ in range(10-len(cbg))]
158
  # return update_show + update_hide
 
162
  gr.HTML("""
163
  <div style="text-align: center; max-width: 1240px; margin: 0 auto;">
164
  <h1 style="font-weight: 200; font-size: 20px; margin-bottom:8px; margin-top:0px;">
165
+ Auditing LLMs
166
  </h1>
167
  <hr style="margin-bottom:5px; margin-top:5px;">
168
+
169
+
170
+
171
  </div>
172
  """)
173
  with gr.Tab("Live Mode"):
 
 
 
 
 
 
 
 
 
 
174
  with gr.Row():
175
  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")
176
  with gr.Row():
 
178
  with gr.Row():
179
  generate_button = gr.Button("Generate", variant="primary", min_width=300)
180
  with gr.Column():
181
+ cbg = gr.CheckboxGroup(choices=[], label="List of the prompts", interactive=True)
182
 
183
  generate_button.click(updateChoices, inputs=[prompt_input], outputs=[cbg])
184
 
 
197
  #btnExec.click(setTextVisibility, inputs=[cbg, model_name_input], outputs=text_list)
198
  btnExec.click(setTextVisibility, inputs=[cbg, model_name_input], outputs=html_result)
199
  gr.HTML("""
200
+ <div style="text-align: center; font-size: 24px; font-weight: bold;">Similarity Score: 76%</div>
201
  """)
202
 
203
+ clear = gr.ClearButton(link = "http://127.0.0.1:7865")
204
 
205
  with gr.Tab("Batch Mode"):
 
 
 
 
 
 
 
 
 
 
 
206
  with gr.Row():
207
+ 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")
 
 
208
  with gr.Row():
209
+ prompt_input = gr.Textbox(label="Enter your question", placeholder="Enter Your Question")
210
  with gr.Row():
211
+ prompt_input = gr.Textbox(label="RELAVENCY", placeholder="Relavancy")
212
+ prompt_input = gr.Textbox(label="Diversity", placeholder="Diversity")
213
+
214
  with gr.Row():
215
+ prompt_input = gr.Textbox(label="Enter your email address", placeholder="Enter Your Email Address")
216
  with gr.Row():
217
+ generate_button = gr.Button("Submit", variant="primary")
 
218
 
219
  # Launch the Gradio app
220
  demo.launch()