YJiangcm / Lion

Code for "Lion: Adversarial Distillation of Proprietary Large Language Models (EMNLP 2023)"
https://arxiv.org/abs/2305.12870
MIT License
201 stars 19 forks source link

problem in generate_hard_instruction.py #5

Open better629 opened 1 year ago

better629 commented 1 year ago

in function post_process_gpt3_response

    instruction_match = re.search(r"Instruction: (.+)\n", raw_instructions)
    if instruction_match:
        instruction = instruction_match.group(1)
    else:
        return []

raw_instructions is the response of chatgpt. And it uses string like Instruction: xx\nInput: <noinput>\n\n#Created Prompt# to call gpt to generate new instruction. But it seems that it won't contain Instruction: in the gpt response, only the new instruction. So it will allways return [] and cause while loop never stop.

Is there a problem or not? @YJiangcm

YJiangcm commented 1 year ago

Hi, in most cases, the gpt response contains strings like Instruction: xxx\nInput: xxx. So we use re.search(r"Instruction: (.+)\n", raw_instructions) to extract the generated instruction.

However, in some cases, the response will not contain the string Instruction: and Input:, so we discard the generated rsponse by return []. Hope this addresses your concerns.

better629 commented 1 year ago

@YJiangcm I think maybe the prompt Instruction: xx\nInput: <noinput>\n\n#Created Prompt# to the gpt is not directly( I have tried times, but can't response as except). Maybe update the prompt like ask it to generate new prompt as your format is more helpful.