TabbyML / tabby

Self-hosted AI coding assistant
https://tabby.tabbyml.com/
Other
21k stars 952 forks source link

Unicode characters seem to break completion #2663

Open ggerganov opened 1 month ago

ggerganov commented 1 month ago

Describe the bug

I'm not 100% sure what is the cause, but it seems the presence of certain unicode characters inside the file somehow messes up the completion requests. Here is an example:

#include <cstdio>

int main() {
    printf("Hello, World!\n");
    printf("Goodbye, 

    return 0;
}
#include <cstdio>

int main() {
    //"\\s?[A-Za-zµÀ-ÖØ-öø-ƺƼ-ƿDŽ-ʓʕ-ʯͰ-ͳͶͷͻ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-ՖႠ-ჅᎠ-Ᏽᏸ-ᏽᲐ-ᲺᲽ-Ჿᴀ-ᴫᵫ-ᵷᵹ-ᶚḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℴℹℼ-ℿⅅ-ⅉⅎↃↄⰀ-ⱻⱾ-ⳤⳫ-ⳮⳲⳳꙀ-ꙭꚀ-ꚛꜢ-ꝯꝱ-ꞇꞋ-ꞎꭰ-ꮿff-stﬓ-ﬗA-Za-z𐐀-𐑏𐒰-𐓓𐓘-𐓻𐲀-𐲲𐳀-𐳲𑢠-𑣟𞤀-𞥃]+",

    printf("Hello, World!\n");
    printf("Goodbye,

    return 0;
}

In fact anything after the long line with unicode characters will not be completed, even if the line is not within the completion context. Completions before the line still work OK. I observe the bug with any model using the Neovim Tabby plugin.

Information about your version

$ ▶ tabby --version
tabby 0.13.1

Information about your GPU

M2 Ultra 192GB

Additional context

Here is what the failed completion request in the example above look like (notice the incorrect prefix/suffix):

{
  "user": "E16n1q",
  "ts": 1721126142270,
  "event": {
    "completion": {
      "completion_id": "cmpl-f954b489-8122-40f8-a2c9-62bc6eb2047f",
      "language": "cpp",
      "prompt": "<fim_prefix>#include <cstdio>\n\nint main() {\n    //\"\\\\s?[A-Za-zµÀ-ÖØ-öø-ƺƼ-ƿDŽ-ʓʕ-ʯͰ-ͳͶͷͻ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-ՖႠ-ჅᎠ-Ᏽᏸ-ᏽᲐ-ᲺᲽ-Ჿᴀ-ᴫᵫ-ᵷᵹ-ᶚḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℴℹℼ-ℿⅅ-ⅉⅎↃↄⰀ-ⱻⱾ-ⳤⳫ-ⳮⳲⳳꙀ-ꙭꚀ-ꚛꜢ-ꝯꝱ-ꞇꞋ-ꞎꭰ-ꮿff-stﬓ-ﬗA-Za-z𐐀-𐑏𐒰-𐓓𐓘-𐓻𐲀-𐲲𐳀-𐳲𑢠-𑣟𞤀-𞥃]+\",\n\n    printf(\"Hello, World!\\n\");\n    pri<fim_suffix>ntf(\"Goodbye, \n\n    return 0;\n}<fim_middle>",
      "segments": {
        "prefix": "#include <cstdio>\n\nint main() {\n    //\"\\\\s?[A-Za-zµÀ-ÖØ-öø-ƺƼ-ƿDŽ-ʓʕ-ʯͰ-ͳͶͷͻ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-ՖႠ-ჅᎠ-Ᏽᏸ-ᏽᲐ-ᲺᲽ-Ჿᴀ-ᴫᵫ-ᵷᵹ-ᶚḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℴℹℼ-ℿⅅ-ⅉⅎↃↄⰀ-ⱻⱾ-ⳤⳫ-ⳮⳲⳳꙀ-ꙭꚀ-ꚛꜢ-ꝯꝱ-ꞇꞋ-ꞎꭰ-ꮿff-stﬓ-ﬗA-Za-z𐐀-𐑏𐒰-𐓓𐓘-𐓻𐲀-𐲲𐳀-𐳲𑢠-𑣟𞤀-𞥃]+\",\n\n    printf(\"Hello, World!\\n\");\n    pri",
        "suffix": "ntf(\"Goodbye, \n\n    return 0;\n}"
      },
      "choices": [
        {
          "index": 0,
          "text": ""
        }
      ]
    }
  }
}
wsxiaoys commented 1 month ago

Seems to be an issue of vim extension - @icycodes thoughts?