2929RETRIEVAL_QREL_QUERIES = 1_500
3030OOD_RETRIEVAL_CHECK_QUERIES = 500
3131TOP_K = 10
32+ MAX_EVAL_QUERY_CHARS = 120
3233
3334FINANCE_CLASSIFICATION_TARGET = 4_000
3435FINANCE_RETRIEVAL_TARGET = 1_500
@@ -155,7 +156,7 @@ def _sample_finance_classification_rows(rows: list[dict], target: int) -> list[E
155156 if product_type in {"" , "unknown" } or question_style == "" :
156157 continue
157158 query = str (row .get ("query" ) or "" ).strip ()
158- if not query :
159+ if not _is_question_style_eval_query ( query ) :
159160 continue
160161 expected_sources = tuple (_ordered_unique (_as_tuple (row .get ("expected_document_sources" )) + _as_tuple (row .get ("expected_structured_sources" ))))
161162 pool .append (
@@ -190,7 +191,7 @@ def _sample_finance_retrieval_queries(qrel_rows: list[dict], corpus_rows: list[d
190191 query = str (row .get ("query" ) or "" ).strip ()
191192 doc_id = str (row .get ("doc_id" ) or "" ).strip ()
192193 relevance = int (row .get ("relevance" ) or 0 )
193- if not query or not doc_id or relevance <= 0 :
194+ if not _is_question_style_eval_query ( query ) or not doc_id or relevance <= 0 :
194195 continue
195196 item = grouped .setdefault (
196197 query ,
@@ -231,7 +232,7 @@ def _sample_ood_public_queries(classification_rows: list[dict], qrel_rows: list[
231232 if source_id not in OOD_SOURCE_IDS :
232233 continue
233234 query = str (row .get ("query" ) or "" ).strip ()
234- if not query :
235+ if not _is_question_style_eval_query ( query ) :
235236 continue
236237 pool .append (
237238 EvalItem (
@@ -252,7 +253,7 @@ def _sample_ood_public_queries(classification_rows: list[dict], qrel_rows: list[
252253 if source_id != "t2ranking" :
253254 continue
254255 query = str (row .get ("query" ) or "" ).strip ()
255- if not query or query in seen :
256+ if not _is_question_style_eval_query ( query ) or query in seen :
256257 continue
257258 pool .append (
258259 EvalItem (
@@ -282,7 +283,7 @@ def _sample_ood_dialogue_queries(target: int) -> list[EvalItem]:
282283 for line_index , line in enumerate (lines ):
283284 utterances = [item .strip () for item in line .split ("__eou__" ) if item .strip ()]
284285 for turn_index , utterance in enumerate (utterances ):
285- if len (utterance ) < 2 :
286+ if not _is_question_style_eval_query (utterance ):
286287 continue
287288 pool .append (
288289 EvalItem (
@@ -1060,6 +1061,18 @@ def _is_self_contained_finance(query: str) -> bool:
10601061 return any (term in lowered for term in finance_terms )
10611062
10621063
1064+ def _is_question_style_eval_query (query : str ) -> bool :
1065+ query = query .strip ()
1066+ if not query or len (query ) > MAX_EVAL_QUERY_CHARS :
1067+ return False
1068+ article_markers = ("\n " , "\r " , "\t " , "\u3000 " , "新浪财经讯" , "本报记者" , "每经记者" )
1069+ if any (marker in query for marker in article_markers ):
1070+ return False
1071+ if query .startswith ("['" ) or query .startswith ('["' ):
1072+ return False
1073+ return True
1074+
1075+
10631076def _predicted_product_type (nlu_result : dict ) -> str :
10641077 product = nlu_result .get ("product_type" ) or {}
10651078 return str (product .get ("label" ) or "" )
0 commit comments