Skip to content
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

Adding Refact model #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lm_eval/tasks/humanevalpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ def get_prompt(self, prompt_base, instruction, context=None):
elif self.prompt == "wizardcoder":
# https://github.com/nlpxucan/WizardLM/blob/main/WizardCoder/src/humaneval_gen.py#L37
prompt = f'Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n### Instruction:\n{inp}\n\n### Response:\n{prompt_base}'
elif self.prompt == "refact_instruct":
prompt = (f'<empty_output>USER {inp}\n'
f'<empty_output>ASSISTANT {prompt_base}')
else:
raise NotImplementedError

Expand Down
20 changes: 1 addition & 19 deletions lm_eval/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,29 +146,11 @@ def _make_infill_prompt(self, prefix, suffix, preprefix=""):
return f"{preprefix}{prefix}<|mask:0|>{suffix}<|mask:0|>"
elif model_id in ["bigcode/santacoder"]:
return f"<fim-prefix>{preprefix}{prefix}<fim-suffix>{suffix}<fim-middle>"
elif model_id in ["bigcode/starcoder", "bigcode/starcoderbase"]:
elif model_id in ["bigcode/starcoder", "bigcode/starcoderbase", "smallcloudai/Refact-1_6B-fim"]:
return f"<fim_prefix>{preprefix}{prefix}<fim_suffix>{suffix}<fim_middle>"
else:
raise ValueError(f"Infilling not yet supported for: {model_id}")

def _make_instruction_prompt(self, instruction, context, prefix=""):
"""Make a prompt for instruction-tuning. Delimit instruction and context with specific tokens if provided."""
if not self.instruction_tokens:
warnings.warn(
"Instruction-tuning tokens are not provided for an instruction-tuning task, we will leave them empty."
)
user_token, end_token, assistant_token = "", "", "\n"
else:
user_token, end_token, assistant_token = self.instruction_tokens
if not user_token or not assistant_token or not end_token:
warnings.warn(
"Instruction-tuning tokens provided but one or more are empty. Ignore warning if this was intended"
)
prompt = (
prefix + user_token + instruction + end_token + assistant_token + context
)

return prompt


def _parse_infill(code, tokenizer):
Expand Down