File size: 4,185 Bytes
f840733 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
#!/usr/bin/env python3
"""
Test script to verify the new CSV filename generation functionality
"""
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from advanced_rag import get_short_embedding_name, get_short_llm_name, get_varied_parameter
def test_embedding_names():
"""Test embedding model name generation"""
test_cases = [
("π€ sentence-transformers/all-MiniLM-L6-v2 (384 dim, fast)", "MiniLM"),
("π€ BAAI/bge-base-en-v1.5 (768 dim, excellent)", "BGE-Base"),
("π¦ Qwen/Qwen3-Embedding-8B (1024 dim, advanced)", "Qwen3-8B"),
("sentence-transformers/all-mpnet-base-v2", "MPNet"),
("unknown-model", "unknown")
]
print("Testing embedding name generation:")
for input_name, expected in test_cases:
result = get_short_embedding_name(input_name)
status = "β" if result == expected else "β"
print(f" {status} {input_name} -> {result} (expected: {expected})")
def test_llm_names():
"""Test LLM model name generation"""
test_cases = [
("πͺπΊ Mistral-API", "Mistral"),
("πΊπΈ Remote Meta-Llama-3", "Llama3"),
("πΊπΈ GPT-4o", "GPT4o"),
("mistral-small-latest", "Mistral"),
("meta-llama/Meta-Llama-3-8B-Instruct", "Llama3"),
("unknown-model", "unknown")
]
print("\nTesting LLM name generation:")
for input_name, expected in test_cases:
result = get_short_llm_name(input_name)
status = "β" if result == expected else "β"
print(f" {status} {input_name} -> {result} (expected: {expected})")
def test_varied_parameter():
"""Test varied parameter detection"""
test_cases = [
({"temperature": "Constant", "top_p": "Constant", "top_k": "Constant", "bm25": "Constant"}, "None"),
({"temperature": "Whole range 3 values", "top_p": "Constant", "top_k": "Constant", "bm25": "Constant"}, "temperature"),
({"temperature": "Constant", "top_p": "Whole range 5 values", "top_k": "Constant", "bm25": "Constant"}, "top_p"),
({"temperature": "Whole range 3 values", "top_p": "Whole range 5 values", "top_k": "Constant", "bm25": "Constant"}, "Multi"),
({"temperature": "Constant", "top_p": "Constant", "top_k": "Constant", "bm25": "Whole range 7 values"}, "bm25")
]
print("\nTesting varied parameter detection:")
for param_configs, expected in test_cases:
result = get_varied_parameter(param_configs)
status = "β" if result == expected else "β"
print(f" {status} {param_configs} -> {result} (expected: {expected})")
def test_filename_generation():
"""Test complete filename generation"""
from datetime import datetime
# Mock timestamp for consistent testing
timestamp = "20241201_120000"
test_cases = [
("π€ sentence-transformers/all-MiniLM-L6-v2 (384 dim, fast)", "πͺπΊ Mistral-API", "temperature", "batch_MiniLM_Mistral_temperature_20241201_120000.csv"),
("π€ BAAI/bge-base-en-v1.5 (768 dim, excellent)", "πΊπΈ Remote Meta-Llama-3", "top_p", "batch_BGE-Base_Llama3_top_p_20241201_120000.csv"),
("π¦ Qwen/Qwen3-Embedding-8B (1024 dim, advanced)", "πΊπΈ GPT-4o", "Multi", "batch_Qwen3-8B_GPT4o_Multi_20241201_120000.csv"),
("", "", "None", "batch_Unknown_Unknown_None_20241201_120000.csv")
]
print("\nTesting complete filename generation:")
for embedding, llm, param, expected in test_cases:
short_embedding = get_short_embedding_name(embedding) if embedding else "Unknown"
short_llm = get_short_llm_name(llm) if llm else "Unknown"
short_param = param if param else "None"
filename = f"batch_{short_embedding}_{short_llm}_{short_param}_{timestamp}.csv"
status = "β" if filename == expected else "β"
print(f" {status} Generated: {filename}")
print(f" Expected: {expected}")
if __name__ == "__main__":
print("Testing CSV filename generation functionality\n")
test_embedding_names()
test_llm_names()
test_varied_parameter()
test_filename_generation()
print("\nTest completed!")
|