# Can a local model autocomplete my code?

> Yes, and well, because autocomplete wants a small fast model. Aim for suggestions that appear before you have finished the thought.

Autocomplete is the easiest coding job to move local. It needs a small model, a fast response and nothing else. A 1.5B to 7B coder model on a laptop does it well.

## Small and fast

The target is under 500 ms from keystroke to grey text. Slower than that and you have typed past the suggestion before it lands.

That budget rules out big models, because each suggestion means reading the code around your cursor, then writing a line or two. A small model does both in a fraction of a second. A 30B model gives smarter guesses that arrive too late to use.

**Rule of thumb.** 
For autocomplete, pick the smallest coder model whose suggestions you accept more often than you delete. Speed beats cleverness here.

The model also has to be trained for fill-in-the-middle. Ordinary chat models only continue text, while a fill-in-the-middle model sees the code before and after your cursor and writes what goes between. Model cards say whether a model supports it, and it is usually the base model, not the instruct one.

**The catch.** 
Most of the wait is reading, not writing. The editor sends a few thousand tokens of surrounding code with every request. On a machine with slow [prefill](https://localagi.co/life-of-a-prompt), such as a CPU-only laptop, that alone can blow the budget, so cut the context the extension sends before you shrink the model.

## Editor extensions with a local endpoint

These extensions accept a local server for completions. All of them are free.

| Extension | Editors | Talks to |
| --- | --- | --- |
| Continue | VS Code, JetBrains | Ollama, LM Studio, llama.cpp and any server from [How do I call a local model from code?](https://localagi.co/local-api) |
| llama.vscode and llama.vim | VS Code, Vim and Neovim | llama-server directly, built by the [What is llama.cpp?](https://localagi.co/llama-cpp) team |
| Tabby | VS Code, JetBrains, Vim | Its own self-hosted server, which runs the model |

Continue is the most common choice. It also does chat and edits, and you assign a model to each job separately. Here is a minimal config for autocomplete through Ollama.

```yaml
# ~/.continue/config.yaml
name: Local
version: 0.0.1
schema: v1
models:
  - name: Local autocomplete
    provider: ollama
    model: qwen2.5-coder:1.5b-base
    roles:
      - autocomplete
```

`provider: ollama` sends requests to Ollama on its default port. `roles: [autocomplete]` tells Continue to use this model only for inline suggestions, so you can add a bigger model for chat beside it.

llama.vscode is the lightest option if you already use llama.cpp. Start the server with a built-in completion preset, then install the extension and it finds the server on its own.

```bash
llama-server --fim-qwen-1.5b-default
```

The preset downloads a small fill-in-the-middle model and starts the server with settings tuned for completion. Swap `1.5b` for `7b` if you have the memory.

**Try it.** 
Open a file, type a function signature and a one-line comment saying what it does, then pause. If grey text appears before you reach for the next key, your setup is fast enough.

## Model picks by memory

Autocomplete shares the machine with your editor, browser and maybe a second model for chat. Size it to leave room.

| Memory | Autocomplete model | Room left for |
| --- | --- | --- |
| 8 GB | About 1.5B at 4-bit, about 1 GB | Your editor and little else |
| 16 GB | 1.5B to 3B, 1 to 2 GB | A small chat model beside it |
| 24 GB and up | Up to 7B, about 5 GB | A mid-class model for chat or agents, see [Which size of model do I need?](https://localagi.co/model-classes) |

A well-known family for this is the Qwen2.5-Coder base models at 1.5B, 3B or 7B. Any coder model that lists fill-in-the-middle support on its model card works the same way. [Which model should I use for my task?](https://localagi.co/choosing-a-model) covers how to compare them.

**The catch.** 
A 7B completion model plus a 27B agent model is about 21 GB of weights before any context. On a 24 GB machine that is too tight. Run one or the other, or drop autocomplete to 1.5B.

## Go deeper

### How fill-in-the-middle prompts look

The extension builds a prompt from three parts: a prefix (code above the cursor), a suffix (code below it) and special tokens that mark each. The model was trained on that layout, so it writes only the missing middle and stops. Each model family uses its own marker tokens, which is why extensions ask which model you run, and the wrong template gives you chatty prose in your code.

### Why the base model

Instruct models are tuned to answer questions in full sentences. That training fights fill-in-the-middle, where you want three tokens of code and silence. Base models, or coder models trained with FIM from the start, stay terse.

### Keeping the model loaded

Runtimes unload idle models to free memory. The first suggestion after an unload waits several seconds while the model loads again. In Ollama, set a long keep-alive for the completion model so it stays resident. [How do I use Ollama?](https://localagi.co/ollama) shows where, and [How do I make it faster?](https://localagi.co/tuning-for-speed) covers the rest of the latency knobs.
