Error: Context length exceeded (13,219 tokens). Cannot compress further.

#12
by dbrzezinsky - opened

I have downloaded BF16 model and using in hermes UI and local model not works. In VSCode error appeared

'Sorry, your request failed. Please try again. Client Request Id: xxxx
Reason: Request Failed: 400 {"error":{"message":"{"error":{"code":400,"message":"request (27086 tokens) exceeds the available context size (4096 tokens), try increasing it","type":"exceed_context_size_error","n_prompt_tokens":27086,"n_ctx":4096}}","type":"invalid_request_error","param":null,"code":null}} : Error: Request Failed: 400 {"error":{"message":"{"error":{"code":400,"message":"request (27086 tokens) exceeds the available context size (4096 tokens), try increasing it","type":"exceed_context_size_error","n_prompt_tokens":27086,"n_ctx":4096}}","type":"invalid_request_error","param":null,"code":null}}'

I added parameter:
'context length 1048576'

and what's next to add?

Hey @dbrzezinsky

It seems you are running via llama.cpp, your error message shows
"n_ctx":4096
This is too little you need to increase the context you are serving the model with

This is usally in your launch parameters

But how change that values as default in files?

It’s part of the llama.cpp server params. Typically prefixed with one or more dashes. How did you run llama.cpp? Share the command you ran, and your machine setup / specs. The full context length will need around 96GB of VRAM unless you are quantizing the KV cache. Watching a 5 minute YouTube tutorial can save you a lot of frustration.

If ure using the chat that is shipped with VS Code (CTRL+ALT+I), just press the hotkey CTRL+SHIFT+P and search Language Models JSON, press enter. In this file you can configure Endpoints and models. Here an example of a llama endpoint:

[
  {
    "name": "llama",
    "vendor": "customendpoint",
    "apiType": "chat-completions",
    "models": [
      {
        "id": "Qwythos-9B-Claude-Mythos-5-1M-MTP-Q5_K_M.gguf",
        "name": "Qwythos-9B-Claude-Mythos-5-1M-MTP-Q5_K_M.gguf",
        "url": "http://127.0.0.1:8080",
        "toolCalling": true,
        "vision": false,
        "maxInputTokens": 262144,
        "maxOutputTokens": 0
      }
    ]
  }
]

(If you load the mmproj file, set vision to true)

Edit: this just an additional step to make sure, that the model has the correct context length (or is generally correctly configured), as Bellesteck already said, you need to specify it when loading the model with llama.cpp.

Sign up or log in to comment