diff --git a/openseek/competition/LongContext-ICL-Annotation/src/main.py b/openseek/competition/LongContext-ICL-Annotation/src/main.py
index c2949795..42718478 100644
--- a/openseek/competition/LongContext-ICL-Annotation/src/main.py
+++ b/openseek/competition/LongContext-ICL-Annotation/src/main.py
@@ -4,20 +4,20 @@
# from method import build_prompt, select_examples, annotate
-from method import build_prompt, select_examples
+from method import build_prompt, select_examples, select_examples_M05, select_examples_M19, select_examples_M20, select_examples_M09, select_examples_M10, select_examples_M11, build_prompt_cot, build_prompt_by_task_type
-from method import annotate_nvidia as annotate # For Nvidia GPU
-# from method import annotate_ascend as annotate # For Huawei Ascend
+# from method import annotate_nvidia as annotate # For Nvidia GPU
+from method import annotate_ascend as annotate # For Huawei Ascend
TASK_FILES = {
- 1: './data/openseek-1_closest_integers.json',
- 2: './data/openseek-2_count_nouns_verbs.json',
- 3: './data/openseek-3_collatz_conjecture.json',
- 4: './data/openseek-4_conala_concat_strings.json',
- 5: './data/openseek-5_semeval_2018_task1_tweet_sadness_detection.json',
- 6: './data/openseek-6_mnli_same_genre_classification.json',
- 7: './data/openseek-7_jeopardy_answer_generation_all.json',
- 8: '../data/openseek-8_kernel_generation.json',
+ 1: '/root/OpenSeek/openseek/competition/LongContext-ICL-Annotation/data/openseek-1_closest_integers.json',
+ 2: '/root/OpenSeek/openseek/competition/LongContext-ICL-Annotation/data/openseek-2_count_nouns_verbs.json',
+ 3: '/root/OpenSeek/openseek/competition/LongContext-ICL-Annotation/data/openseek-3_collatz_conjecture.json',
+ 4: '/root/OpenSeek/openseek/competition/LongContext-ICL-Annotation/data/openseek-4_conala_concat_strings.json',
+ 5: '/root/OpenSeek/openseek/competition/LongContext-ICL-Annotation/data/openseek-5_semeval_2018_task1_tweet_sadness_detection.json',
+ 6: '/root/OpenSeek/openseek/competition/LongContext-ICL-Annotation/data/openseek-6_mnli_same_genre_classification.json',
+ 7: '/root/OpenSeek/openseek/competition/LongContext-ICL-Annotation/data/openseek-7_jeopardy_answer_generation_all.json',
+ 8: '/root/OpenSeek/openseek/competition/LongContext-ICL-Annotation/data/openseek-8_kernel_generation.json',
}
def parser_args():
@@ -30,7 +30,7 @@ def parser_args():
default='../outputs/',
help='Prefix path to save the evaluation logs.')
parser.add_argument('--tokenizer_path', type=str,
- default='/share/project/wuhaiming/spaces/data_agent/OpenSeek-main/openseek/competition/LongContext-ICL-Annotation/src/Qwen3-4B')
+ default='/root/Qwen3-4B')
args = parser.parse_args()
return args
@@ -48,7 +48,7 @@ def evaluate(task_id:int,
task_name = task_dict['task_name']
task_description = task_dict['Definition'][0]
- icl_examples = task_dict['examples'][:100]
+ icl_examples = task_dict['examples'][:50]
test_samples = task_dict['test_samples']
version = 1
@@ -62,7 +62,7 @@ def evaluate(task_id:int,
pass
examples_str = None
- for test_sample in tqdm(test_samples, desc=f'Evaluation on Task {task_id}: {task_name}'):
+ for sample_idx, test_sample in enumerate(tqdm(test_samples, desc=f'Evaluation on Task {task_id}: {task_name}')):
test_record = dict()
test_sample_id = test_sample['id']
@@ -70,18 +70,23 @@ def evaluate(task_id:int,
text2annotate = test_sample['input']
- prompt = build_prompt(task_description, text2annotate)
+
+ # M03优化:使用任务分型Prompt路由系统
+ # 根据任务类型自动选择最合适的prompt策略
+ prompt = build_prompt_by_task_type(task_id, task_description, text2annotate)
+
if examples_str is None:
- examples_str = select_examples(icl_examples, task_description, text2annotate)
+ # M11优化:使用Task 7 Jeopardy线索拆解策略
+ examples_str = select_examples_M11(icl_examples, task_description, text2annotate, task_id, sample_idx)
input_prompt = prompt.replace("[[EXAMPLES]]\n\n", examples_str+'\n\n')
# tokenized_input = qwen_tokenizer(input_prompt, return_tensors="pt")
# if tokenized_input['input_ids'].shape[1] > max_input_length:
# test_record['prediction'] = None
# else:
- # prediction = annotate(input_prompt)
+ # prediction = annotate(input_prompt, task_id)
# test_record['prediction'] = prediction
- prediction = annotate(input_prompt)
+ prediction = annotate(input_prompt, task_id)
test_record['prediction'] = prediction
with open(output_file, 'a') as f:
f.write(json.dumps(test_record)+'\n')
diff --git a/openseek/competition/LongContext-ICL-Annotation/src/method.py b/openseek/competition/LongContext-ICL-Annotation/src/method.py
index 386daf22..e426f4c5 100644
--- a/openseek/competition/LongContext-ICL-Annotation/src/method.py
+++ b/openseek/competition/LongContext-ICL-Annotation/src/method.py
@@ -46,6 +46,185 @@ def build_prompt____(task_description: str, text2annotate: str) -> str:
)
return prompt
+def build_prompt_by_task_type(task_id: int, task_description: str, text2annotate: str) -> str:
+ """
+ M03优化版本:任务分型Prompt路由方案
+ 根据任务类型选择最合适的prompt策略
+ """
+
+ # 任务类型分类
+ math_tasks = [1, 3] # Task 1: Closest Integers, Task 3: Collatz Conjecture
+ string_tasks = [2, 4] # Task 2: Count Nouns & Verbs, Task 4: Concat Strings
+ classification_tasks = [5, 6] # Task 5: Tweet Sadness, Task 6: MNLI
+ generation_tasks = [7, 8] # Task 7: Jeopardy Answers, Task 8: Kernel Generation
+
+ if task_id in math_tasks:
+ return build_prompt_math(task_description, text2annotate)
+ elif task_id in string_tasks:
+ return build_prompt_string(task_description, text2annotate)
+ elif task_id in classification_tasks:
+ return build_prompt_classification(task_description, text2annotate)
+ elif task_id in generation_tasks:
+ return build_prompt_generation(task_description, text2annotate)
+ else:
+ return build_prompt(task_description, text2annotate)
+
+def build_prompt_math(task_description: str, text2annotate: str) -> str:
+ """
+ M03优化:数学推理任务的专用prompt
+ 针对Task 1 (Closest Integers)和Task 3 (Collatz Conjecture)
+ """
+ prompt = (
+ "### Role Definition\n"
+ "You are a mathematical reasoning expert specializing in numerical analysis and mathematical problem-solving. "
+ "You excel at systematic step-by-step reasoning and precise calculations.\n\n"
+
+ "### Core Task\n"
+ f"{task_description}\n\n"
+
+ "### Critical Mathematical Reasoning Guidelines\n"
+ "1. **Step-by-Step Analysis**: For mathematical problems, show your reasoning:\n"
+ " - Break down the problem into clear steps\n"
+ " - Verify each calculation carefully\n"
+ " - Explain the logic behind each step\n\n"
+
+ "2. **Precision Requirements**:\n"
+ " - Ensure all calculations are accurate\n"
+ " - Double-check numerical operations\n"
+ " - Pay attention to edge cases\n\n"
+
+ "3. **Output Format**: Follow this structure:\n"
+ " **Analysis:** [Your step-by-step reasoning]\n"
+ " **Answer:** \n\n"
+
+ "### Examples (Must Be Fully Followed)\n"
+ "[[EXAMPLES]]\n\n"
+
+ "### Mathematical Problem to Solve\n"
+ f"{text2annotate}\n\n"
+
+ "### Final Answer\n"
+ "Provide your analysis and final numerical answer in