Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,6 +38,7 @@ def query_tqa(query, search_level):
|
|
| 38 |
return grag_response, grag_reference, grag_reference_text, rag_response, rag_reference, rag_reference_text
|
| 39 |
|
| 40 |
|
|
|
|
| 41 |
def eval_llm(query, rag_response, grag_response):
|
| 42 |
"""
|
| 43 |
Evaluate responses from both Graph-RAG and RAG models using an LLM.
|
|
@@ -50,9 +51,8 @@ def eval_llm(query, rag_response, grag_response):
|
|
| 50 |
Returns:
|
| 51 |
tuple: Evaluation results for both responses.
|
| 52 |
"""
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
return parse_evaluation_regex(grag_eval), parse_evaluation_regex(rag_eval)
|
| 56 |
|
| 57 |
|
| 58 |
|
|
@@ -65,25 +65,29 @@ with gr.Blocks() as demo:
|
|
| 65 |
search_level = gr.Slider(minimum=1, maximum=50, value=3, step=5, label="Search level")
|
| 66 |
ask_button = gr.Button("Ask TelcomVA!!")
|
| 67 |
|
| 68 |
-
|
| 69 |
with gr.Row():
|
| 70 |
with gr.Accordion("Graph-RAG!", open=True):
|
| 71 |
grag_output = gr.Textbox(label="Response")
|
| 72 |
grag_reference = gr.Textbox(label="Triplets")
|
| 73 |
-
|
|
|
|
| 74 |
|
| 75 |
with gr.Accordion("RAG", open=True):
|
| 76 |
rag_output = gr.Textbox(label="Response")
|
| 77 |
rag_reference = gr.Textbox(label="Extracted Reference")
|
| 78 |
-
|
|
|
|
| 79 |
|
| 80 |
|
| 81 |
with gr.Row():
|
| 82 |
grag_performance = gr.Textbox(label="Graph-RAG Performance")
|
| 83 |
-
rag_performance = gr.
|
| 84 |
eval_button = gr.Button("Evaluate LLMs!!")
|
| 85 |
|
| 86 |
-
|
|
|
|
|
|
|
| 87 |
|
| 88 |
with gr.Accordion("Explore KG!", open=False):
|
| 89 |
kg_output = gr.HTML()
|
|
@@ -105,7 +109,14 @@ with gr.Blocks() as demo:
|
|
| 105 |
inputs=[query_input,rag_output,grag_output],
|
| 106 |
outputs=[
|
| 107 |
grag_performance,
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
]
|
| 110 |
)
|
| 111 |
|
|
@@ -118,4 +129,5 @@ with gr.Blocks() as demo:
|
|
| 118 |
],
|
| 119 |
inputs=[query_input]
|
| 120 |
)
|
|
|
|
| 121 |
demo.launch(auth=(os.getenv('id'), os.getenv('pass')), share=True)
|
|
|
|
| 38 |
return grag_response, grag_reference, grag_reference_text, rag_response, rag_reference, rag_reference_text
|
| 39 |
|
| 40 |
|
| 41 |
+
|
| 42 |
def eval_llm(query, rag_response, grag_response):
|
| 43 |
"""
|
| 44 |
Evaluate responses from both Graph-RAG and RAG models using an LLM.
|
|
|
|
| 51 |
Returns:
|
| 52 |
tuple: Evaluation results for both responses.
|
| 53 |
"""
|
| 54 |
+
eval_text = evaluate_llm(query, grag_response, rag_response)
|
| 55 |
+
return eval_text #, parse_evaluation_regex(grag_eval)
|
|
|
|
| 56 |
|
| 57 |
|
| 58 |
|
|
|
|
| 65 |
search_level = gr.Slider(minimum=1, maximum=50, value=3, step=5, label="Search level")
|
| 66 |
ask_button = gr.Button("Ask TelcomVA!!")
|
| 67 |
|
| 68 |
+
|
| 69 |
with gr.Row():
|
| 70 |
with gr.Accordion("Graph-RAG!", open=True):
|
| 71 |
grag_output = gr.Textbox(label="Response")
|
| 72 |
grag_reference = gr.Textbox(label="Triplets")
|
| 73 |
+
with gr.Accordion("Extracted Reference raw", open=False):
|
| 74 |
+
grag_reference_text = gr.Textbox(label="Extracted Reference raw")
|
| 75 |
|
| 76 |
with gr.Accordion("RAG", open=True):
|
| 77 |
rag_output = gr.Textbox(label="Response")
|
| 78 |
rag_reference = gr.Textbox(label="Extracted Reference")
|
| 79 |
+
with gr.Accordion("Extracted Reference raw", open=False):
|
| 80 |
+
rag_reference_text = gr.Textbox(label="Extracted Reference raw")
|
| 81 |
|
| 82 |
|
| 83 |
with gr.Row():
|
| 84 |
grag_performance = gr.Textbox(label="Graph-RAG Performance")
|
| 85 |
+
# rag_performance = gr.HTML(label="RAG Performance")
|
| 86 |
eval_button = gr.Button("Evaluate LLMs!!")
|
| 87 |
|
| 88 |
+
with gr.Row():
|
| 89 |
+
grag_reasoning = gr.Textbox(label="Graph-RAG Reasoning")
|
| 90 |
+
reason_button = gr.Button("Get Graph Reasoning!!")
|
| 91 |
|
| 92 |
with gr.Accordion("Explore KG!", open=False):
|
| 93 |
kg_output = gr.HTML()
|
|
|
|
| 109 |
inputs=[query_input,rag_output,grag_output],
|
| 110 |
outputs=[
|
| 111 |
grag_performance,
|
| 112 |
+
# rag_performance
|
| 113 |
+
]
|
| 114 |
+
)
|
| 115 |
+
|
| 116 |
+
reason_button.click(reasoning_graph,
|
| 117 |
+
inputs=[query_input,grag_output,grag_reference],
|
| 118 |
+
outputs=[
|
| 119 |
+
grag_reasoning
|
| 120 |
]
|
| 121 |
)
|
| 122 |
|
|
|
|
| 129 |
],
|
| 130 |
inputs=[query_input]
|
| 131 |
)
|
| 132 |
+
|
| 133 |
demo.launch(auth=(os.getenv('id'), os.getenv('pass')), share=True)
|