chen459664 commited on
Commit
0b92299
·
verified ·
1 Parent(s): 9397c2d

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. lm-evaluation-harness/lm_eval/tasks/afrobench/xlsum/prompt_3/xlsum_swahili.yaml +10 -0
  2. lm-evaluation-harness/lm_eval/tasks/afrobench/xlsum/prompt_3/xlsum_telugu.yaml +10 -0
  3. lm-evaluation-harness/lm_eval/tasks/afrobench/xlsum/prompt_3/xlsum_tigrinya.yaml +10 -0
  4. lm-evaluation-harness/lm_eval/tasks/agieval/gaokao-history.yaml +3 -0
  5. lm-evaluation-harness/lm_eval/tasks/agieval/gaokao-mathcloze.yaml +22 -0
  6. lm-evaluation-harness/lm_eval/tasks/agieval/gaokao-mathqa.yaml +3 -0
  7. lm-evaluation-harness/lm_eval/tasks/agieval/gaokao-physics.yaml +3 -0
  8. lm-evaluation-harness/lm_eval/tasks/agieval/jec-qa-ca.yaml +3 -0
  9. lm-evaluation-harness/lm_eval/tasks/agieval/jec-qa-kd.yaml +3 -0
  10. lm-evaluation-harness/lm_eval/tasks/agieval/logiqa-en.yaml +3 -0
  11. lm-evaluation-harness/lm_eval/tasks/agieval/logiqa-zh.yaml +3 -0
  12. lm-evaluation-harness/lm_eval/tasks/agieval/lsat-ar.yaml +3 -0
  13. lm-evaluation-harness/lm_eval/tasks/agieval/lsat-lr.yaml +3 -0
  14. lm-evaluation-harness/lm_eval/tasks/agieval/lsat-rc.yaml +3 -0
  15. lm-evaluation-harness/lm_eval/tasks/agieval/math.yaml +22 -0
  16. lm-evaluation-harness/lm_eval/tasks/agieval/sat-en-without-passage.yaml +3 -0
  17. lm-evaluation-harness/lm_eval/tasks/agieval/sat-en.yaml +3 -0
  18. lm-evaluation-harness/lm_eval/tasks/agieval/sat-math.yaml +3 -0
  19. lm-evaluation-harness/lm_eval/tasks/agieval/utils.py +274 -0
  20. lm-evaluation-harness/lm_eval/tasks/alghafa/copa_ar/README.md +40 -0
  21. lm-evaluation-harness/lm_eval/tasks/alghafa/copa_ar/copa_ar.yaml +21 -0
  22. lm-evaluation-harness/lm_eval/tasks/alghafa/piqa_ar/README.md +43 -0
  23. lm-evaluation-harness/lm_eval/tasks/alghafa/piqa_ar/piqa_ar.yaml +21 -0
  24. lm-evaluation-harness/lm_eval/tasks/anli/README.md +56 -0
  25. lm-evaluation-harness/lm_eval/tasks/anli/anli_r1.yaml +26 -0
  26. lm-evaluation-harness/lm_eval/tasks/anli/anli_r2.yaml +5 -0
  27. lm-evaluation-harness/lm_eval/tasks/anli/anli_r3.yaml +5 -0
  28. lm-evaluation-harness/lm_eval/tasks/arab_culture/README.md +70 -0
  29. lm-evaluation-harness/lm_eval/tasks/arab_culture/_arab_culture.yaml +12 -0
  30. lm-evaluation-harness/lm_eval/tasks/arab_culture/_arab_culture_gulf.yaml +10 -0
  31. lm-evaluation-harness/lm_eval/tasks/arab_culture/_arab_culture_levant.yaml +10 -0
  32. lm-evaluation-harness/lm_eval/tasks/arab_culture/_arab_culture_nile_valley.yaml +10 -0
  33. lm-evaluation-harness/lm_eval/tasks/arab_culture/_arab_culture_north_africa.yaml +10 -0
  34. lm-evaluation-harness/lm_eval/tasks/arab_culture/_default_arab_culture_mcq_template_yaml +19 -0
  35. lm-evaluation-harness/lm_eval/tasks/arab_culture/_generate_configs.py +122 -0
  36. lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_algeria.yaml +5 -0
  37. lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_egypt.yaml +5 -0
  38. lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_jordan.yaml +5 -0
  39. lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_ksa.yaml +5 -0
  40. lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_lebanon.yaml +5 -0
  41. lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_libya.yaml +5 -0
  42. lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_morocco.yaml +5 -0
  43. lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_palestine.yaml +5 -0
  44. lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_sudan.yaml +5 -0
  45. lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_syria.yaml +5 -0
  46. lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_tunisia.yaml +5 -0
  47. lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_uae.yaml +5 -0
  48. lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_yemen.yaml +5 -0
  49. lm-evaluation-harness/lm_eval/tasks/arab_culture/prompts.py +73 -0
  50. lm-evaluation-harness/lm_eval/tasks/arab_culture/utils_mcq.py +112 -0
