DeepSpeed
DeepSpeed copied to clipboard
[BUG] inference --prompt special inputs
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:
- inner quotations are dropped because of using format on the string inside the python
- the fact that split according to white spaces and new arguments are identified by the - sign isn't right, because here -4C will be identified as a new argument that leads to: unrecognized arguments: -4C outside
@RezaYazdaniAminabadi @jeffra
@oelayan7 can you take a look at #4824 ? I believe it will resolve the problem you raised. Thanks
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.
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.
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.