Ki-Complete-1.5B / README.md
KVC899's picture
Link Ki Complete on the VS Code Marketplace
ecaf1cc verified
|
Raw History Blame Contribute Delete
5.98 kB
---
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).
A larger, more accurate but slower sibling is [Ki Complete 7B](https://huggingface.co/KvcHub/Ki-Complete-7B).
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.
**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). Elsewhere, [download the .vsix](https://kvchub.com/downloads/ki-complete-0.3.0.vsix) (v0.3.0, 41 KB; in the editor's Extensions panel choose Install from VSIX), or install [Ki Complete from Open VSX](https://open-vsx.org/extension/kvchub/ki-complete) (`kvchub.ki-complete`, published by KvcHub) from the Extensions panel in Antigravity or any editor that uses Open VSX. More at [kvchub.com](https://kvchub.com/#ki-complete).
| 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) |
| `ki-complete-1.5b-q4_k_m.gguf` | **Ki Complete Small**: the same model packed to 4 bits (Q4_K_M, 986 MB, about 1.3 GB of memory) for computers with 8 GB of memory. In the same tests: HumanEval one line 88.8%, several lines 51.3%, real code exactly right 34.0% / 42.6% (Q8_0: 89.4%, 53.4%, 36.0% / 44.0%) |
| `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).