Pijush2023
commited on
Commit
•
c020ce7
1
Parent(s):
f5c8bff
Update app.py
Browse files
app.py
CHANGED
@@ -145,6 +145,23 @@ def model(prompt):
|
|
145 |
|
146 |
return [highlighted_user_prompt, highlighted_accepted_sentences, highlighted_discarded_sentences] + trees1 + trees2 + reparaphrased_sentences_list + [three_D_plot]
|
147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
|
149 |
with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
150 |
gr.Markdown("# **AIISC Watermarking Model**")
|
@@ -156,6 +173,7 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
|
156 |
submit_button = gr.Button("Submit")
|
157 |
clear_button = gr.Button("Clear")
|
158 |
generate_non_melting_point_button = gr.Button("Generate Non-Melting Point") # New button
|
|
|
159 |
|
160 |
with gr.Row():
|
161 |
highlighted_user_prompt = gr.HTML()
|
@@ -226,6 +244,12 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
|
226 |
inputs=user_input,
|
227 |
outputs=highlighted_user_prompt
|
228 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
clear_button.click(lambda: "", inputs=None, outputs=user_input)
|
230 |
clear_button.click(lambda: "", inputs=None, outputs=[highlighted_user_prompt, highlighted_accepted_sentences, highlighted_discarded_sentences] + tree1_tabs + tree2_tabs + reparaphrased_sentences_tabs + [three_D_plot])
|
231 |
|
|
|
145 |
|
146 |
return [highlighted_user_prompt, highlighted_accepted_sentences, highlighted_discarded_sentences] + trees1 + trees2 + reparaphrased_sentences_list + [three_D_plot]
|
147 |
|
148 |
+
# Logic for the new "Paraphrase and Discarded Sentence Generator" button
|
149 |
+
def generate_paraphrase_and_discarded_sentences(prompt):
|
150 |
+
user_prompt = prompt
|
151 |
+
paraphrased_sentences = generate_paraphrase(user_prompt)
|
152 |
+
analyzed_paraphrased_sentences, selected_sentences, discarded_sentences = analyze_entailment(user_prompt, paraphrased_sentences, 0.7)
|
153 |
+
|
154 |
+
# Combine discarded sentences with their entailment scores
|
155 |
+
discarded_sentences_with_scores = [
|
156 |
+
f"{sentence} (Entailment Score: {score:.2f})"
|
157 |
+
for sentence, score in discarded_sentences.items()
|
158 |
+
]
|
159 |
+
|
160 |
+
# Prepare paraphrased sentences for display
|
161 |
+
paraphrased_sentences_html = highlight_common_words_dict([], selected_sentences, "Paraphrased Sentences")
|
162 |
+
discarded_sentences_html = "<br>".join(discarded_sentences_with_scores)
|
163 |
+
|
164 |
+
return paraphrased_sentences_html, discarded_sentences_html
|
165 |
|
166 |
with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
167 |
gr.Markdown("# **AIISC Watermarking Model**")
|
|
|
173 |
submit_button = gr.Button("Submit")
|
174 |
clear_button = gr.Button("Clear")
|
175 |
generate_non_melting_point_button = gr.Button("Generate Non-Melting Point") # New button
|
176 |
+
paraphrase_discard_button = gr.Button("Paraphrase and Discarded Sentence Generator")
|
177 |
|
178 |
with gr.Row():
|
179 |
highlighted_user_prompt = gr.HTML()
|
|
|
244 |
inputs=user_input,
|
245 |
outputs=highlighted_user_prompt
|
246 |
)
|
247 |
+
|
248 |
+
paraphrase_discard_button.click(
|
249 |
+
generate_paraphrase_and_discarded_sentences,
|
250 |
+
inputs=user_input,
|
251 |
+
outputs=[highlighted_accepted_sentences, highlighted_discarded_sentences]
|
252 |
+
)
|
253 |
clear_button.click(lambda: "", inputs=None, outputs=user_input)
|
254 |
clear_button.click(lambda: "", inputs=None, outputs=[highlighted_user_prompt, highlighted_accepted_sentences, highlighted_discarded_sentences] + tree1_tabs + tree2_tabs + reparaphrased_sentences_tabs + [three_D_plot])
|
255 |
|