Commit
•
a53ec7d
1
Parent(s):
1e4f0c7
fix
Browse files
app.py
CHANGED
@@ -126,10 +126,15 @@ precision, recall, f1 = evaluate_efficiency(dataset['validation'])
|
|
126 |
def gradio_interface(input_text):
|
127 |
results = retrieve_relevant_text(input_text)
|
128 |
formatted_results = [
|
129 |
-
f"
|
130 |
-
|
|
|
|
|
|
|
|
|
|
|
131 |
]
|
132 |
-
return formatted_results
|
133 |
|
134 |
# Display retrieval efficiency metrics
|
135 |
metrics = f"Precision: {precision:.2f}, Recall: {recall:.2f}, F1 Score: {f1:.2f}"
|
@@ -137,9 +142,12 @@ metrics = f"Precision: {precision:.2f}, Recall: {recall:.2f}, F1 Score: {f1:.2f}
|
|
137 |
with gr.Blocks() as interface:
|
138 |
gr.Markdown("# Text Retrieval with Efficiency Metrics")
|
139 |
gr.Markdown(metrics)
|
140 |
-
|
141 |
-
|
142 |
-
|
|
|
|
|
|
|
143 |
submit_button.click(fn=gradio_interface, inputs=text_input, outputs=text_output)
|
144 |
|
145 |
interface.launch()
|
|
|
126 |
def gradio_interface(input_text):
|
127 |
results = retrieve_relevant_text(input_text)
|
128 |
formatted_results = [
|
129 |
+
f"Result {i + 1}:\n"
|
130 |
+
f"Similarity Score: {result['similarity_score']:.2f}\n"
|
131 |
+
f"Code: {result['code']}\n"
|
132 |
+
f"Code System: {result['code_system']}\n"
|
133 |
+
f"Description: {result['description']}\n"
|
134 |
+
"-------------------"
|
135 |
+
for i, result in enumerate(results)
|
136 |
]
|
137 |
+
return "\n".join(formatted_results)
|
138 |
|
139 |
# Display retrieval efficiency metrics
|
140 |
metrics = f"Precision: {precision:.2f}, Recall: {recall:.2f}, F1 Score: {f1:.2f}"
|
|
|
142 |
with gr.Blocks() as interface:
|
143 |
gr.Markdown("# Text Retrieval with Efficiency Metrics")
|
144 |
gr.Markdown(metrics)
|
145 |
+
with gr.Row():
|
146 |
+
with gr.Column():
|
147 |
+
text_input = gr.Textbox(label="Input Text")
|
148 |
+
submit_button = gr.Button("Submit")
|
149 |
+
with gr.Column():
|
150 |
+
text_output = gr.Textbox(label="Retrieved Results", lines=10)
|
151 |
submit_button.click(fn=gradio_interface, inputs=text_input, outputs=text_output)
|
152 |
|
153 |
interface.launch()
|