thankrandomness
commited on
Commit
•
773c7a0
1
Parent(s):
206cc5e
fix
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,16 @@ 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}"
|
@@ -140,7 +147,7 @@ with gr.Blocks() as interface:
|
|
140 |
text_input = gr.Textbox(label="Input Text")
|
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"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}"
|
|
|
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()
|