ml-explore / mlx-examples

Examples in the MLX framework
MIT License
6.29k stars 897 forks source link

mlx_lm.generate --system-prompt doesn't convert `\n` as new line. #1120

Closed chigkim closed 4 days ago

chigkim commented 4 days ago

If I include \n in --system-prompt "xxx\nyyy", it seems to just feed the characters \n to the model instead of a new line.

awni commented 4 days ago

This shell escapes the \ before sending to Python and I believe this is shell-dependent behavior. If you are using bash or zsh (and maybe others, not sure) then you can do $'system\nprompt' and it will not escape it. For example:

mlx_lm.generate --system-prompt $'You\nare\na\nhelpful\nAI\nassistant' --prompt "Write a story about Einstein"