|
|
import sys |
|
|
from pathlib import Path |
|
|
|
|
|
|
|
|
sys.path.append(str(Path(__file__).parent)) |
|
|
|
|
|
from src.rag_engine import SatelliteRAG |
|
|
import time |
|
|
|
|
|
def evaluate_rag(): |
|
|
print("Initializing Satellite RAG Engine for Evaluation...") |
|
|
try: |
|
|
engine = SatelliteRAG() |
|
|
except Exception as e: |
|
|
print(f"Failed to initialize engine: {e}") |
|
|
return |
|
|
|
|
|
test_questions = [ |
|
|
"1. What is the spatial resolution of Gaofen 1?", |
|
|
"2. Who operates the Tianhui 1 satellite?", |
|
|
"3. When was the first Yaogan satellite launched?", |
|
|
"4. Which satellites are equipped with SAR (Synthetic Aperture Radar)?", |
|
|
"5. What is the difference between Gaofen 4 and Gaofen 5?", |
|
|
"6. List the instruments on board the Ziyuan 3 satellite.", |
|
|
"7. Tell me about the orbit of the Shijian 11 series.", |
|
|
"8. What is the purpose of the Chuangxin 1 satellite?", |
|
|
"9. How many spectral bands does the WFI on CBERS-4 have?", |
|
|
"10. Which launch vehicle was used for the Jilin-1 Gaofen 03 satellites?" |
|
|
] |
|
|
|
|
|
print(f"\nStarting Evaluation with {len(test_questions)} Questions...\n") |
|
|
print("-" * 60) |
|
|
|
|
|
for i, question in enumerate(test_questions): |
|
|
print(f"\n[?] Question: {question}") |
|
|
start_time = time.time() |
|
|
|
|
|
try: |
|
|
response, docs = engine.query(question) |
|
|
end_time = time.time() |
|
|
duration = end_time - start_time |
|
|
|
|
|
print(f"[Time]: {duration:.2f}s") |
|
|
print(f"[Docs Retrieved]: {len(docs)}") |
|
|
print(f"[Answer]:") |
|
|
print(f"{response}") |
|
|
print("-" * 60) |
|
|
|
|
|
except Exception as e: |
|
|
print(f"Error processing question: {e}") |
|
|
print("-" * 60) |
|
|
|
|
|
if __name__ == "__main__": |
|
|
evaluate_rag() |
|
|
|