Context Length and VRAM for Local AI, Explained

When you chat with a local AI model, it can only 'remember' a limited amount of text. That limit is the context length. A longer context lets the model handle bigger documents and longer chats, but it needs more memory. This guide explains the trade-off, and how to choose a size that fits your PC.
What is context length?
Models read text in small pieces called tokens. In English, one token is roughly three quarters of a word, so 1,000 words is about 1,300 tokens. The context length is the number of tokens the model can look at at once: your prompt, the conversation so far and its own answer.
Why does context use memory?
While the model works, it stores data about every token it has seen, so it does not have to recompute it. This store is often called the KV cache. The longer the context, the bigger the cache. Depending on the model and the context length, it can add anywhere from a few hundred megabytes to several gigabytes on top of the model itself.
That is why a model that fits with a short context can run out of memory with a long one.
Step-by-step: choose a context length
Step 1: Check your VRAM
Open Task Manager > Performance > GPU and note the Dedicated GPU memory. See how much VRAM you need to run AI models for the model sizes.
Step 2: Start with the default
Begin with the tool's default context length, usually a few thousand tokens. This is enough for normal chats and short documents.
Step 3: Raise it only when you need to
Increase the context length when you work with long documents or long conversations. In LM Studio the context length is a setting in the model's load options. In Ollama it is controlled by the num_ctx setting.
Step 4: Watch your memory
While the model answers, open Task Manager and watch Dedicated GPU memory. If it reaches the limit, the model slows down or fails with an out-of-memory error.
Step 5: If you run out of memory
- Lower the context length.
- Use a smaller quantization or a smaller model (see AI model quantization explained).
- Close other programs that use VRAM.
- Move fewer layers to the GPU, which trades speed for memory.
Step 6: Work around a small context
For a long document, split it into parts and ask about each part, or ask the model to summarize each part first.
Does a long context make answers better?
Not always. It lets the model see more, but very long contexts can be slower, and models can lose track of details in the middle. Use the length you need, not the maximum.
More help
For more guides on running AI on your own PC, and for general PC help, visit the PC Repair Atlas homepage. To set up a tool, see how to run an AI model locally on Windows.
FAQ
How many words is 4,096 tokens? Roughly 3,000 words of English text, though it varies.
Does context length change the model's file size? No. The file stays the same, but the memory used while running grows.
Do I need more RAM or more VRAM for a longer context? The memory used is on the GPU if the model runs there, so VRAM matters most.