-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Completion results are worse with Windows line endings (CRLF) #3279
Comments
Thank you for the detailed bug report. My initial thought is that this issue might stem from a limitation of the model, rather than a manipulation within Tabby's layer. One approach you could take is to submit a relevant completion request at https://demo.tabbyml.com/swagger-ui/#/v1/completion, which is powered by a much more powerful model (>100B parameters). Based on my testing, requests with CRLF seem to work just fine. |
Hi, thanks for the quick reply! You are right, it works more often with a more powerful model. My minimal example and real example 1 work well on the test instance, even with CRLF. But with real example 2, there is still some weird output with CRLF only: Input from example 2 (CRLF): {
"language": "java",
"segments": {
"prefix": "class Fibonacci {\r\n int fib(int n) {\r\n if (n <= 1) {\r\n return n;\r\n }\r\n return fib(n - 1) + fib(n - 2);\r\n }\r\n\r\n int fibIterative(int n) {\r\n ",
"suffix": "\r\n }\r\n}"
}
} Output (CRLF): {
"id": "cmpl-1c3809e9-03f1-4edb-a22a-f4fdd1f706ef",
"choices": [
{
"index": 0,
"text": "if (n <= 1)bolds\n return nbolds\nbolds\n int fib = 1bolds\n int prevFib = 1bolds\nbolds\n for (int i = 2; i < n; i++)bolds\n {bolds\n int temp = fibbolds\n fib += prevFibbolds\n prevFib = tempbolds\n }bolds\nbolds\n return fibbolds\n }bolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds\nbolds"
}
]
} This happens repeatedly. With LF, it works fine. |
I feel it is more or less related to how data in model training is processed. One way to solve this is by replacing CRLF with LF in requests within Tabby, and then replacing them back in responses. |
Additional notes: https://demo.tabbyml.com/files/github/TabbyML/tabby/-/search/main?q=join%5C%5C(%5C%22%5C%5C%5C%5Cn%5C%22%5C%5C)%20lang%3Arust Inserted context (e.g from LSP / repository context) is currently constructed solely with LF, which might make the situation worse |
Hi @kleincode, which model do you use can mostly reproduce this case? |
Hi @zwpaper I can reproduce all my examples using CodeLlama-7b. It usually fails to give proper predictions as soon as there are 2-3 CRLF line breaks in the input. I would assume though that you can find examples for every LLM where replacing LF with CRLF (or even mixing them) leads to different, usually worse, results. |
Describe the bug
Tabby is running on a Linux machine, but I'm using it through the VSCode extension on Windows. When I edit a document with CRLF line endings (the standard on Windows), code completion returns an empty string or unfitting suggestions substantially more often. When I change the line endings to LF, the completion suggestions improve.
From looking at the completions events, I can see that the line endings are fed directly to the model - in the
prompt
field, they are conserved. Thus, the same piece of code will lead to different results by default on Windows and Linux/Mac machines. I have tested this with different variants of CodeLLaMa.I'd like to ask if this is intended. I would suggest that only LF line endings should be fed to the model because in my experiments, the results were consistently better than with CRLF. Theoretically, this makes sense since the models are probably trained mostly on LF data.
Information about your version
tabby 0.18.0 via Docker compose on Debian with CUDA
Information about your GPU
Additional context
Minimal example
Sending the Swagger example to the
completions
endpoint works perfectly fine:But the same request with CRLF returns an empty string:
Real example 1
Some examples of the exact same code leading to good suggestions with LF, but no suggestions with CRLF:
With LF:
Real example 2
Another example with CRLF:
After changing the line endings from CRLF to LF:
The text was updated successfully, but these errors were encountered: