-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevaluate_query_classifier.py
More file actions
36 lines (29 loc) · 1.11 KB
/
evaluate_query_classifier.py
File metadata and controls
36 lines (29 loc) · 1.11 KB
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
from pathlib import Path
from src.relevance_classifier import classify_relevance
from src.utils import read_json
if __name__ == '__main__':
MODEL = 'mistral'
TEMPERATURE = 0.0
OLLAMA_URL = "http://localhost:11434/"
PROMPTS_PATH = Path('./prompts')
CLASSIFIER_PATH = PROMPTS_PATH / "query_classifier/query_classifier.txt"
DATA_PATH = Path('./data')
FAQ_PATH = DATA_PATH / "test/test_query_classifier.json"
# read the test queries
test_queries = read_json(FAQ_PATH)
test_queries = test_queries['queries']
total = len(test_queries)
correct = 0
incorrect = 0
for query in test_queries:
question = query['query']
expected = query['expected']
result = classify_relevance(query=question,
ollama_base_url=OLLAMA_URL,
prompt_path=CLASSIFIER_PATH,
model='mistral', temperature=0.0)
if result == expected:
correct += 1
else:
incorrect += 1
print(f'Classifier accuracy {float(correct) / float(total):0.2f}')