rai-sant commited on
Commit
6b384dd
·
1 Parent(s): 361e067

Refactored __init__.py to include DataArguments and adjusted imports

Browse files
src/open_r1/.DS_Store CHANGED
Binary files a/src/open_r1/.DS_Store and b/src/open_r1/.DS_Store differ
 
src/open_r1/__init__.py CHANGED
@@ -15,13 +15,8 @@
15
  __version__ = "0.3.0.dev0"
16
 
17
  # Import necessary modules and classes
18
- from .configs import (
19
- DataArguments,
20
- DPOConfig,
21
- H4ArgumentParser,
22
- ModelArguments,
23
- SFTConfig,
24
- )
25
  from .data import apply_chat_template, get_datasets
26
  from .decontaminate import decontaminate_humaneval
27
  from .model_utils import (
 
15
  __version__ = "0.3.0.dev0"
16
 
17
  # Import necessary modules and classes
18
+ from .configs.data_arguments import DataArguments # Ensure correct path
19
+ from .configs import DPOConfig, H4ArgumentParser, ModelArguments, SFTConfig
 
 
 
 
 
20
  from .data import apply_chat_template, get_datasets
21
  from .decontaminate import decontaminate_humaneval
22
  from .model_utils import (
src/open_r1/configs/data_arguments.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class DataArguments:
2
+ """
3
+ A placeholder class for DataArguments.
4
+ Add relevant arguments and methods as needed.
5
+ """
6
+
7
+ def __init__(self, dataset_path: str = None, max_samples: int = 1000):
8
+ self.dataset_path = dataset_path
9
+ self.max_samples = max_samples
10
+
11
+ def __repr__(self):
12
+ return f"DataArguments(dataset_path={self.dataset_path}, max_samples={self.max_samples})"
src/open_r1/evaluate.py CHANGED
@@ -1,103 +1,12 @@
1
- # Copyright 2025 The HuggingFace Team. All rights reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- """Custom evaluation tasks for LightEval."""
16
-
17
- from lighteval.metrics.dynamic_metrics import (
18
- ExprExtractionConfig,
19
- LatexExtractionConfig,
20
- multilingual_extractive_match_metric,
21
- )
22
- from lighteval.tasks.lighteval_task import LightevalTaskConfig
23
- from lighteval.tasks.requests import Doc
24
- from lighteval.utils.language import Language
25
-
26
-
27
- latex_gold_metric = multilingual_extractive_match_metric(
28
- language=Language.ENGLISH,
29
- fallback_mode="first_match",
30
- precision=5,
31
- gold_extraction_target=(LatexExtractionConfig(),),
32
- pred_extraction_target=(ExprExtractionConfig(), LatexExtractionConfig()),
33
- aggregation_function=max,
34
- )
35
-
36
- expr_gold_metric = multilingual_extractive_match_metric(
37
- language=Language.ENGLISH,
38
- fallback_mode="first_match",
39
- precision=5,
40
- gold_extraction_target=(ExprExtractionConfig(),),
41
- pred_extraction_target=(ExprExtractionConfig(), LatexExtractionConfig()),
42
- aggregation_function=max,
43
- )
44
-
45
-
46
- def prompt_fn(line, task_name: str = None):
47
- """Assumes the model is either prompted to emit \\boxed{answer} or does so automatically"""
48
- return Doc(
49
- task_name=task_name,
50
- query=line["problem"],
51
- choices=[line["solution"]],
52
- gold_index=0,
53
- )
54
-
55
-
56
- def aime_prompt_fn(line, task_name: str = None):
57
- return Doc(
58
- task_name=task_name,
59
- query=line["problem"],
60
- choices=[line["answer"]],
61
- gold_index=0,
62
- )
63
-
64
-
65
- # Define tasks
66
- aime24 = LightevalTaskConfig(
67
- name="aime24",
68
- suite=["custom"],
69
- prompt_function=aime_prompt_fn,
70
- hf_repo="HuggingFaceH4/aime_2024",
71
- hf_subset="default",
72
- hf_avail_splits=["train"],
73
- evaluation_splits=["train"],
74
- few_shots_split=None,
75
- few_shots_select=None,
76
- generation_size=32768,
77
- metric=[expr_gold_metric],
78
- version=1,
79
- )
80
- math_500 = LightevalTaskConfig(
81
- name="math_500",
82
- suite=["custom"],
83
- prompt_function=prompt_fn,
84
- hf_repo="HuggingFaceH4/MATH-500",
85
- hf_subset="default",
86
- hf_avail_splits=["test"],
87
- evaluation_splits=["test"],
88
- few_shots_split=None,
89
- few_shots_select=None,
90
- generation_size=32768,
91
- metric=[latex_gold_metric],
92
- version=1,
93
- )
94
-
95
- # Add tasks to the table
96
- TASKS_TABLE = []
97
- TASKS_TABLE.append(aime24)
98
- TASKS_TABLE.append(math_500)
99
-
100
- # MODULE LOGIC
101
- if __name__ == "__main__":
102
- print([t["name"] for t in TASKS_TABLE])
103
- print(len(TASKS_TABLE))
 
1
+ class DataArguments:
2
+ """
3
+ A placeholder class for DataArguments.
4
+ Add relevant arguments and methods as needed.
5
+ """
6
+
7
+ def __init__(self, dataset_path: str = None, max_samples: int = 1000):
8
+ self.dataset_path = dataset_path
9
+ self.max_samples = max_samples
10
+
11
+ def __repr__(self):
12
+ return f"DataArguments(dataset_path={self.dataset_path}, max_samples={self.max_samples})"