You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: bigcode_eval/tasks/shadereval.py
+16-5Lines changed: 16 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -131,6 +131,7 @@ def __init__(self):
131
131
# and if the evaluation requires executing the generated code in `requires_execution`.
132
132
stop_words=["\nfloat ", "\nvec", "\nint", "\nvoid", "\nmat"], #new function starts... so all the keywords
133
133
requires_execution=True, #we run shadercode - could that be harmful? (all in the metric)
134
+
prompt="minimal", # "minimal" or "full". "minimal" is the function header and comments before/after it, "full" is the whole code up untill the function declaration ends
134
135
)
135
136
136
137
defget_dataset(self):
@@ -146,13 +147,19 @@ def get_prompt(self, doc):
146
147
# TODO: build the prompt for the language model from a sample `doc` from the dataset
147
148
"""
148
149
Builds the prompt for the LM to generate from.
150
+
if prompt == "minimal" -> function header and comments before/after it
151
+
if prompt == "full" -> also includes full code before the function header
149
152
:param doc: dict[str: str]
150
153
sample from the test dataset
151
154
:return: str
152
155
"""
153
-
154
-
# alternatively, give the whole code up untill the function declaration ends? as in this paper: https://arxiv.org/abs/2306.03203
155
-
returndoc["model_ctx"]
156
+
model_context=""
157
+
ifself.prompt=="full":
158
+
# alternatively, give the whole code up untill the function declaration ends? as in this paper: https://arxiv.org/abs/2306.03203
159
+
model_context+=doc["full_code"].encode("utf-8")[:doc["func_range"][0]].decode("utf-8") #returns full original code up untill the function declaration ends
160
+
# only have one alternative, but could be more?
161
+
model_context+=doc["model_ctx"]
162
+
returnmodel_context
156
163
157
164
defget_reference(self, doc):
158
165
# TODO: get the reference solution from a sample `doc` from the dataset
0 commit comments