mirror of
https://github.com/HKUDS/LightRAG.git
synced 2025-08-06 07:41:54 +00:00
Merge branch 'main' of github.com:HKUDS/LightRAG
This commit is contained in:
commit
cb15883130
@ -181,19 +181,55 @@ async def process_with_rag(
|
|||||||
file_path=file_path, output_dir=output_dir, parse_method="auto"
|
file_path=file_path, output_dir=output_dir, parse_method="auto"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Example queries
|
# Example queries - demonstrating different query approaches
|
||||||
queries = [
|
logger.info("\nQuerying processed document:")
|
||||||
|
|
||||||
|
# 1. Pure text queries using aquery()
|
||||||
|
text_queries = [
|
||||||
"What is the main content of the document?",
|
"What is the main content of the document?",
|
||||||
"Describe the images and figures in the document",
|
"What are the key topics discussed?",
|
||||||
"Tell me about the experimental results and data tables",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
logger.info("\nQuerying processed document:")
|
for query in text_queries:
|
||||||
for query in queries:
|
logger.info(f"\n[Text Query]: {query}")
|
||||||
logger.info(f"\nQuery: {query}")
|
result = await rag.aquery(query, mode="hybrid")
|
||||||
result = await rag.query_with_multimodal(query, mode="hybrid")
|
|
||||||
logger.info(f"Answer: {result}")
|
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:
|
except Exception as e:
|
||||||
logger.error(f"Error processing with RAG: {str(e)}")
|
logger.error(f"Error processing with RAG: {str(e)}")
|
||||||
import traceback
|
import traceback
|
||||||
|
@ -57,6 +57,10 @@ def batch_eval(query_file, result1_file, result2_file, output_file_path):
|
|||||||
"Winner": "[Answer 1 or Answer 2]",
|
"Winner": "[Answer 1 or Answer 2]",
|
||||||
"Explanation": "[Provide explanation here]"
|
"Explanation": "[Provide explanation here]"
|
||||||
}},
|
}},
|
||||||
|
"Diversity": {{
|
||||||
|
"Winner": "[Answer 1 or Answer 2]",
|
||||||
|
"Explanation": "[Provide explanation here]"
|
||||||
|
}},
|
||||||
"Empowerment": {{
|
"Empowerment": {{
|
||||||
"Winner": "[Answer 1 or Answer 2]",
|
"Winner": "[Answer 1 or Answer 2]",
|
||||||
"Explanation": "[Provide explanation here]"
|
"Explanation": "[Provide explanation here]"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user