Add files via upload#257
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a differentiated prompting and parameter strategy for various tasks, implementing Chain-of-Thought (CoT) prompts for mathematical and string tasks, updating parsing logic with fallback strategies, and switching the default annotation backend to Huawei Ascend. Key feedback points out a mismatch in task handling between main.py and method.py for CoT prompts, the use of hardcoded absolute paths that hinder portability, and a potential signature mismatch if switching back to Nvidia annotation. Additionally, the reviewer noted that hardcoded tokenizer paths bypass command-line arguments, type hints for several functions are incorrect, and the new API call lacks error handling.
| ) | ||
| return prompt | ||
|
|
||
| def build_prompt_cot(task_description: str, text2annotate: str, task_id: int) -> str: |
There was a problem hiding this comment.
There is a mismatch between main.py and method.py regarding Task 4 and Task 8.
main.pycallsbuild_prompt_cotfortask_id in [3, 4], butbuild_prompt_cothas no specific implementation fortask_id == 4and falls back to the standard prompt.build_prompt_cotcontains a specific CoT prompt implementation fortask_id == 8, butmain.pyexplicitly avoids calling it for Task 8 because 'CoT was harmful'.
Please align the implementations so that Task 4 has its CoT prompt implemented if intended, and remove or clarify the unused Task 8 CoT prompt.
| 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', |
There was a problem hiding this comment.
Using hardcoded absolute paths starting with /root/ makes the script non-portable and environment-dependent. It is highly recommended to resolve these paths dynamically relative to the script's location using os.path.
| 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', | |
| 1: os.path.abspath(os.path.join(os.path.dirname(__file__), '../data/openseek-1_closest_integers.json')), | |
| 2: os.path.abspath(os.path.join(os.path.dirname(__file__), '../data/openseek-2_count_nouns_verbs.json')), | |
| 3: os.path.abspath(os.path.join(os.path.dirname(__file__), '../data/openseek-3_collatz_conjecture.json')), | |
| 4: os.path.abspath(os.path.join(os.path.dirname(__file__), '../data/openseek-4_conala_concat_strings.json')), | |
| 5: os.path.abspath(os.path.join(os.path.dirname(__file__), '../data/openseek-5_semeval_2018_task1_tweet_sadness_detection.json')), | |
| 6: os.path.abspath(os.path.join(os.path.dirname(__file__), '../data/openseek-6_mnli_same_genre_classification.json')), | |
| 7: os.path.abspath(os.path.join(os.path.dirname(__file__), '../data/openseek-7_jeopardy_answer_generation_all.json')), | |
| 8: os.path.abspath(os.path.join(os.path.dirname(__file__), '../data/openseek-8_kernel_generation.json')), |
| # prediction = annotate(input_prompt, task_id) | ||
| # test_record['prediction'] = prediction | ||
| prediction = annotate(input_prompt) | ||
| prediction = annotate(input_prompt, task_id) |
There was a problem hiding this comment.
If the user switches the active annotation function to annotate_nvidia (by uncommenting line 9 and commenting out line 10), this call will raise a TypeError because annotate_nvidia does not accept a task_id argument. Consider updating annotate_nvidia's signature in method.py to accept task_id: int = None to maintain interface compatibility, or handle it dynamically here.
| prediction = annotate(input_prompt, task_id) | |
| prediction = annotate(input_prompt, task_id) if annotate.__name__ == 'annotate_ascend' else annotate(input_prompt) |
| # 初始化Qwen3-4B的tokenizer(自动下载/加载千问3-4B的分词器) | ||
| # 若本地已下载模型,可替换为本地路径,如 "./qwen3-4b" | ||
| tokenizer = AutoTokenizer.from_pretrained("/share/project/wuhaiming/spaces/data_agent/OpenSeek-main/openseek/competition/LongContext-ICL-Annotation/src/Qwen3-4B", trust_remote_code=True) | ||
| tokenizer = AutoTokenizer.from_pretrained("/root/Qwen3-4B", trust_remote_code=True) |
There was a problem hiding this comment.
The tokenizer path /root/Qwen3-4B is hardcoded here, which ignores the --tokenizer_path argument passed to main.py. Consider using an environment variable to allow overriding this path dynamically without changing the function signature.
| tokenizer = AutoTokenizer.from_pretrained("/root/Qwen3-4B", trust_remote_code=True) | |
| import os | |
| tokenizer_path = os.getenv("TOKENIZER_PATH", "/root/Qwen3-4B") | |
| tokenizer = AutoTokenizer.from_pretrained(tokenizer_path, trust_remote_code=True) |
| def count_answer(text: str) -> tuple[list, dict]: | ||
| """ | ||
| 提取字符串中<label>标签内的所有内容(字符串形式),统计出现次数最多的内容 | ||
| M01 优化版本:增加兜底匹配逻辑 |
There was a problem hiding this comment.
| return prediction | ||
|
|
||
| def annotate_ascend(input_prompt:str)->list[str]: | ||
| def annotate_ascend(input_prompt:str, task_id:int=None)->list[str]: |
There was a problem hiding this comment.
The function's type hint indicates it returns list[str], but the actual implementation returns a single str (or None). Please update the type hint to str | None to match the actual return type.
| def annotate_ascend(input_prompt:str, task_id:int=None)->list[str]: | |
| def annotate_ascend(input_prompt:str, task_id:int=None)->str | None: |
| response = openai.chat.completions.create( | ||
| model=model, | ||
| messages=messages, | ||
| temperature=0.7, | ||
| temperature=temperature, | ||
| top_p=0.95, | ||
| max_tokens=10_000, | ||
| max_tokens=max_tokens, | ||
| stream=False, | ||
| ) | ||
| whole_result = response.choices[0].message.content |
There was a problem hiding this comment.
The OpenAI API call lacks error handling. If a network issue, rate limit, or API error occurs, the entire evaluation loop will crash, losing progress. Consider wrapping the API call in a try-except block to handle exceptions gracefully.
| response = openai.chat.completions.create( | |
| model=model, | |
| messages=messages, | |
| temperature=0.7, | |
| temperature=temperature, | |
| top_p=0.95, | |
| max_tokens=10_000, | |
| max_tokens=max_tokens, | |
| stream=False, | |
| ) | |
| whole_result = response.choices[0].message.content | |
| try: | |
| response = openai.chat.completions.create( | |
| model=model, | |
| messages=messages, | |
| temperature=temperature, | |
| top_p=0.95, | |
| max_tokens=max_tokens, | |
| stream=False, | |
| ) | |
| whole_result = response.choices[0].message.content | |
| except Exception as e: | |
| print(f"Error calling OpenAI API: {e}") | |
| whole_result = "" |
No description provided.