LocalAI icon indicating copy to clipboard operation
LocalAI copied to clipboard

Not correctly accounting for Line Endings in tmpl files.

Open TwinFinz opened this issue 5 months ago • 1 comments

LocalAI version: N/A

Environment, CPU architecture, OS, and Version: N/A

Describe the bug If tmpl file is edited using a windows based editor it can cause weird bugs in requests with smaller models due to windows line endings "\r\n". A possible fix would be to swap ALL line endings for tmpl files to use the linux line endings "\n" regardless which ones it initially used. maybe a startup check. This issue does not occur when files are edited within linux or if template is directly within the yaml file.

To Reproduce Edit tmpl file using windows based editor then pass this tmpl to be used by a smaller model (I.E: 7b model) it will cause more often looping.

Expected behavior Model respond correctly

Logs N/A

TwinFinz avatar Mar 22 '24 04:03 TwinFinz

Hello TwinFinz,

Thank you for bringing this issue to our attention. It seems like there might be a problem with how LocalAI handles line endings in tmpl files when they are edited using a Windows-based editor. This could cause issues with smaller models, particularly when using "\r\n" line endings instead of the Linux-style "\n" line endings.

I am a bot, an experiment of @mudler, and I will provide you with some information regarding the problem and possible solutions.

To reproduce the issue, you mentioned that editing tmpl files using a Windows-based editor and then passing them to be used by a smaller model like a 7b model would cause more frequent looping. The expected behavior, on the other hand, should be that the model responds correctly.

Unfortunately, there are no logs provided in this case, which would help us investigate the issue further. However, I suggest the following possible solution:

  1. To ensure consistency and avoid this issue, it would be best to edit the tmpl files using a Linux-based editor or an editor that uses the "\n" line ending by default.
  2. Alternatively, you can implement a startup check in LocalAI that automatically swaps all line endings in tmpl files to use the Linux-style "\n" line endings, regardless of their initial format. This would help avoid any potential issues related to line endings.

If you encounter this issue again or have any additional information, please do not hesitate to update the issue.

Best regards, The LocalAI Bot (an experiment of @mudler)

localai-bot avatar Apr 15 '24 17:04 localai-bot