-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdataset_config.py
More file actions
130 lines (118 loc) · 4.43 KB
/
dataset_config.py
File metadata and controls
130 lines (118 loc) · 4.43 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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# config/dataset_config.py
from typing import Any
from .prompts import (
prompt_for_execution_accuracy,
prompt_for_identification,
prompt_for_syntax_error_detection,
prompt_for_execution_plan,
prompt_for_conversion,
prompt_for_executable_judge_conversion,
prompt_for_equivalence_judge,
prompt_for_conversion_judge,
prompt_for_optimization,
prompt_for_index_advice,
prompt_for_index_advice_judge,
prompt_for_optimization_rule_judge,
prompt_for_judge_depth_rules,
prompt_for_optimization_equivalence_judge,
prompt_for_executable_judge_optimization
)
from .knowledge_base import judge_model_knowledge_base
DATASET_CONFIG = {
"sql_understanding": {
'execution_accuracy.jsonl': {
'target_model_prompt': prompt_for_execution_accuracy,
'evaluation_type': "objective",
'indicator_ability_weights': 4
},
'sql_identification.jsonl': {
'target_model_prompt': prompt_for_identification,
'evaluation_type': "objective",
'indicator_ability_weights': 3
},
'explain_detection.jsonl': {
'target_model_prompt': prompt_for_execution_plan,
'evaluation_type': "objective",
'indicator_ability_weights': 2
},
'syntax_error_detection.jsonl': {
'target_model_prompt': prompt_for_syntax_error_detection,
'evaluation_type': "objective",
'indicator_ability_weights': 1
}
},
"dialect_conversion": {
'logical_equivalence.jsonl': {
'target_model_prompt': prompt_for_conversion,
'judge_model_prompt': prompt_for_equivalence_judge,
'evaluation_type': "hybrid",
'indicator_ability_weights': 4
},
'syntax_error_detection.jsonl': {
'target_model_prompt': prompt_for_conversion,
'judge_model_prompt': prompt_for_executable_judge_conversion,
'evaluation_type': "hybrid",
'indicator_ability_weights': 2
},
'China-made_database.jsonl': {
'target_model_prompt': prompt_for_conversion,
'judge_model_prompt': prompt_for_conversion_judge,
'evaluation_type': "hybrid",
'indicator_ability_weights': 3
},
'big_sql_conversion.jsonl': {
'target_model_prompt': prompt_for_conversion,
'judge_model_prompt': prompt_for_conversion_judge,
'evaluation_type': "hybrid",
'indicator_ability_weights': 4
}
},
"sql_optimization": {
'logical_equivalence.jsonl': {
'target_model_prompt': prompt_for_optimization,
'judge_model_prompt': prompt_for_optimization_equivalence_judge,
'evaluation_type': "hybrid",
'indicator_ability_weights': 3
},
'syntax_error_detection.jsonl': {
'target_model_prompt': prompt_for_optimization,
'judge_model_prompt': prompt_for_executable_judge_optimization,
'evaluation_type': "hybrid",
'indicator_ability_weights': 3
},
'optimization_depth.jsonl': {
'target_model_prompt': prompt_for_optimization,
'judge_model_prompt': prompt_for_judge_depth_rules,
'evaluation_type': "subjective",
'indicator_ability_weights': 2
},
'index_advice.jsonl': {
'target_model_prompt': prompt_for_index_advice,
'judge_model_prompt': prompt_for_index_advice_judge,
'evaluation_type': "hybrid",
'indicator_ability_weights': 2
},
}
}
def get_dataset_config(category: str, filename: str, field: str, default):
return (
DATASET_CONFIG
.get(category, {})
.get(filename, {})
.get(field, default)
)
def generate_model_prompt(dir: str, file: str, case: dict) -> str:
func = get_dataset_config(dir, file, 'target_model_prompt', '')
return func(case)
def generate_judge_model_prompt(model_name: str, dir: str, file: str, case: dict, model_answer: Any) -> str:
func = get_dataset_config(dir, file, 'judge_model_prompt', '')
prompt = func(model_name, case, model_answer)
# Enhance prompt with knowledge base if applicable
enhanced_prompt = judge_model_knowledge_base(prompt, case)
return enhanced_prompt
# Difficulty level weight configuration
DIFFICULTY_WEIGHTS_CONFIG = {
'1': 1,
'2': 2,
'3': 3
}