Skip to content

escaping prompt for cfg_negative_prompt and consecutive prompts in main with interactive #3623

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

Merged
merged 22 commits into from
Oct 22, 2023

Conversation

vvhg1
Copy link
Contributor

@vvhg1 vvhg1 commented Oct 14, 2023

only when -e:
cfg_negative_prompt gets escaped
consecutive inputs in interactive mode are getting escaped

not sure if I got all cases covered, review needed

vvhg1 and others added 19 commits October 6, 2023 18:26
…ing space token from suffix when params.escape
…ing space token from suffix when params.escape
…ed back or rm added space token"

This reverts commit 63ba0b6.
Comment on lines 323 to 328
std::string inp_pfx_str = "\n\n### Instruction:\n\n";
std::string inp_sfx_str = "\n\n### Response:\n\n";
if (params.escape) {
process_escapes(inp_pfx_str);
process_escapes(inp_sfx_str);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm like 99.9% sure those have to be raw string literals, otherwise it makes no sense, escape sequences in string literals are processed at compile time, so this doesn't do anything

@@ -631,6 +631,7 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
process_escapes(params.prompt);
process_escapes(params.input_prefix);
process_escapes(params.input_suffix);
process_escapes(sparams.cfg_negative_prompt);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep only this line from this PR and we can merge.
All other changes are not necessary


if (params.escape) {
process_escapes(buffer);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not also want to keep this to escape the new input?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to - the model will not generate unescaped stuff

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would that not result in a situation where we escape the initial prompt but not the following prompts in interactive mode?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vvhg1
That's the current behavior, user input in interactive mode tokenizes "\n" as \,n

While enabling escapes for interactive user input would allow "multiline" input via "\n", it would prevent user from writing "\n" literally, making it impossible to do things like copy-pasting code snippets etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@staviq I see your point. What I don't yet understand is, why would we want to treat the initial prompt differently than subsequential prompts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, wait - I think I was wrong. Let me check this again later, but we might want to keep this escape

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I agree we should keep this escape as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, should all be ready to merge

@ggerganov ggerganov merged commit d3956ae into ggml-org:master Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants