thankrandomness
commited on
Commit
•
1e4f0c7
1
Parent(s):
b0c4c0f
revert
Browse files
app.py
CHANGED
@@ -81,16 +81,14 @@ def retrieve_relevant_text(input_text):
|
|
81 |
|
82 |
# Extract code and similarity scores
|
83 |
output = []
|
84 |
-
for
|
85 |
-
output.append(
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
)
|
93 |
-
return "\n".join(output)
|
94 |
|
95 |
# Evaluate retrieval efficiency on the validation/test set
|
96 |
def evaluate_efficiency(dataset_split):
|
@@ -127,7 +125,11 @@ precision, recall, f1 = evaluate_efficiency(dataset['validation'])
|
|
127 |
# Gradio interface
|
128 |
def gradio_interface(input_text):
|
129 |
results = retrieve_relevant_text(input_text)
|
130 |
-
|
|
|
|
|
|
|
|
|
131 |
|
132 |
# Display retrieval efficiency metrics
|
133 |
metrics = f"Precision: {precision:.2f}, Recall: {recall:.2f}, F1 Score: {f1:.2f}"
|
@@ -135,12 +137,9 @@ metrics = f"Precision: {precision:.2f}, Recall: {recall:.2f}, F1 Score: {f1:.2f}
|
|
135 |
with gr.Blocks() as interface:
|
136 |
gr.Markdown("# Text Retrieval with Efficiency Metrics")
|
137 |
gr.Markdown(metrics)
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
submit_button = gr.Button("Submit")
|
142 |
-
with gr.Column():
|
143 |
-
text_output = gr.Textbox(label="Retrieved Results")
|
144 |
submit_button.click(fn=gradio_interface, inputs=text_input, outputs=text_output)
|
145 |
|
146 |
interface.launch()
|
|
|
81 |
|
82 |
# Extract code and similarity scores
|
83 |
output = []
|
84 |
+
for metadata, distance in zip(results['metadatas'][0], results['distances'][0]):
|
85 |
+
output.append({
|
86 |
+
"similarity_score": distance,
|
87 |
+
"code": metadata['code'],
|
88 |
+
"code_system": metadata['code_system'],
|
89 |
+
"description": metadata['description']
|
90 |
+
})
|
91 |
+
return output
|
|
|
|
|
92 |
|
93 |
# Evaluate retrieval efficiency on the validation/test set
|
94 |
def evaluate_efficiency(dataset_split):
|
|
|
125 |
# Gradio interface
|
126 |
def gradio_interface(input_text):
|
127 |
results = retrieve_relevant_text(input_text)
|
128 |
+
formatted_results = [
|
129 |
+
f"Similarity Score: {result['similarity_score']:.2f}, Code: {result['code']}, Description: {result['description']}"
|
130 |
+
for result in results
|
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 |
with gr.Blocks() as interface:
|
138 |
gr.Markdown("# Text Retrieval with Efficiency Metrics")
|
139 |
gr.Markdown(metrics)
|
140 |
+
text_input = gr.Textbox(label="Input Text")
|
141 |
+
text_output = gr.Textbox(label="Retrieved Results")
|
142 |
+
submit_button = gr.Button("Submit")
|
|
|
|
|
|
|
143 |
submit_button.click(fn=gradio_interface, inputs=text_input, outputs=text_output)
|
144 |
|
145 |
interface.launch()
|