--- license: apache-2.0 base_model: Qwen/Qwen2.5-Coder-7B 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 7B KvcHub's larger code autocomplete model. It writes the suggestion as you type in your editor, running on your own computer, and it's the most accurate model in the **Ki Complete** extension for VS Code and editors built on it (such as Antigravity). The smaller [Ki Complete 1.5B](https://huggingface.co/KvcHub/Ki-Complete-1.5B) is about 4 times quicker and stays the default; choose the 7B if accuracy matters more to you than speed and your computer has 16 GB of memory or more. Ki Complete 7B is **Qwen2.5-Coder-7B 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. **Get the extension:** in VS Code, install [Ki Complete from the Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=KvcHub.ki-complete&ssr=false#overview); in Antigravity or any editor that uses Open VSX, install [Ki Complete from Open VSX](https://open-vsx.org/extension/kvchub/ki-complete) (`kvchub.ki-complete`, published by KvcHub). Then pick **Ki Complete 7B** from the Ki status bar menu, under Model (version 0.3.0 and later). More at [kvchub.com](https://kvchub.com/#ki-complete). | File | What it is | |---|---| | `ki-complete-7b-q8_0.gguf` | The model for llama.cpp (Q8_0, 8.1 GB, about 9 GB of memory) | | `adapter/` | The LoRA (rank 64) for use with Hugging Face PEFT on top of [Qwen/Qwen2.5-Coder-7B](https://huggingface.co/Qwen/Qwen2.5-Coder-7B) | | `LICENSE` | Apache-2.0 | ## Use With llama.cpp directly: ``` llama-server -hf KvcHub/Ki-Complete-7B: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-7B") model = PeftModel.from_pretrained(base, "KvcHub/Ki-Complete-7B", subfolder="adapter") ``` ## Results On tasks it never trained on, through Ki Complete's own suggestion logic, on llama.cpp (Q8_0, Apple M5 Pro): | | Qwen2.5-Coder-7B | **Ki Complete 7B** | Ki Complete 1.5B | |---|---|---|---| | Real code (700 spots, two halves): rest of the line exactly right | 47.4% / 36.6% | **49.7% / 37.7%** | 43.1% / 35.7% | | Same, similarity to the right answer | 77.7% / 70.3% | **78.8% / 72.1%** | | | Same, with pieces of related files as context | 50.0% / 41.7% | **52.9% / 41.7%** | 45.1% / 38.9% | | Answers padded with extra lines nobody asked for | 42% | **4%** | 3% | | Tokens written per suggestion | 24 | **11** | 11 | | HumanEval-Infilling, one missing line (1,033): tests pass | 94.6% | **95.0%** | 89.4% | | HumanEval-Infilling, several missing lines (1,000): tests pass | **54.1%** | 53.5% | 53.4% | | HumanEval-Infilling, gap starting mid-line (164): tests pass | **48.2%** | 46.3% | 40.9% | | Typical wait for a suggestion on real code | 1.18 s | 1.00 s | **0.23 s** | | Typical wait with related files as context | 5.2 s | 4.5 s | **1.1 s** | The real-code spots come from KvcHub's own projects (Python, JavaScript, HTML, shell). While typing on the same line, the server reuses its work, so suggestions after the first are much quicker. Because the first suggestion with related files as context takes several seconds, the Ki Complete extension leaves that context off for this model unless you turn it on. ## Training - **Examples:** the same 120,000 editor moments as Ki Complete 1.5B, 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 (161M trainable parameters), loss only on the missing code, 396 steps over 10.8 hours on an Apple M5 Pro (PyTorch, then MLX), about 20,000 examples seen. Validation loss on projects never trained on: 0.449 before, 0.381 after. - **Credentials:** the training files were scanned for keys and tokens before training. The Ki Complete extension also never suggests a key-shaped string that isn't already in your file. ## Limits - Slower than Ki Complete 1.5B: about 1 second for a fresh suggestion on an Apple M5 Pro, and more on older computers. - 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 7B is a modified version of [Qwen2.5-Coder-7B](https://huggingface.co/Qwen/Qwen2.5-Coder-7B) 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).