--- license: apache-2.0 base_model: Qwen/Qwen2.5-Coder-1.5B base_model_relation: finetune pipeline_tag: text-generation library_name: gguf language: - en datasets: - codeparrot/github-code-clean tags: - code - code-completion - autocomplete - fill-in-the-middle - gguf - llama.cpp - lora - kvchub - ki-complete --- # Ki Complete 1.5B KvcHub's code autocomplete model: it writes the grey suggestion as you type in your editor, running on your own computer. It powers the **Ki Complete** extension for VS Code and editors built on it (such as Antigravity). Ki Complete 1.5B is **Qwen2.5-Coder-1.5B fine-tuned by KvcHub** for editor moments: finish the line you're typing and stop, write the block when a line opens one, write the next line on a fresh line, and write nothing when nothing is missing. | File | What it is | |---|---| | `ki-complete-1.5b-q8_0.gguf` | The model for llama.cpp (Q8_0, 1.65 GB, about 2 GB of memory) | | `adapter/` | The LoRA (rank 64) for use with Hugging Face PEFT on top of [Qwen/Qwen2.5-Coder-1.5B](https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B) | | `LICENSE` | Apache-2.0 | ## Use In the Ki Complete extension it's the default model. With llama.cpp directly: ``` llama-server -hf KvcHub/Ki-Complete-1.5B:Q8_0 --port 8012 -b 1024 -ub 1024 --cache-reuse 256 curl http://127.0.0.1:8012/infill -d '{"input_prefix": "def add(a, b):\n", "prompt": " ", "input_suffix": "\n", "n_predict": 64}' ``` The prompt format is Qwen2.5-Coder's fill-in-the-middle, exactly as llama.cpp's `/infill` builds it: `<|repo_name|>myproject\n<|file_sep|>filename\n<|fim_prefix|>{code before the cursor}<|fim_suffix|>{code after}<|fim_middle|>`; pieces of other files can go before the last `<|file_sep|>` as `<|file_sep|>{name}\n{code}`. The model ends its answer with `<|endoftext|>` or `<|fim_pad|>`. With PEFT: ```python from transformers import AutoModelForCausalLM from peft import PeftModel base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Coder-1.5B") model = PeftModel.from_pretrained(base, "KvcHub/Ki-Complete-1.5B", subfolder="adapter") ``` ## Results On tasks it never trained on, through Ki Complete's own suggestion logic, on llama.cpp: | | Qwen2.5-Coder-1.5B | **Ki Complete 1.5B** | |---|---|---| | HumanEval-Infilling, one missing line (1,033): tests pass | 88.4% | **89.4%** | | HumanEval-Infilling, several missing lines (1,000): tests pass | 50.8% | **53.4%** | | HumanEval-Infilling, gap starting mid-line (164): tests pass | **42.7%** | 40.9% | | Real code (700 spots): rest of the line exactly right | 30.9% / 39.7% | **36.0% / 44.0%** | | Same, with pieces of related files as context | 33.7% / 41.1% | **38.6% / 45.1%** | | Answers padded with extra lines nobody asked for | 65% | **3%** | | Tokens written per suggestion | 65 | **12** | | Typical wait for a suggestion (Apple M5 Pro) | 586 ms | **228 ms** | The real-code spots come from KvcHub's own projects (Python, JavaScript, HTML, shell), split into two halves. While typing on the same line, the server reuses its work and suggestions typically take about 0.1 seconds. ## Training - **Examples:** 120,000 editor moments, in exactly the format llama.cpp sends: 41% part-way through a line, 35% on a fresh line, 9% a gap of up to three lines, 15% where nothing is missing. A quarter include pieces of other files from the same project. - **Code:** permissively licensed files (MIT, Apache-2.0, BSD, ISC and similar) in 15 languages from [codeparrot/github-code-clean](https://huggingface.co/datasets/codeparrot/github-code-clean), plus about 10% from KvcHub's own projects (only files that parse; the test files and near-copies of them excluded). - **Method:** LoRA rank 64 on every attention and MLP layer (74M trainable parameters), loss only on the missing code, 989 steps over 10 hours on an Apple M5 Pro (about 40,000 examples seen). Validation loss on projects never trained on: 0.681 before, 0.578 after. - **Credentials:** the training files were scanned for keys and tokens; the model doesn't reproduce them (it is no more likely to write any of them than the base model, which never saw them). The Ki Complete extension also never suggests a key-shaped string that isn't already in your file. ## Limits - It's a 1.5B model: strong at finishing lines and short blocks, weaker than large cloud models at long multi-line code. - Trained to finish lines and stop, so it does slightly worse than the base model when asked to fill gaps that start and end at random points mid-line. - Mostly English code and comments. ## License and credits Apache-2.0. **Ki Complete 1.5B is a modified version of [Qwen2.5-Coder-1.5B](https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B) by the Qwen team (Apache-2.0)**: KvcHub fine-tuned it with a LoRA, merged into the GGUF weights. Training data from codeparrot/github-code-clean (permissively licensed files only); evaluation with HumanEval-Infilling (OpenAI, MIT); runs with llama.cpp (MIT).