-
Notifications
You must be signed in to change notification settings - Fork 91
Add files via upload #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tongyboez
wants to merge
1
commit into
FlagAI-Open:main
Choose a base branch
from
tongyboez:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add files via upload #256
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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, 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,26 +62,31 @@ 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'] | ||||||
| test_record['test_sample_id'] = test_sample_id | ||||||
|
|
||||||
|
|
||||||
| 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) | ||||||
| # M05优化:使用相似度+多样性混合检索策略 | ||||||
| examples_str = select_examples_M05(icl_examples, task_description, text2annotate, task_id, sample_idx) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pass the pre-loaded
Suggested change
|
||||||
| 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') | ||||||
|
|
||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoding absolute paths starting with
"/root/OpenSeek/..."makes the codebase non-portable and environment-dependent. It is better to resolve the paths dynamically relative to the script's directory.