From 62655a4725235774b148cc498c84d023251e99c9 Mon Sep 17 00:00:00 2001 From: zrguo <49157727+LarFii@users.noreply.github.com> Date: Fri, 4 Jul 2025 11:32:01 +0800 Subject: [PATCH 1/2] Update raganything_example.py --- examples/raganything_example.py | 52 ++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/examples/raganything_example.py b/examples/raganything_example.py index 7f346391..f61274a8 100644 --- a/examples/raganything_example.py +++ b/examples/raganything_example.py @@ -181,19 +181,55 @@ async def process_with_rag( file_path=file_path, output_dir=output_dir, parse_method="auto" ) - # Example queries - queries = [ + # Example queries - demonstrating different query approaches + logger.info("\nQuerying processed document:") + + # 1. Pure text queries using aquery() + text_queries = [ "What is the main content of the document?", - "Describe the images and figures in the document", - "Tell me about the experimental results and data tables", + "What are the key topics discussed?", ] - logger.info("\nQuerying processed document:") - for query in queries: - logger.info(f"\nQuery: {query}") - result = await rag.query_with_multimodal(query, mode="hybrid") + for query in text_queries: + logger.info(f"\n[Text Query]: {query}") + result = await rag.aquery(query, mode="hybrid") logger.info(f"Answer: {result}") + # 2. Multimodal query with specific multimodal content using aquery_with_multimodal() + logger.info( + "\n[Multimodal Query]: Analyzing performance data in context of document" + ) + multimodal_result = await rag.aquery_with_multimodal( + "Compare this performance data with any similar results mentioned in the document", + multimodal_content=[ + { + "type": "table", + "table_data": """Method,Accuracy,Processing_Time + RAGAnything,95.2%,120ms + Traditional_RAG,87.3%,180ms + Baseline,82.1%,200ms""", + "table_caption": "Performance comparison results", + } + ], + mode="hybrid", + ) + logger.info(f"Answer: {multimodal_result}") + + # 3. Another multimodal query with equation content + logger.info("\n[Multimodal Query]: Mathematical formula analysis") + equation_result = await rag.aquery_with_multimodal( + "Explain this formula and relate it to any mathematical concepts in the document", + multimodal_content=[ + { + "type": "equation", + "latex": "F1 = 2 \\cdot \\frac{precision \\cdot recall}{precision + recall}", + "equation_caption": "F1-score calculation formula", + } + ], + mode="hybrid", + ) + logger.info(f"Answer: {equation_result}") + except Exception as e: logger.error(f"Error processing with RAG: {str(e)}") import traceback From 840cd4650b357df58677f15df22e02c7ee254810 Mon Sep 17 00:00:00 2001 From: zrguo <49157727+LarFii@users.noreply.github.com> Date: Fri, 4 Jul 2025 14:33:03 +0800 Subject: [PATCH 2/2] Update batch_eval.py --- reproduce/batch_eval.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/reproduce/batch_eval.py b/reproduce/batch_eval.py index a85e1ede..424b4f54 100644 --- a/reproduce/batch_eval.py +++ b/reproduce/batch_eval.py @@ -57,6 +57,10 @@ def batch_eval(query_file, result1_file, result2_file, output_file_path): "Winner": "[Answer 1 or Answer 2]", "Explanation": "[Provide explanation here]" }}, + "Diversity": {{ + "Winner": "[Answer 1 or Answer 2]", + "Explanation": "[Provide explanation here]" + }}, "Empowerment": {{ "Winner": "[Answer 1 or Answer 2]", "Explanation": "[Provide explanation here]"