Spaces:
Running
Running
| from src.search.vector_search import ( | |
| search_vector_with_expansion, | |
| search_vector_with_reranking, | |
| ) | |
| if __name__ == "__main__": | |
| query = "wireless headphones" | |
| print(f"=== Testing: {query} ===\n") | |
| # Stage 3: Query Expansion | |
| print("STAGE 3: Query Expansion Results") | |
| results_3 = search_vector_with_expansion(query) | |
| for i, r in enumerate(results_3[:5], 1): | |
| print(f"{i}. [{r['score']:.4f}] {r['product_name']}") | |
| print("\n" + "=" * 80 + "\n") | |
| # Stage 4: Reranking | |
| print("STAGE 4: Reranking Results") | |
| results_4 = search_vector_with_reranking(query) | |
| for i, r in enumerate(results_4[:5], 1): | |
| print(f"{i}. [{r['score']:.4f}] {r['product_name']}") | |
| print("\n" + "=" * 80 + "\n") | |
| print("Analysis:") | |
| print( | |
| f"Stage 3 Top-1: {results_3[0]['score']:.4f} - {results_3[0]['product_name']}" | |
| ) | |
| print( | |
| f"Stage 4 Top-1: {results_4[0]['score']:.4f} - {results_4[0]['product_name']}" | |
| ) | |
| if results_3[0]["product_name"] != results_4[0]["product_name"]: | |
| print("\n⚠️ Reranker changed the top result!") | |