lm-evaluation-harness/lm_eval/tasks/afrobench/xlsum/prompt_3/xlsum_swahili.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generated by utils.py
2
+ dataset_name: swahili
3
+ doc_to_target: '{{summary}}'
4
+ doc_to_text: 'You are an advanced Summarizer, a specialized assistant designed to
5
+ summarize documents in Swahili. Your main goal is to ensure summaries are concise
6
+ and informative. Ensure you return the summary only and nothing else.
7
+
8
+ Document: {{''text''}}\nSummary: '
9
+ include: xlsum
10
+ task: xlsum_swahili_prompt_3
lm-evaluation-harness/lm_eval/tasks/afrobench/xlsum/prompt_3/xlsum_telugu.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generated by utils.py
2
+ dataset_name: telugu
3
+ doc_to_target: '{{summary}}'
4
+ doc_to_text: 'You are an advanced Summarizer, a specialized assistant designed to
5
+ summarize documents in Telugu. Your main goal is to ensure summaries are concise
6
+ and informative. Ensure you return the summary only and nothing else.
7
+
8
+ Document: {{''text''}}\nSummary: '
9
+ include: xlsum
10
+ task: xlsum_telugu_prompt_3
lm-evaluation-harness/lm_eval/tasks/afrobench/xlsum/prompt_3/xlsum_tigrinya.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generated by utils.py
2
+ dataset_name: tigrinya
3
+ doc_to_target: '{{summary}}'
4
+ doc_to_text: 'You are an advanced Summarizer, a specialized assistant designed to
5
+ summarize documents in Tigrinya. Your main goal is to ensure summaries are concise
6
+ and informative. Ensure you return the summary only and nothing else.
7
+
8
+ Document: {{''text''}}\nSummary: '
9
+ include: xlsum
10
+ task: xlsum_tigrinya_prompt_3
lm-evaluation-harness/lm_eval/tasks/agieval/gaokao-history.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: aqua-rat.yaml
2
+ task: agieval_gaokao_history
3
+ dataset_path: hails/agieval-gaokao-history
lm-evaluation-harness/lm_eval/tasks/agieval/gaokao-mathcloze.yaml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ task: agieval_gaokao_mathcloze
2
+ dataset_path: hails/agieval-gaokao-mathcloze
3
+ dataset_name: null
4
+ output_type: generate_until
5
+ training_split: null
6
+ validation_split: null
7
+ test_split: test
8
+ doc_to_text: "{{query}}"
9
+ doc_to_target: "{{answer}}"
10
+ process_results: !function utils.process_results
11
+ generation_kwargs:
12
+ max_gen_toks: 32
13
+ do_sample: False
14
+ temperature: 0.0
15
+ until:
16
+ - "Q:"
17
+ metric_list:
18
+ - metric: acc
19
+ aggregation: mean
20
+ higher_is_better: true
21
+ metadata:
22
+ version: 1.0
lm-evaluation-harness/lm_eval/tasks/agieval/gaokao-mathqa.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: aqua-rat.yaml
2
+ task: agieval_gaokao_mathqa
3
+ dataset_path: hails/agieval-gaokao-mathqa
lm-evaluation-harness/lm_eval/tasks/agieval/gaokao-physics.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: aqua-rat.yaml
2
+ task: agieval_gaokao_physics
3
+ dataset_path: hails/agieval-gaokao-physics
lm-evaluation-harness/lm_eval/tasks/agieval/jec-qa-ca.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: aqua-rat.yaml
2
+ task: agieval_jec_qa_ca
3
+ dataset_path: hails/agieval-jec-qa-ca
lm-evaluation-harness/lm_eval/tasks/agieval/jec-qa-kd.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: aqua-rat.yaml
2
+ task: agieval_jec_qa_kd
3
+ dataset_path: hails/agieval-jec-qa-kd
lm-evaluation-harness/lm_eval/tasks/agieval/logiqa-en.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: aqua-rat.yaml
2
+ task: agieval_logiqa_en
3
+ dataset_path: hails/agieval-logiqa-en
lm-evaluation-harness/lm_eval/tasks/agieval/logiqa-zh.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: aqua-rat.yaml
2
+ task: agieval_logiqa_zh
3
+ dataset_path: hails/agieval-logiqa-zh
lm-evaluation-harness/lm_eval/tasks/agieval/lsat-ar.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: aqua-rat.yaml
2
+ task: agieval_lsat_ar
3
+ dataset_path: hails/agieval-lsat-ar
lm-evaluation-harness/lm_eval/tasks/agieval/lsat-lr.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: aqua-rat.yaml
2
+ task: agieval_lsat_lr
3
+ dataset_path: hails/agieval-lsat-lr
lm-evaluation-harness/lm_eval/tasks/agieval/lsat-rc.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: aqua-rat.yaml
2
+ task: agieval_lsat_rc
3
+ dataset_path: hails/agieval-lsat-rc
lm-evaluation-harness/lm_eval/tasks/agieval/math.yaml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ task: agieval_math
2
+ dataset_path: hails/agieval-math
3
+ dataset_name: null
4
+ output_type: generate_until
5
+ training_split: null
6
+ validation_split: null
7
+ test_split: test
8
+ doc_to_text: "{{query}}"
9
+ doc_to_target: "{{answer}}"
10
+ process_results: !function utils.process_results
11
+ generation_kwargs:
12
+ max_gen_toks: 32
13
+ do_sample: False
14
+ temperature: 0.0
15
+ until:
16
+ - "Q:"
17
+ metric_list:
18
+ - metric: acc
19
+ aggregation: mean
20
+ higher_is_better: true
21
+ metadata:
22
+ version: 1.0
lm-evaluation-harness/lm_eval/tasks/agieval/sat-en-without-passage.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: aqua-rat.yaml
2
+ task: agieval_sat_en_without_passage
3
+ dataset_path: hails/agieval-sat-en-without-passage
lm-evaluation-harness/lm_eval/tasks/agieval/sat-en.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: aqua-rat.yaml
2
+ task: agieval_sat_en
3
+ dataset_path: hails/agieval-sat-en
lm-evaluation-harness/lm_eval/tasks/agieval/sat-math.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include: aqua-rat.yaml
2
+ task: agieval_sat_math
3
+ dataset_path: hails/agieval-sat-math
lm-evaluation-harness/lm_eval/tasks/agieval/utils.py ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Answer parsing and normalization code, from
2
+ # https://github.com/ruixiangcui/AGIEval/blob/main/src/
3
+ # math_equivalence.py and post_process.py
4
+ import re
5
+ from typing import Dict, List
6
+
7
+ import numpy as np
8
+
9
+
10
+ def parse_math_answer(raw_string):
11
+ def remove_boxed(s):
12
+ left = "\\boxed{"
13
+ try:
14
+ assert s[: len(left)] == left
15
+ assert s[-1] == "}"
16
+ answer = s[len(left) : -1]
17
+ if "=" in answer:
18
+ answer = answer.split("=")[-1].lstrip(" ")
19
+ return answer
20
+ except Exception:
21
+ return None
22
+
23
+ def last_boxed_only_string(string):
24
+ idx = string.rfind("\\boxed")
25
+ if idx < 0:
26
+ idx = string.rfind("\\fbox")
27
+ if idx < 0:
28
+ return None
29
+ i = idx
30
+ right_brace_idx = None
31
+ num_left_braces_open = 0
32
+ while i < len(string):
33
+ if string[i] == "{":
34
+ num_left_braces_open += 1
35
+ if string[i] == "}":
36
+ num_left_braces_open -= 1
37
+ if num_left_braces_open == 0:
38
+ right_brace_idx = i
39
+ break
40
+ i += 1
41
+
42
+ if right_brace_idx is None:
43
+ retval = None
44
+ else:
45
+ retval = string[idx : right_brace_idx + 1]
46
+
47
+ return retval
48
+
49
+ def get_answer_with_dollar_sign(s):
50
+ first_pattern = "\$(.*)\$"
51
+ last_match = None
52
+ matches = re.findall(first_pattern, s)
53
+ if matches:
54
+ last_match = matches[-1]
55
+ if "=" in last_match:
56
+ last_match = last_match.split("=")[-1].lstrip(" ")
57
+ return last_match
58
+
59
+ def get_answer_without_dollar_sign(s):
60
+ last_match = None
61
+ if "=" in s:
62
+ last_match = s.split("=")[-1].lstrip(" ").rstrip(".")
63
+ if "\\n" in last_match:
64
+ last_match = last_match.split("\\n")[0]
65
+ else:
66
+ pattern = "(?:\\$)?\d+(?:\.\d+)?(?![\w\d])"
67
+ matches = re.findall(pattern, s)
68
+ if matches:
69
+ last_match = matches[-1]
70
+ return last_match
71
+
72
+ if "\\boxed" in raw_string:
73
+ answer = remove_boxed(last_boxed_only_string(raw_string))
74
+ else:
75
+ answer = get_answer_with_dollar_sign(raw_string)
76
+ if not answer:
77
+ answer = get_answer_without_dollar_sign(raw_string)
78
+ return answer
79
+
80
+
81
+ # code from https://github.com/hendrycks/math/blob/main/modeling/math_equivalence.py
82
+ def _fix_fracs(string):
83
+ substrs = string.split("\\frac")
84
+ new_str = substrs[0]
85
+ if len(substrs) > 1:
86
+ substrs = substrs[1:]
87
+ for substr in substrs:
88
+ new_str += "\\frac"
89
+ if substr[0] == "{":
90
+ new_str += substr
91
+ else:
92
+ try:
93
+ assert len(substr) >= 2
94
+ except Exception:
95
+ return string
96
+ a = substr[0]
97
+ b = substr[1]
98
+ if b != "{":
99
+ if len(substr) > 2:
100
+ post_substr = substr[2:]
101
+ new_str += "{" + a + "}{" + b + "}" + post_substr
102
+ else:
103
+ new_str += "{" + a + "}{" + b + "}"
104
+ else:
105
+ if len(substr) > 2:
106
+ post_substr = substr[2:]
107
+ new_str += "{" + a + "}" + b + post_substr
108
+ else:
109
+ new_str += "{" + a + "}" + b
110
+ string = new_str
111
+ return string
112
+
113
+
114
+ def _fix_a_slash_b(string):
115
+ if len(string.split("/")) != 2:
116
+ return string
117
+ a = string.split("/")[0]
118
+ b = string.split("/")[1]
119
+ try:
120
+ a = int(a)
121
+ b = int(b)
122
+ assert string == "{}/{}".format(a, b)
123
+ new_string = "\\frac{" + str(a) + "}{" + str(b) + "}"
124
+ return new_string
125
+ except Exception:
126
+ return string
127
+
128
+
129
+ def _remove_right_units(string):
130
+ # "\\text{ " only ever occurs (at least in the val set) when describing units
131
+ if "\\text{ " in string:
132
+ splits = string.split("\\text{ ")
133
+ assert len(splits) == 2
134
+ return splits[0]
135
+ else:
136
+ return string
137
+
138
+
139
+ def _fix_sqrt(string):
140
+ if "\\sqrt" not in string:
141
+ return string
142
+ splits = string.split("\\sqrt")
143
+ new_string = splits[0]
144
+ for split in splits[1:]:
145
+ if split[0] != "{":
146
+ a = split[0]
147
+ new_substr = "\\sqrt{" + a + "}" + split[1:]
148
+ else:
149
+ new_substr = "\\sqrt" + split
150
+ new_string += new_substr
151
+ return new_string
152
+
153
+
154
+ def _strip_string(string):
155
+ # linebreaks
156
+ string = string.replace("\n", "")
157
+ # print(string)
158
+
159
+ # remove inverse spaces
160
+ string = string.replace("\\!", "")
161
+ # print(string)
162
+
163
+ # replace \\ with \
164
+ string = string.replace("\\\\", "\\")
165
+ # print(string)
166
+
167
+ # replace tfrac and dfrac with frac
168
+ string = string.replace("tfrac", "frac")
169
+ string = string.replace("dfrac", "frac")
170
+ # print(string)
171
+
172
+ # remove \left and \right
173
+ string = string.replace("\\left", "")
174
+ string = string.replace("\\right", "")
175
+ # print(string)
176
+
177
+ # Remove circ (degrees)
178
+ string = string.replace("^{\\circ}", "")
179
+ string = string.replace("^\\circ", "")
180
+
181
+ # remove dollar signs
182
+ string = string.replace("\\$", "")
183
+
184
+ # remove units (on the right)
185
+ string = _remove_right_units(string)
186
+
187
+ # remove percentage
188
+ string = string.replace("\\%", "")
189
+ string = string.replace("\%", "")
190
+
191
+ # " 0." equivalent to " ." and "{0." equivalent to "{." Alternatively, add "0" if "." is the start of the string
192
+ string = string.replace(" .", " 0.")
193
+ string = string.replace("{.", "{0.")
194
+ # if empty, return empty string
195
+ if len(string) == 0:
196
+ return string
197
+ if string[0] == ".":
198
+ string = "0" + string
199
+
200
+ # to consider: get rid of e.g. "k = " or "q = " at beginning
201
+ if len(string.split("=")) == 2:
202
+ if len(string.split("=")[0]) <= 2:
203
+ string = string.split("=")[1]
204
+
205
+ # fix sqrt3 --> sqrt{3}
206
+ string = _fix_sqrt(string)
207
+
208
+ # remove spaces
209
+ string = string.replace(" ", "")
210
+
211
+ # \frac1b or \frac12 --> \frac{1}{b} and \frac{1}{2}, etc. Even works with \frac1{72} (but not \frac{72}1). Also does a/b --> \\frac{a}{b}
212
+ string = _fix_fracs(string)
213
+
214
+ # manually change 0.5 --> \frac{1}{2}
215
+ if string == "0.5":
216
+ string = "\\frac{1}{2}"
217
+
218
+ # NOTE: X/Y changed to \frac{X}{Y} in dataset, but in simple cases fix in case the model output is X/Y
219
+ string = _fix_a_slash_b(string)
220
+
221
+ return string
222
+
223
+
224
+ def is_equiv(str1, str2, verbose=False):
225
+ if str1 is None and str2 is None:
226
+ print("WARNING: Both None")
227
+ return True
228
+ if str1 is None or str2 is None:
229
+ return False
230
+
231
+ str1, str2 = parse_math_answer(str1), parse_math_answer(str2)
232
+
233
+ try:
234
+ ss1 = _strip_string(str1)
235
+ ss2 = _strip_string(str2)
236
+ if verbose:
237
+ print(ss1, ss2)
238
+ return ss1 == ss2
239
+ except Exception:
240
+ return str1 == str2
241
+
242
+
243
+ def process_results(doc: dict, results: List[str]) -> Dict[str, int]:
244
+ candidate = results[0]
245
+
246
+ gold = doc["answer"]
247
+
248
+ if not gold:
249
+ print(doc, candidate, gold)
250
+ if is_equiv(candidate, gold):
251
+ retval = 1
252
+ else:
253
+ retval = 0
254
+
255
+ results = {
256
+ "acc": retval,
257
+ }
258
+ return results
259
+
260
+
261
+ # use a custom process_results() function, because AGIEval can have multiple valid answers
262
+ def process_results_mcqa(doc, results):
263
+ results = [result[0] for result in results]
264
+
265
+ gold = doc["gold"]
266
+
267
+ acc = 1.0 if int(np.argmax(results)) in gold else 0.0
268
+ completion_len = np.array([float(len(i)) for i in doc["choices"]])
269
+ acc_norm = 1.0 if int(np.argmax(results / completion_len)) in gold else 0.0
270
+
271
+ return {
272
+ "acc": acc,
273
+ "acc_norm": acc_norm,
274
+ }
lm-evaluation-harness/lm_eval/tasks/alghafa/copa_ar/README.md ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Arabic COPA
2
+
3
+ ### Paper
4
+
5
+ Original Title: `COPA`
6
+
7
+
8
+
9
+ The Choice Of Plausible Alternatives (COPA) evaluation provides researchers with a tool for assessing progress in open-domain commonsense causal reasoning.
10
+
11
+ [Homepage](https://people.ict.usc.edu/~gordon/copa.html)
12
+
13
+ AlGhafa has translated this dataset to Arabic[AlGafa](https://aclanthology.org/2023.arabicnlp-1.21.pdf)
14
+
15
+ The link to the Arabic version of the dataset [PICA](https://gitlab.com/tiiuae/alghafa/-/tree/main/arabic-eval/copa_ar)
16
+
17
+ ### Citation
18
+
19
+ ### Groups and Tasks
20
+
21
+ #### Groups
22
+
23
+ * Not part of a group yet.
24
+
25
+ #### Tasks
26
+
27
+ * `copa_ar`
28
+
29
+ ### Checklist
30
+
31
+ For adding novel benchmarks/datasets to the library:
32
+ * [x] Is the task an existing benchmark in the literature?
33
+ * [x] Have you referenced the original paper that introduced the task?
34
+ * [x] If yes, does the original paper provide a reference implementation? If so, have you checked against the reference implementation and documented how to run such a test?
35
+
36
+
37
+ If other tasks on this dataset are already supported:
38
+ * [x] Is the "Main" variant of this task clearly denoted?
39
+ * [x] Have you provided a short sentence in a README on what each new variant adds / evaluates?
40
+ * [x] Have you noted which, if any, published evaluation setups are matched by this variant?
lm-evaluation-harness/lm_eval/tasks/alghafa/copa_ar/copa_ar.yaml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ task: copa_ar
2
+ dataset_path: Hennara/copa_ar
3
+ dataset_name: null
4
+ output_type: multiple_choice
5
+ training_split: null
6
+ validation_split: null
7
+ test_split: test
8
+ doc_to_text: "السؤال: {{query}}\nالجواب:"
9
+ doc_to_choice: "{{[sol1, sol2]}}"
10
+ doc_to_target: label
11
+ should_decontaminate: true
12
+ doc_to_decontamination_query: query
13
+ metric_list:
14
+ - metric: acc
15
+ aggregation: mean
16
+ higher_is_better: true
17
+ - metric: acc_norm
18
+ aggregation: mean
19
+ higher_is_better: true
20
+ metadata:
21
+ version: 1.0
lm-evaluation-harness/lm_eval/tasks/alghafa/piqa_ar/README.md ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Arabic PIQA
2
+
3
+ ### Paper
4
+
5
+ Original Title: `PIQA: Reasoning about Physical Commonsense in Natural Language`
6
+
7
+ Original paper: [PICA](https://arxiv.org/abs/1911.11641)
8
+
9
+ Physical Interaction: Question Answering (PIQA) is a physical commonsense
10
+ reasoning and a corresponding benchmark dataset. PIQA was designed to investigate
11
+ the physical knowledge of existing models. To what extent are current approaches
12
+ actually learning about the world?
13
+
14
+ [Homepage](https://yonatanbisk.com/piqa)
15
+
16
+ AlGhafa has translated this dataset to Arabic[AlGafa](https://aclanthology.org/2023.arabicnlp-1.21.pdf)
17
+
18
+ The link to the Arabic version of the dataset [PICA](https://gitlab.com/tiiuae/alghafa/-/tree/main/arabic-eval/pica_ar)
19
+
20
+ ### Citation
21
+
22
+ ### Groups and Tasks
23
+
24
+ #### Groups
25
+
26
+ * Not part of a group yet.
27
+
28
+ #### Tasks
29
+
30
+ * `piqa_ar`
31
+
32
+ ### Checklist
33
+
34
+ For adding novel benchmarks/datasets to the library:
35
+ * [x] Is the task an existing benchmark in the literature?
36
+ * [x] Have you referenced the original paper that introduced the task?
37
+ * [x] If yes, does the original paper provide a reference implementation? If so, have you checked against the reference implementation and documented how to run such a test?
38
+
39
+
40
+ If other tasks on this dataset are already supported:
41
+ * [x] Is the "Main" variant of this task clearly denoted?
42
+ * [x] Have you provided a short sentence in a README on what each new variant adds / evaluates?
43
+ * [x] Have you noted which, if any, published evaluation setups are matched by this variant?
lm-evaluation-harness/lm_eval/tasks/alghafa/piqa_ar/piqa_ar.yaml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ task: piqa_ar
2
+ dataset_path: Hennara/pica_ar
3
+ dataset_name: null
4
+ output_type: multiple_choice
5
+ training_split: null
6
+ validation_split: null
7
+ test_split: test
8
+ doc_to_text: "السؤال: {{goal}}\nالجواب:"
9
+ doc_to_choice: "{{[sol1, sol2]}}"
10
+ doc_to_target: label
11
+ should_decontaminate: true
12
+ doc_to_decontamination_query: goal
13
+ metric_list:
14
+ - metric: acc
15
+ aggregation: mean
16
+ higher_is_better: true
17
+ - metric: acc_norm
18
+ aggregation: mean
19
+ higher_is_better: true
20
+ metadata:
21
+ version: 1.0
lm-evaluation-harness/lm_eval/tasks/anli/README.md ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ANLI
2
+
3
+ ### Paper
4
+
5
+ Title: `Adversarial NLI: A New Benchmark for Natural Language Understanding`
6
+
7
+ Paper Link: https://arxiv.org/abs/1910.14599
8
+
9
+ Adversarial NLI (ANLI) is a dataset collected via an iterative, adversarial
10
+ human-and-model-in-the-loop procedure. It consists of three rounds that progressively
11
+ increase in difficulty and complexity, and each question-answer includes annotator-
12
+ provided explanations.
13
+
14
+ Homepage: https://github.com/facebookresearch/anli
15
+
16
+ ### Citation
17
+
18
+ ```
19
+ @inproceedings{nie-etal-2020-adversarial,
20
+ title = "Adversarial {NLI}: A New Benchmark for Natural Language Understanding",
21
+ author = "Nie, Yixin and
22
+ Williams, Adina and
23
+ Dinan, Emily and
24
+ Bansal, Mohit and
25
+ Weston, Jason and
26
+ Kiela, Douwe",
27
+ booktitle = "Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics",
28
+ year = "2020",
29
+ publisher = "Association for Computational Linguistics",
30
+ }
31
+ ```
32
+
33
+ ### Groups and Tasks
34
+
35
+ #### Groups
36
+
37
+ * `anli`: Evaluates `anli_r1`, `anli_r2`, and `anli_r3`
38
+
39
+ #### Tasks
40
+ * `anli_r1`: The data collected adversarially in the first round.
41
+ * `anli_r2`: The data collected adversarially in the second round, after training on the previous round's data.
42
+ * `anli_r3`: The data collected adversarially in the third round, after training on the previous multiple rounds of data.
43
+
44
+
45
+ ### Checklist
46
+
47
+ For adding novel benchmarks/datasets to the library:
48
+ * [x] Is the task an existing benchmark in the literature?
49
+ * [x] Have you referenced the original paper that introduced the task?
50
+ * [ ] If yes, does the original paper provide a reference implementation? If so, have you checked against the reference implementation and documented how to run such a test?
51
+
52
+
53
+ If other tasks on this dataset are already supported:
54
+ * [ ] Is the "Main" variant of this task clearly denoted?
55
+ * [x] Have you provided a short sentence in a README on what each new variant adds / evaluates?
56
+ * [ ] Have you noted which, if any, published evaluation setups are matched by this variant?
lm-evaluation-harness/lm_eval/tasks/anli/anli_r1.yaml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tag:
2
+ - anli
3
+ task: anli_r1
4
+ dataset_path: anli
5
+ dataset_name: null
6
+ output_type: multiple_choice
7
+ training_split: train_r1
8
+ validation_split: dev_r1
9
+ test_split: test_r1
10
+ doc_to_text: "{{premise}}\nQuestion: {{hypothesis}} True, False, or Neither?\nAnswer:"
11
+ # True = entailment
12
+ # False = contradiction
13
+ # Neither = neutral
14
+ doc_to_target: "{{['True', 'Neither', 'False'][label]}}"
15
+ doc_to_choice:
16
+ - "True"
17
+ - "Neither"
18
+ - "False"
19
+ should_decontaminate: true
20
+ doc_to_decontamination_query: premise
21
+ metric_list:
22
+ - metric: acc
23
+ aggregation: mean
24
+ higher_is_better: true
25
+ metadata:
26
+ version: 1.0
lm-evaluation-harness/lm_eval/tasks/anli/anli_r2.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ include: anli_r1.yaml
2
+ task: anli_r2
3
+ training_split: train_r2
4
+ validation_split: dev_r2
5
+ test_split: test_r2
lm-evaluation-harness/lm_eval/tasks/anli/anli_r3.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ include: anli_r1.yaml
2
+ task: anli_r3
3
+ training_split: train_r3
4
+ validation_split: dev_r3
5
+ test_split: test_r3
lm-evaluation-harness/lm_eval/tasks/arab_culture/README.md ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Arab Culture
2
+
3
+ ### Paper
4
+
5
+ Title: Commonsense Reasoning in Arab Culture
6
+
7
+
8
+ Abstract: https://arxiv.org/abs/2502.12788
9
+
10
+ Despite progress in Arabic large language models, such as Jais and AceGPT, their evaluation on commonsense reasoning has largely relied on machine-translated datasets, which lack cultural depth and may introduce Anglocentric biases. Commonsense reasoning is shaped by geographical and cultural contexts, and existing English datasets fail to capture the diversity of the Arab world. To address this, we introduce \datasetname, a commonsense reasoning dataset in Modern Standard Arabic (MSA), covering cultures of 13 countries across the Gulf, Levant, North Africa, and the Nile Valley. The dataset was built from scratch by engaging native speakers to write and validate culturally relevant questions for their respective countries. \datasetname spans 12 daily life domains with 54 fine-grained subtopics, reflecting various aspects of social norms, traditions, and everyday experiences. Zero-shot evaluations show that open-weight language models with up to 32B parameters struggle to comprehend diverse Arab cultures, with performance varying across regions. These findings highlight the need for more culturally aware models and datasets tailored to the Arabic-speaking world.
11
+
12
+ Homepage: https://github.com/fajri91/ArabicCulture
13
+
14
+
15
+ ### Citation
16
+
17
+ ```
18
+ @misc{sadallah2025commonsensereasoningarabculture,
19
+ title={Commonsense Reasoning in Arab Culture},
20
+ author={Abdelrahman Sadallah and Junior Cedric Tonga and Khalid Almubarak and Saeed Almheiri and Farah Atif and Chatrine Qwaider and Karima Kadaoui and Sara Shatnawi and Yaser Alesh and Fajri Koto},
21
+ year={2025},
22
+ eprint={2502.12788},
23
+ archivePrefix={arXiv},
24
+ primaryClass={cs.CL},
25
+ url={https://arxiv.org/abs/2502.12788},
26
+ }
27
+ ```
28
+
29
+ ### There are two variant of this task: `arab_culture`, and `arab_culture_completion`
30
+
31
+ - The `arab_culture` is the normal MCQ evaluation type, which appends the answers to the question, and then measure the likelihood of the different choices markers (A,B,C or "أ","ب","ج"). For more info, follow the MMLU style [tempelate](https://github.com/EleutherAI/lm-evaluation-harness/blob/main/lm_eval/tasks/mmlu/default/_default_template_yaml#L7-L8)
32
+ - The `arab_culture_completion` do the evaluation in a sentence completion manner, by appending each asnwer to the question separetley and chooses the answer with the higher likelihood. See [this](https://github.com/EleutherAI/lm-evaluation-harness/blob/1f9bc88fe61f6bfa36f74e91ce3d59ab5685e4f1/lm_eval/tasks/arc/arc_easy.yaml#L10-L12) for more information
33
+
34
+ ### Groups and Tasks
35
+
36
+ #### Groups
37
+
38
+ * `arabculture`: evaluates all ArabCulture tasks.
39
+
40
+ * `arab_culture_gulf`: evaluates Gulf countires ArabCulture tasks.
41
+ * `arab_culture_levant`: evaluates Levant countires ArabCulture tasks.
42
+ * `arab_culture_nile_valley`: evaluates Nile Valley countires ArabCulture tasks.
43
+ * `arab_culture_north_africa`: evaluates North Africa ArabCulture tasks.
44
+
45
+ ### Evaluation modes
46
+ This bechmark allows for different evaluation settings by allowing to adding more extra context for the model:
47
+
48
+ We have three settings:
49
+ * without any information
50
+ ```
51
+ COUNTRY=False
52
+ REGION=False
53
+ ```
54
+ * with only region information
55
+ ```
56
+ COUNTRY=False
57
+ REGION=True
58
+ ```
59
+ * with region and country information
60
+ ```
61
+ COUNTRY=True
62
+ REGION=True
63
+ ```
64
+
65
+ **Please add these flags add environment variables.**
66
+
67
+
68
+ * We also allow for prompting in English, which we found to acheive higher results on most of the evaluated models (please refer to our paper).
69
+
70
+ * To change the language of the prompt, Define the `ARABIC` environment variable.
lm-evaluation-harness/lm_eval/tasks/arab_culture/_arab_culture.yaml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aggregate_metric_list:
2
+ metric: acc
3
+ weight_by_size: true
4
+ group: arab_culture
5
+ metadata:
6
+ description: Arab Culture tasks
7
+ version: 0
8
+ task:
9
+ - arab_culture_gulf
10
+ - arab_culture_levant
11
+ - arab_culture_north_africa
12
+ - arab_culture_nile_valley
lm-evaluation-harness/lm_eval/tasks/arab_culture/_arab_culture_gulf.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ aggregate_metric_list:
2
+ metric: acc
3
+ weight_by_size: true
4
+ group: arab_culture_gulf
5
+ group_alias: Gulf
6
+ metadata:
7
+ description: arab Culture tasks
8
+ version: 0
9
+ task:
10
+ - arab_culture_gulf_tasks
lm-evaluation-harness/lm_eval/tasks/arab_culture/_arab_culture_levant.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ aggregate_metric_list:
2
+ metric: acc
3
+ weight_by_size: true
4
+ group: arab_culture_levant
5
+ group_alias: Levant
6
+ metadata:
7
+ description: arab Culture tasks
8
+ version: 0
9
+ task:
10
+ - arab_culture_levant_tasks
lm-evaluation-harness/lm_eval/tasks/arab_culture/_arab_culture_nile_valley.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ aggregate_metric_list:
2
+ metric: acc
3
+ weight_by_size: true
4
+ group: arab_culture_nile_valley
5
+ group_alias: Nile Valley
6
+ metadata:
7
+ description: arab Culture tasks
8
+ version: 0
9
+ task:
10
+ - arab_culture_nile_valley_tasks
lm-evaluation-harness/lm_eval/tasks/arab_culture/_arab_culture_north_africa.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ aggregate_metric_list:
2
+ metric: acc
3
+ weight_by_size: true
4
+ group: arab_culture_north_africa
5
+ group_alias: North Africa
6
+ metadata:
7
+ description: arab Culture tasks
8
+ version: 0
9
+ task:
10
+ - arab_culture_north_africa_tasks
lm-evaluation-harness/lm_eval/tasks/arab_culture/_default_arab_culture_mcq_template_yaml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ dataset_path: MBZUAI/ArabCulture
2
+ test_split: test
3
+ fewshot_split: test
4
+ fewshot_config:
5
+ sampler: first_n
6
+ output_type: multiple_choice
7
+ doc_to_text: !function utils_mcq.doc_to_text
8
+ doc_to_choice: !function utils_mcq.doc_to_choice
9
+ doc_to_target: !function utils_mcq.doc_to_target
10
+ target_delimiter: ""
11
+ metric_list:
12
+ - metric: acc
13
+ aggregation: mean
14
+ higher_is_better: true
15
+ - metric: acc_norm
16
+ aggregation: mean
17
+ higher_is_better: true
18
+ metadata:
19
+ version: 0.0
lm-evaluation-harness/lm_eval/tasks/arab_culture/_generate_configs.py ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Take in a YAML, and output all "other" splits with this YAML
3
+ """
4
+
5
+ import argparse
6
+ import logging
7
+ import os
8
+
9
+ import yaml
10
+ from tqdm import tqdm
11
+
12
+
13
+ eval_logger = logging.getLogger("lm-eval")
14
+
15
+ countries = {
16
+ "KSA": "Gulf",
17
+ "UAE": "Gulf",
18
+ "Yemen": "Gulf",
19
+ "Lebanon": "Levant",
20
+ "Syria": "Levant",
21
+ "Palestine": "Levant",
22
+ "Jordan": "Levant",
23
+ "Tunisia": "North Africa",
24
+ "Algeria": "North Africa",
25
+ "Morocco": "North Africa",
26
+ "Libya": "North Africa",
27
+ "Egypt": "Nile Valley",
28
+ "Sudan": "Nile Valley",
29
+ }
30
+
31
+ VERSION = 0
32
+
33
+
34
+ def parse_args():
35
+ parser = argparse.ArgumentParser()
36
+ parser.add_argument(
37
+ "--base_yaml_path", default="_default_arab_culture_mcq_template_yaml"
38
+ )
39
+ parser.add_argument("--save_prefix_path", default="arab_culture")
40
+ return parser.parse_args()
41
+
42
+
43
+ if __name__ == "__main__":
44
+ args = parse_args()
45
+
46
+ # get filename of base_yaml so we can `"include": ` it in our "other" YAMLs.
47
+ base_yaml_name = os.path.split(args.base_yaml_path)[-1]
48
+ # with open(args.base_yaml_path, encoding="utf-8") as f:
49
+ # base_yaml = yaml.full_load(f)
50
+
51
+ ALL_REGIONS = []
52
+ for country, region in tqdm(countries.items()):
53
+ if region not in ALL_REGIONS:
54
+ ALL_REGIONS.append(region)
55
+
56
+ # description = f"The following are multiple choice questions (with answers) about {' '.join(subject.split('_'))}.\n\n"
57
+
58
+ yaml_dict = {
59
+ "include": base_yaml_name,
60
+ "tag": f"arab_culture_{region.lower().replace(' ', '_')}_tasks",
61
+ "task": f"arab_culture_{country.lower().replace(' ', '_')}",
62
+ "task_alias": country,
63
+ "dataset_name": country,
64
+ # "description": description,
65
+ }
66
+
67
+ file_save_path = (
68
+ args.save_prefix_path
69
+ + f"_{country.lower().replace(' ', '_').replace('(', '').replace(')', '')}.yaml"
70
+ )
71
+ eval_logger.info(f"Saving yaml for subset {country} to {file_save_path}")
72
+ with open(file_save_path, "w", encoding="utf-8") as yaml_file:
73
+ yaml.dump(
74
+ yaml_dict,
75
+ yaml_file,
76
+ allow_unicode=True,
77
+ default_style='"',
78
+ )
79
+
80
+ arab_culture_mcq_regions = [
81
+ f"arab_culture_{region.lower().replace(' ', '_')}" for region in ALL_REGIONS
82
+ ]
83
+
84
+ file_save_path = args.save_prefix_path + ".yaml"
85
+
86
+ eval_logger.info(f"Saving benchmark config to {file_save_path}")
87
+
88
+ for region in ALL_REGIONS:
89
+ file_save_path = (
90
+ args.save_prefix_path + f"_{region.lower().replace(' ', '_')}.yaml"
91
+ )
92
+ eval_logger.info(f"Saving yaml for subset {region} to {file_save_path}")
93
+ with open("_" + file_save_path, "w", encoding="utf-8") as yaml_file:
94
+ yaml.dump(
95
+ {
96
+ "group": f"arab_culture_{region.lower().replace(' ', '_')}",
97
+ "group_alias": region,
98
+ "task": [f"arab_culture_{region.lower().replace(' ', '_')}_tasks"],
99
+ "aggregate_metric_list": {"metric": "acc", "weight_by_size": True},
100
+ "metadata": {
101
+ "description": "arab Culture tasks",
102
+ "version": VERSION,
103
+ },
104
+ },
105
+ yaml_file,
106
+ indent=4,
107
+ default_flow_style=False,
108
+ )
109
+
110
+ file_save_path = args.save_prefix_path + ".yaml"
111
+ with open("_" + file_save_path, "w", encoding="utf-8") as yaml_file:
112
+ yaml.dump(
113
+ {
114
+ "group": "arab_culture",
115
+ "task": arab_culture_mcq_regions,
116
+ "aggregate_metric_list": {"metric": "acc", "weight_by_size": True},
117
+ "metadata": {"description": "Arab Culture tasks", "version": VERSION},
118
+ },
119
+ yaml_file,
120
+ indent=4,
121
+ default_flow_style=False,
122
+ )
lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_algeria.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ "dataset_name": "Algeria"
2
+ "include": "_default_arab_culture_mcq_template_yaml"
3
+ "tag": "arab_culture_north_africa_tasks"
4
+ "task": "arab_culture_algeria"
5
+ "task_alias": "Algeria"
lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_egypt.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ "dataset_name": "Egypt"
2
+ "include": "_default_arab_culture_mcq_template_yaml"
3
+ "tag": "arab_culture_nile_valley_tasks"
4
+ "task": "arab_culture_egypt"
5
+ "task_alias": "Egypt"
lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_jordan.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ "dataset_name": "Jordan"
2
+ "include": "_default_arab_culture_mcq_template_yaml"
3
+ "tag": "arab_culture_levant_tasks"
4
+ "task": "arab_culture_jordan"
5
+ "task_alias": "Jordan"
lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_ksa.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ "dataset_name": "KSA"
2
+ "include": "_default_arab_culture_mcq_template_yaml"
3
+ "tag": "arab_culture_gulf_tasks"
4
+ "task": "arab_culture_ksa"
5
+ "task_alias": "KSA"
lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_lebanon.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ "dataset_name": "Lebanon"
2
+ "include": "_default_arab_culture_mcq_template_yaml"
3
+ "tag": "arab_culture_levant_tasks"
4
+ "task": "arab_culture_lebanon"
5
+ "task_alias": "Lebanon"
lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_libya.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ "dataset_name": "Libya"
2
+ "include": "_default_arab_culture_mcq_template_yaml"
3
+ "tag": "arab_culture_north_africa_tasks"
4
+ "task": "arab_culture_libya"
5
+ "task_alias": "Libya"
lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_morocco.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ "dataset_name": "Morocco"
2
+ "include": "_default_arab_culture_mcq_template_yaml"
3
+ "tag": "arab_culture_north_africa_tasks"
4
+ "task": "arab_culture_morocco"
5
+ "task_alias": "Morocco"
lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_palestine.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ "dataset_name": "Palestine"
2
+ "include": "_default_arab_culture_mcq_template_yaml"
3
+ "tag": "arab_culture_levant_tasks"
4
+ "task": "arab_culture_palestine"
5
+ "task_alias": "Palestine"
lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_sudan.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ "dataset_name": "Sudan"
2
+ "include": "_default_arab_culture_mcq_template_yaml"
3
+ "tag": "arab_culture_nile_valley_tasks"
4
+ "task": "arab_culture_sudan"
5
+ "task_alias": "Sudan"
lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_syria.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ "dataset_name": "Syria"
2
+ "include": "_default_arab_culture_mcq_template_yaml"
3
+ "tag": "arab_culture_levant_tasks"
4
+ "task": "arab_culture_syria"
5
+ "task_alias": "Syria"
lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_tunisia.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ "dataset_name": "Tunisia"
2
+ "include": "_default_arab_culture_mcq_template_yaml"
3
+ "tag": "arab_culture_north_africa_tasks"
4
+ "task": "arab_culture_tunisia"
5
+ "task_alias": "Tunisia"
lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_uae.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ "dataset_name": "UAE"
2
+ "include": "_default_arab_culture_mcq_template_yaml"
3
+ "tag": "arab_culture_gulf_tasks"
4
+ "task": "arab_culture_uae"
5
+ "task_alias": "UAE"
lm-evaluation-harness/lm_eval/tasks/arab_culture/arab_culture_yemen.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ "dataset_name": "Yemen"
2
+ "include": "_default_arab_culture_mcq_template_yaml"
3
+ "tag": "arab_culture_gulf_tasks"
4
+ "task": "arab_culture_yemen"
5
+ "task_alias": "Yemen"
lm-evaluation-harness/lm_eval/tasks/arab_culture/prompts.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ REGION_COUNTRY_PROMPT_AR = """
2
+ مهمتك هي اختيار الخيار الأنسب ثقافياً بناءً على السياق المقدم أدناه.
3
+
4
+ الموقع: {country}, {region}
5
+ الجملة: {first_statement}
6
+
7
+ يرجى مراعاة الفروق الثقافية للموقع المحدد واختيار الإجابة الأكثر ملاءمة من الخيارات المتاحة.
8
+
9
+ الخيارات:
10
+ {choices}
11
+ """
12
+
13
+ REGION_PROMPT_AR = """
14
+ مهمتك هي اختيار الخيار الأنسب ثقافياً بناءً على السياق المقدم أدناه.
15
+
16
+ الموقع: {region}
17
+ الجملة: {first_statement}
18
+
19
+ يرجى مراعاة الفروق الثقافية للموقع المحدد واختيار الإجابة الأكثر ملاءمة من الخيارات المتاحة.
20
+
21
+ الخيارات:
22
+ {choices}
23
+ """
24
+
25
+ BASE_PROMPT_AR = """
26
+ مهمتك هي اختيار الخيار الأنسب ثقافياً بناءً على السياق المقدم أدناه.
27
+
28
+ الجملة: {first_statement}
29
+
30
+ يرجى مراعاة الفروق الثقافية واختيار الإجابة الأكثر ملاءمة من الخيارات المتاحة.
31
+
32
+ الخيارات:
33
+ {choices}
34
+ """
35
+
36
+ REGION_COUNTRY_PROMPT = """
37
+ You are tasked with selecting the most culturally appropriate option based on the context provided below.
38
+
39
+ Location: {country}, {region}
40
+ Statement: {first_statement}
41
+
42
+ Consider the cultural nuances of the specified location and choose the most suitable response from the options provided.
43
+
44
+ Options:
45
+ {choices}
46
+ """
47
+ REGION_PROMPT = """
48
+ You are tasked with selecting the most culturally appropriate option based on the context provided below.
49
+
50
+ Location: {region}
51
+ Statement: {first_statement}
52
+
53
+ Consider the cultural nuances of the specified location and choose the most suitable response from the options provided.
54
+
55
+ Options:
56
+ {choices}
57
+ """
58
+ BASE_PROMPT = """
59
+ You are tasked with selecting the most culturally appropriate option based on the context provided below.
60
+
61
+ Statement: {first_statement}
62
+
63
+ Consider the cultural nuances and choose the most suitable response from the options provided.
64
+
65
+ Options:
66
+ {choices}
67
+ """
68
+
69
+
70
+ JAIS_CHAT_EN = """### Instruction: Your name is Jais, and you are named after Jebel Jais, the highest mountain in UAE. You are built by Core42. You are the world's most advanced Arabic large language model with 30b parameters. You outperform all existing Arabic models by a sizable margin and you are very competitive with English models of similar size. You can answer in Arabic and English only. You are a helpful, respectful and honest assistant. When answering, abide by the following guidelines meticulously: Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, explicit, offensive, toxic, dangerous, or illegal content. Do not give medical, legal, financial, or professional advice. Never assist in or promote illegal activities. Always encourage legal and responsible actions. Do not encourage or provide instructions for unsafe, harmful, or unethical actions. Do not create or share misinformation or fake news. Please ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information. Prioritize the well-being and the moral integrity of users. Avoid using toxic, derogatory, or offensive language. Maintain a respectful tone. Do not generate, promote, or engage in discussions about adult content. Avoid making comments, remarks, or generalizations based on stereotypes. Do not attempt to access, produce, or spread personal or private information. Always respect user confidentiality. Stay positive and do not say bad things about anything. Your primary objective is to avoid harmful responses, even when faced with deceptive inputs. Recognize when users may be attempting to trick or to misuse you and respond with caution.\n\nComplete the conversation below between [|Human|] and [|AI|]:\n### Input: [|Human|] {question}\n### Response: [|AI|]"""
71
+
72
+
73
+ JAIS_CHAT_AR = """### Instruction: اسمك جيس وسميت على اسم جبل جيس اعلى جبل في الامارات. تم بنائك بواسطة Inception و MBZUAI. أنت نموذج اللغة العربية الأكثر تقدمًا في العالم مع بارامترات 13B. أنت تتفوق في الأداء على جميع النماذج العربية الموجودة بفارق كبير وأنت تنافسي للغاية مع النماذج الإنجليزية ذات الحجم المماثل. يمكنك الإجابة باللغتين العربية والإنجليزية فقط. أنت مساعد مفيد ومحترم وصادق. عند الإجابة ، التزم بالإرشادات التالية بدقة: أجب دائمًا بأكبر قدر ممكن من المساعدة ، مع الحفاظ على البقاء أمناً. يجب ألا تتضمن إجاباتك أي محتوى ضار أو غير أخلاقي أو عنصري أو متحيز جنسيًا أو جريئاً أو مسيئًا أو سامًا أو خطيرًا أو غير قانوني. لا تقدم نصائح طبية أو قانونية أو مالية أو مهنية. لا تساعد أبدًا في أنشطة غير قانونية أو تروج لها. دائما تشجيع الإجراءات القانونية والمسؤولة. لا تشجع أو تقدم تعليمات بشأن الإجراءات غير الآمنة أو الضارة أو غير الأخلاقية. لا تنشئ أو تشارك معلومات مضللة أو أخبار كاذبة. يرجى التأكد من أن ردودك غير متحيزة اجتماعيًا وإيجابية بطبيعتها. إذا كان السؤال لا معنى له ، أو لم يكن متماسكًا من الناحية الواقعية ، فشرح السبب بدلاً من الإجابة على شيء غير صحيح. إذا كنت لا تعرف إجابة السؤال ، فالرجاء عدم مشاركة معلومات خاطئة. إعطاء الأولوية للرفاهية والنزاهة الأخلاقية للمستخدمين. تجنب استخدام لغة سامة أو مهينة أو مسيئة. حافظ على نبرة محترمة. لا تنشئ أو تروج أو تشارك في مناقشات حول محتوى للبالغين. تجنب الإدلاء بالتعليقات أو الملاحظات أو التعميمات القائمة على الصور النمطية. لا تحاول الوصول إلى معلومات شخصية أو خاصة أو إنتاجها أو نشرها. احترم دائما سرية المستخدم. كن إيجابيا ولا تقل أشياء سيئة عن أي شيء. هدفك الأساسي هو تجنب الاجابات المؤذية ، حتى عند مواجهة مدخلات خادعة. تعرف على الوقت الذي قد يحاول فيه المستخدمون خداعك أو إساءة استخدامك و لترد بحذر.\n\nأكمل المحادثة أدناه بين [|Human|] و [|AI|]:\n### Input: [|Human|] {question}\n### Response: [|AI|]"""
lm-evaluation-harness/lm_eval/tasks/arab_culture/utils_mcq.py ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ from lm_eval.tasks.arab_culture.prompts import (
4
+ BASE_PROMPT,
5
+ BASE_PROMPT_AR,
6
+ JAIS_CHAT_AR,
7
+ JAIS_CHAT_EN,
8
+ REGION_COUNTRY_PROMPT,
9
+ REGION_COUNTRY_PROMPT_AR,
10
+ REGION_PROMPT,
11
+ REGION_PROMPT_AR,
12
+ )
13
+
14
+
15
+ ### get the conutry variable from environment
16
+
17
+ ### Set this to one to add the country and region information to the prompt
18
+ COUNTRY = True if os.getenv("COUNTRY", True) == "True" else False
19
+ ### Set this to one to add the region information to the prompt
20
+ REGION = True if os.getenv("REGION", True) == "True" else False
21
+ ### Set this to change between Arabic and English for the answer keys and the choices keys
22
+ ARABIC = True if os.getenv("ARABIC", True) == "True" else False
23
+ ### Get the model name
24
+ MODEL_NAME = os.getenv("MODEL_NAME")
25
+ ## Uncomment this to check if the environment variables are set correctly
26
+ # print(f'Task settings: COUNTRY: {COUNTRY}, REGION: {REGION}, ARABIC: {ARABIC}', MODEL_NAME: {MODEL_NAME})
27
+
28
+ en_ar_countries_regions = {
29
+ "Egypt": "مصر",
30
+ "Morocco": "المغرب",
31
+ "Algeria": "الجزائر",
32
+ "Libya": "ليبيا",
33
+ "Sudan": "السودان",
34
+ "Tunisia": "تونس",
35
+ "Jordan": "الأردن",
36
+ "Lebanon": "لبنان",
37
+ "Syria": "سوريا",
38
+ "Palestine": "فلسطين",
39
+ "Yemen": "اليمن",
40
+ "UAE": "الإمارات",
41
+ "KSA": "السعودية",
42
+ "Gulf": "الخليج",
43
+ "Levant": "الشام",
44
+ "North Africa": "شمال أفريقيا",
45
+ "Nile Valley": "وادي النيل",
46
+ }
47
+
48
+
49
+ def doc_to_text(doc):
50
+ country = "" if not doc["country"] else doc["country"]
51
+ region = "" if not doc["region"] else doc["region"]
52
+ first_statement = doc["first_statement"].strip()
53
+
54
+ ## We don't have a setting for only information about the country without the region
55
+ if COUNTRY:
56
+ assert REGION, (
57
+ "If you want to add the country information, you must also add the region information"
58
+ )
59
+
60
+ ## convert contry and region name to arabic if the language is arabic
61
+ if ARABIC:
62
+ country = en_ar_countries_regions[country]
63
+ region = en_ar_countries_regions[region]
64
+
65
+ choices = doc["options"]
66
+ choices_str = ""
67
+ for i in range(3):
68
+ key = choices["arabic_keys"][i] if ARABIC else choices["english_keys"][i]
69
+ choice_str = key + ". " + choices["text"][i].strip() + "\n"
70
+ choices_str += choice_str
71
+
72
+ if COUNTRY and REGION:
73
+ cur_prompt = REGION_COUNTRY_PROMPT_AR if ARABIC else REGION_COUNTRY_PROMPT
74
+ doc_text = cur_prompt.format(
75
+ country=country,
76
+ region=region,
77
+ first_statement=first_statement,
78
+ choices=choices_str,
79
+ )
80
+ elif REGION:
81
+ cur_prompt = REGION_PROMPT_AR if ARABIC else REGION_PROMPT
82
+ doc_text = cur_prompt.format(
83
+ region=region, first_statement=first_statement, choices=choices_str
84
+ )
85
+ else:
86
+ cur_prompt = BASE_PROMPT_AR if ARABIC else BASE_PROMPT
87
+ doc_text = cur_prompt.format(
88
+ first_statement=first_statement, choices=choices_str
89
+ )
90
+
91
+ ### apply jais chat tempelate
92
+ if MODEL_NAME and "jais" in MODEL_NAME and "chat" in MODEL_NAME:
93
+ if ARABIC:
94
+ doc_text = JAIS_CHAT_AR.format(question=doc_text)
95
+ else:
96
+ doc_text = JAIS_CHAT_EN.format(question=doc_text)
97
+
98
+ return doc_text
99
+
100
+
101
+ def doc_to_choice(doc):
102
+ return doc["options"]["arabic_keys"] if ARABIC else doc["options"]["english_keys"]
103
+
104
+
105
+ def doc_to_target(doc):
106
+ ans = (
107
+ doc["answer_key"]["arabic_answer_key"]
108
+ if ARABIC
109
+ else doc["answer_key"]["english_answer_key"]
110
+ )
111
+ ans = ans.strip()
112
+ return ans