microsoft / DeepSpeed

DeepSpeed is a deep learning optimization library that makes distributed training and inference easy, efficient, and effective.
https://www.deepspeed.ai/
Apache License 2.0
34.69k stars 4.04k forks source link

[BUG] inference --prompt special inputs #4716

Open oelayan7 opened 9 months ago

oelayan7 commented 9 months ago

When running in inference, one of the input parameters is a sentence which is given after --prompt flag.

As all arguments are parsed inside inference to build the "shell" command, prompt argument is wrapped in quotation marks --prompt. The wrapping quotations were ' and lately I have changed it to " (which solves a lot of issues where the prompt has a ' inside of it). But with the current solution, there is a wrong behavior (all inner " should be escaped, other wise the terminal ignores them) where we have inner quotations inside the prompt and there is a - inside those inner quotes.

For example: parameters of any command --model_name_or_path tiiuae/falcon-40b --max_new_tokens 128 --prompt "I'm feeling hot he said \" temperatures is -4C outside\""

user args after parsing: ['--model_name_or_path', 'tiiuae/falcon-40b', '--max_new_tokens', '128', '--prompt', "I'm feeling hot he said ", 'temp', 'is', '-4C', 'outside']

issues:

oelayan7 commented 9 months ago

@RezaYazdaniAminabadi @jeffra

mrwyattii commented 9 months ago

@oelayan7 can you take a look at #4824 ? I believe it will resolve the problem you raised. Thanks

oelayan7 commented 8 months ago

My bad, I defined a specific problem with " that happens in a higher probability than other characters that need to be escaped.

There are many other characters that need to be handled in the same way and it is hard to cover them all (Maybe it is easier to use a library version instead of handling all cases).

Not handling those characters mean that user's input is being altered.

mrwyattii commented 7 months ago

My bad, I defined a specific problem with " that happens in a higher probability than other characters that need to be escaped.

There are many other characters that need to be handled in the same way and it is hard to cover them all (Maybe it is easier to use a library version instead of handling all cases).

Not handling those characters mean that user's input is being altered.

Do you have another suggestion for how we can handle other cases? I'm not sure we will be able to handle every case where a character needs to be escaped due to the nature of how the DeepSpeed launcher works. In many cases, it's probably better to pass these values in a file rather than via command line.

oelayan7 commented 7 months ago

Maybe using shlex library which is made to solve these issues. Maybe using quote function there or any relevant function would be fine, I think.