Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

llama.vim : plugin for Neovim#9787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ggerganov merged 42 commits intomasterfromllama.vim
Oct 21, 2024
Merged

llama.vim : plugin for Neovim#9787

ggerganov merged 42 commits intomasterfromllama.vim
Oct 21, 2024

Conversation

@ggerganov
Copy link
Member

@ggerganovggerganov commentedOct 8, 2024
edited
Loading

refggml-org/p1#1

The plugin is now developed here:https://github.com/ggml-org/llama.vim

Overview

Add a simple Neovim plugin for local LLM-assisted code/text completion.

Features

  • Auto-suggest on cursor movement inInsert mode
  • Toggle the suggestion manually by pressingCtrl+F
  • Accept a suggestion withTab
  • Accept the first line of a suggestion withShift+Tab
  • Control max text generation time
  • Configure scope of context around the cursor
  • Ring context with chunks from open and edited files and yanked text
  • Supports very large contexts even on low-end hardware via smart context reuse
  • Display performance stats
image

Usage

  • Setup allama-server instance with a FIM-compatible model (RoPE required). For example:

    llama-server \    --hf-repo ggerganov/Qwen2.5-Coder-1.5B-Q8_0-GGUF \    --hf-file qwen2.5-coder-1.5b-q8_0.gguf \    --port 8012 -ngl 99 -fa -ub 1024 -b 1024 -dt 0.1 \    --cache-reuse 256

    works best with Qwen2.5-Coder models (not Instruct)

  • Copy or symlinkexamples/llama.vim to~/.config/nvim/autoload/llama.vim

  • Start Neovim and run:

    :callllama#init()

For more advanced options, check the parameters ing:llama_config inexamples/llama.vim:

https://github.com/ggerganov/llama.cpp/blob/acf6d1909ca38cbd5e057debbd291e89205c3afc/examples/llama.vim#L43-L86

Sample configs based on hardware

High-end hardware with GPU

# llama-server: 7B LLM or above--batch 2048--flash-attn# llama.vim:g:llama_config.ring_n_chunks   = 64g:llama_config.ring_chunk_size = 64

Mid-end hardware with GPU

# llama-server: 1.5B or 7B LLM--batch [512, 1024]--ctx-size [8192, 32768]--flash-attn# llama.vim:g:llama_config.ring_n_chunks   = [32, 64]g:llama_config.ring_chunk_size = [32, 64]

Low-end hardware with GPU

# llama-server: 1.5B LLM--batch [512, 1024]--ctx-size [2048, 8192]--flash-attn# llama.vim:g:llama_config.ring_n_chunks   = [4, 16]g:llama_config.ring_chunk_size = [16, 32]

Low-end hardware (CPU only)

# llama-server: 1.5B LLM--batch [256, 512]--ctx-size [1024, 4096]# llama.vim:g:llama_config.ring_n_chunks   = [0, 8]g:llama_config.ring_chunk_size = [16, 32]

Backend changes

Debugging

  • Startllama-server .. -lv 1
  • EnableGGML_DEBUG_SAMPLER_INFILL inllama-sampling.cpp

Technical details

The plugin uses the/infill endpoint of thellama-server. It sends asynchronous FIM requests to the server via thecurl tool:

letl:request=json_encode({\'input_prefix':l:prefix,\'input_suffix':l:suffix,\'input_extra':l:extra_context,\'prompt':l:prompt,\'n_predict':g:llama_config.n_predict,\'n_indent':l:indent,\'top_k':40,\'top_p':0.99,\'stream':v:false,\'samplers':         ["top_k","top_p","infill"],\'cache_prompt':v:true,\'t_max_prompt_ms':g:llama_config.t_max_prompt_ms,\'t_max_predict_ms':g:llama_config.t_max_predict_ms\})letl:curl_command=printf(\"curl --silent --no-buffer --request POST --url %s --header\"Content-Type: application/json\" --data %s",\g:llama_config.endpoint,shellescape(l:request)\)

The"input_prefix" and"input_suffix" are constructed by picking nearby lines around the cursor location:

lets:pos_x=col('.')-1lets:pos_y=line('.')letl:lines_prefix=getline(max([1,s:pos_y-g:llama_config.n_prefix]),s:pos_y-1)letl:lines_suffix=getline(s:pos_y+1,min([line('$'),s:pos_y+g:llama_config.n_suffix]))letl:prefix=""\.join(l:lines_prefix,"\n")lets:line_cur_suffix=strpart(s:line_cur,s:pos_x)letl:suffix=""\.s:line_cur_suffix\."\n"\.join(l:lines_suffix,"\n")\."\n"

The"prompt" is set as the text to the left of the cursor on the current line:

lets:line_cur_prefix=strpart(s:line_cur,0,s:pos_x)letl:prompt=""\.s:line_cur_prefix\."\n"

So far this is very a standard FIM completion using "local" context. Adding more and more context will usually improve the quality of the completion, but it will also increase the latency. As a datapoint, consider that a 7B LLM running on a 76 core M2 Ultra GPU roughly takes ~1 second to process 1000 tokens of context. Modern LLMs have training contexts of more than 32k tokens, so filling the entire context with local context and reprocessing it on each completion request is obviously not feasible for local completion, as it would be exceedingly slow. For good user experience, we aim at a latency of about ~1 second or less per completion suggestion, while utilizing the full context of the model at the same time. Read more on how we solve this problem further down the text.

Global context

In addition to the local context around the current cursor location, we can significantly improve the quality of the generated suggestions by including extra "global" context. This extra context can come either from other places in the same file that we are currently editing, or from other recently edited or opened files. There are a lot of different techniques for deciding which extra context specifically to include in the request that could be potentially relevant to the current completion task. In thellama.vim plugin, we use a simple approach:

  • We create a ring buffer ofg:llama_config.ring_n_chunks chunks ofg:llama_config.ring_chunk_size lines each
  • On every completion request we add 1 prefix and 1 suffix chunk, randomly picked relative to the cursor position but in a much larger scope (g:llama_config.ring_scope lines around the cursor)
  • Upon entering and leaving a Vim buffer, we pick a chunk around the last cursor position
  • Upon saving a file, we pick a chunk around the current cursor position
  • Upon yanking a text block, we add it as a chunk to the ring buffer
  • Upon trying to add a chunk, we evict old chunks that are very similar to the new one
" gather chunks upon yankingautocmdTextYankPost*ifv:event.operator==#'y' |calls:pick_chunk(v:event.regcontents,v:false,v:true) |endif" gather chunks upon entering/leaving a bufferautocmdBufEnter*calltimer_start(100, {->s:pick_chunk(getline(max([1,line('.')-g:llama_config.ring_chunk_size/2]), min([line('.') + g:llama_config.ring_chunk_size/2,line('$')])),v:true,v:true)})autocmdBufLeave*calls:pick_chunk(getline(max([1,line('.')-g:llama_config.ring_chunk_size/2]), min([line('.') + g:llama_config.ring_chunk_size/2,line('$')])),v:true,v:true)" gather chunk upon saving the fileautocmdBufWritePost*calls:pick_chunk(getline(max([1,line('.')-g:llama_config.ring_chunk_size/2]), min([line('.') + g:llama_config.ring_chunk_size/2,line('$')])),v:true,v:true)

Upon each FIM completion request, we now send both the local and global contexts together. The latter is passed through the"input_extra" field of the/infill request in the following format:

[    {        "filename": string        "text": string,    },    ... max of g:llama_config.ring_n_chunks ...]

With this design, as we edit the files in our Neovim session, the overall context grows to a certain amount (determined by the ring buffer size) and usually contains up-to-date relevant information for the editing task at hand. The specific events and logic for gathering chunks can be easily modified and customized if needed.

Note that the entire state of the context is stored client-side and is sent to the server on each request.

Server-side processing

Upon receiving a request withN extra context chunks, the server constructs the following repo-level FIM prompt:

<|repo_name|>{repo_name}" --\<|file_sep|>{filename_0}"   |{text_0}"   |<|file_sep|>{filename_1}"   | extra (global) prompt{text_1}"   |..."   |<|file_sep|>{filename_N-1}"   |{text_N-1}" --/<|file_sep|>{filename}" --\<|fim_prefix|>{prefix}<|fim_suffix|>{suffix}<|fim_middle|>{prompt}" --/ local FIM prompt

This is based on the work inhttps://arxiv.org/pdf/2409.12186. Note that not all models are trained for this pattern, so it is recommended to use models that support it, such asQwen2.5-Coder. This prompt format has important advantages that allow efficient context reuse, discussed in the following paragraphs.

In this FIM prompt, the components correspond to:

  • <|repo_name|>,<|file_sep|>,<|fim_prefix|>,<|fim_suffix|>,<|fim_middle|> - special tokens defined by the model
  • filename_i - thefilename of the i'th chunk in the"input_extra" array
  • text_i - thetext of the i'th chunk in the"input_extra" array
  • prefix,suffix,prompt - the input from the"input_prefix","input_suffix", and"prompt" fields of the request

The server processes the constructed prompt and then generates a maximum number of tokens that represent the FIM completion. The generation can be terminated early by several different conditions:

  • An end-of-generation (EOG) token is sampled
  • A maximum time-limit optionally specified by the client is exceed
  • An indentation constraint optionally specified by the client is not satisfied

The generated text is sent back to the client for display as a suggestion via virtual text overlay.

KV cache reuse : global prefix

The first optimization technique for improving long-context performance is to simply reuse the computed KV cache common prefix from the previous request. This allows us to very efficiently append new chunks of extra context, in-between the<|fim_prefix|> token and the existing chunks in the extra context:

<|repo_name|>{repo_name}" --\<|file_sep|>{filename_0}"   |{text_0}"   |<|file_sep|>{filename_1}"   | extra context, cached and reused (no processing){text_1}"   |..."   |<|file_sep|>{filename_N-1}"   |{text_N-1}" --/<|file_sep|>{filename_N}" --\ new chunk,{text_N}" --/ processed with the new request<|file_sep|>{filename}<|fim_prefix|>{prefix}<|fim_suffix|>{suffix}<|fim_middle|>{prompt}

Reusing the KV cache prefix is supported generally by thellama-server and requires simply to provide the"cache_prompt": true flag in the completion requests. With this option, each new completion request will reuse the largest common prefix of tokens between the old and the new request. This saves a large part of the prompt processing in situations where the extra context does not change, or was extended by appending a new chunk at the end.

KV cache reuse : context shift

The previous optimization is only useful up tog:ring_n_chunks chunks of extra context. When the ring buffer becomes full, the first chunk would be evicted and would therefore "shift" all following chunks into a new position relative to the start of the prompt:

<|repo_name|>{repo_name}" --\<|file_sep|>{filename_1}"   |{text_1}"   |<|file_sep|>{filename_2}"   | chunk 0 has been evicted{text_2}"   | the rest of the chunks have 'moved' one step towards the front..."   |<|file_sep|>{filename_N}"   |{text_N}" --/<|file_sep|>{filename}<|fim_prefix|>{prefix}<|fim_suffix|>{suffix}<|fim_middle|>{prompt}

Because of this relative shift ofD0 tokens, it is no longer possible to directly reuse the KV cache of the extra context. The reason for this is because the position of the tokens is encoded inside the KV cache data (e.g. via the RoPE operator) and now the tokens are no longer in those particular positions (for more info, see#71 (comment)).

However, quite early in the project (#2060), we realized that the cache in this case can actually be efficiently reused by "updating" the encoded positions in the K cache. This follows from the observation that theRoPE operator is "additive". Roughly speaking, applying a RoPE with positionp1 = p0 + d is equivalent to applying:

  • RoPE at positionp0
  • RoPE at positiond on the already RoPE'd data in the previous step

This provides a very cheap way to "move" the remaining chunks in the ring buffer forward, towards the beginning of the context: simply apply RoPE with position-D0 to all tokens in the K cache that we want to reuse. Doing so, we can again save the computation of a large portion of the extra prompt.

Note that the described context shifting method is not mathematically identical to recomputing the entire prompt from scratch. It can be easily seen that the embeddings at each token position are "entangled" with all the embeddings before that position, so simply "shifting" the K cache positions will not produce the exact same numbers as full reprocessing. Regardless of this, the context shifting feature has been applied and used by the localllama.cpp community for more than an year now and empirical results indicate that it is very effective and does not seem to degrade the quality of the output in a significant way. The cache reuse techniques described here heavily rely on this "trick".

The described context shifting strategy can also be applied when the evicted chunk is somewhere in the middle of the ring buffer or even if there are multiple evicted chunks at a time. A detailed description of the implementation can be found in#5793 and#9866.

This context reuse strategy requires thellama-server to be started with the--cache-reuse N command-line argument. TheN argument is the minimum size of the chunks (in number of tokens) that we will accept and shift in the KV cache for reuse purposes. The logic is that we don't want to reuse very small bits (e.g. individual tokens) from random places of the old context and instead we are interested in reusing large continuous blocks. Note that the implementation preserves the order of the reused chunks, so that a shifted chunk will never move over another chunk (i.e. reused chunks always appear in the same order to each other as when they were originally computed).

Applying these two techniques, we can now efficiently update the extra context of our FIM requests by adding and evicting chunks any way the client decides. Existing chunks will not be recomputed and the server will process only new chunks that were not present in the previous request. Thellama.vim plugging periodically updates the extra context ring buffer on the client side and sends the information to the server whenever it detects inactivity (i.e. the cursor hasn't moved for certain period of time or we are currently inNormal mode). This makes the processing of the extra global context almost entirely seamless for the user, mitigating a huge portion of the latency in the naive approach.

KV cache reuse : local prefix

Let's now focus again on the local context part of the request and explain one additional cache reuse strategy that helps to further reduce the completion latency in some typical cases. All of the following examples will assume the PSM (Prefix-Suffix-Middle) FIM pattern. Similar analysis can be made for the SPM (Suffix-Prefix-Middle) pattern which is supported via the--spm-infill command line argument ofllama-server.

" the PSM FIM pattern<|fim_prefix|>{prefix}<|fim_suffix|>{suffix}<|fim_middle|>{prompt}

Assume also that we are in the middle of editing a line of text and the client has already received a suggestion from the server:

" this is the text file that we are editing:{prefixlines outside the scope of the local FIM context}{prefix_line_1}{prefix_line_2}{prefix_line_3}...{prefix_line_P}{cur_line_prefix}█{cur_line_suffix}" --> currently have a completion suggestion for this position{suffix_line_1}{suffix_line_2}...{suffix_line_S}{suffixlines outside the scope of the local FIM context}

Here is how the local FIM prompt looks like in more details:

<|fim_prefix|>{prefix_line_1}{prefix_line_2}{prefix_line_3}...{prefix_line_P}<|fim_suffix|>{cur_line_suffix}{suffix_line_1}{suffix_line_2}...{suffix_line_S}<|fim_middle|>{cur_line_prefix}{generated_suggestion}

From here, there are 3 typical follow-up completion requests that occur in most situations:

  • Same line FIM: the cursor moves left or right on the same line
  • Next line FIM: the cursor moves to the next line
  • Prev line FIM: the cursor moves to the previous line

Same line FIM

For clarity, assume the cursor moved{dx} tokens to the right (moving to the left follows the same logic). The new FIM prompt would look like this:

<|fim_prefix|>{prefix_line_1}" --\{prefix_line_2}"   |{prefix_line_3}"   | the cache is reused from the previous request..."   |{prefix_line_P}" --/<|fim_suffix|>{cur_line_suffix- dx}" --\{suffix_line_1}"   |{suffix_line_2}"   |..."   | computed in the new request{suffix_line_S}"   |<|fim_middle|>{cur_line_prefix+ dx}" --/

In this case the entire local prefix will be reused since it's contents and position are the same as in the previous request. This means that attempting FIM anywhere on the same line will be quite cheap and will involve recomputing only the suffix tokens.

Next line FIM

In this case, the new FIM prompt after moving to the next line, looks like this:

<|fim_prefix|>{prefix_line_2}" --\{prefix_line_3}"   |{prefix_line_4}"   | the cache is reused from previous request via context shift..."   |{prefix_line_P}" --/{prefix_line_P+1}" --> this is a new line added to the FIM prefix<|fim_suffix|>{new_line_suffix}" --\{suffix_line_2}"   |{suffix_line_3}"   |..."   | computed in the new request{suffix_line_S+1}"   |<|fim_middle|>{new_line_prefix}" --/

The old{prefix_line_1} line is now out of the FIM prefix scope and a new{prefix_line_P+1} line is within the FIM prefix scope. We can reuse the cache for lines[2, P] via context shifting, as explained earlier. So in this case, we compute only the new prefix line{prefix_line_P+1}, together with the new FIM suffix.

Prev line FIM

This case is the most cache unfriendly one. Moving a line up, the new FIM prompt will look like this:

<|fim_prefix|>{prefix_line_0}" --> this line is completely new, so it breaks the cache reuse sequence very early{prefix_line_1}{prefix_line_2}...{prefix_line_P-1}<|fim_suffix|>{new_line_suffix}{suffix_line_0}{suffix_line_1}...{suffix_line_S-1}<|fim_middle|>{new_line_prefix}

Because we haven't computed the{prefix_line_0} line in the previous request, the cache reuse logic has to stop at the very start of the local FIM prompt. Therefore in this case we don't reuse any of the previous local FIM cache and we need to compute the entire local FIM prompt.

Expected performance

On each FIM request, the server takes a maximum of 1 full batch of tokens from the provided local context. The prefix and suffix tokens are split in a ratio of3:1:

https://github.com/ggerganov/llama.cpp/blob/32927e68b7fbfd6dfa82e531d186f1b6b22612ae/examples/server/server.cpp#L2055-L2062

This means that for new FIM requests, there will be at most--batch tokens to process, while in most cases the processed tokens would be much less due to the cache reuse optimizations described above. Knowing this, we can estimate the typical performance of FIM requests using thellama-batched-bench tool. Here are some analysis on M1 Pro and M2 Ultra usingQwen2.5-Coder 1.5B and 7B models:

M1 Pro

./llama-batched-bench -m models/qwen2.5-1.5b-coder/ggml-model-q8_0.gguf -c 32768 -b 1024 -npp 1024,2048,15360,16384,30720,31744 -ntg 32 -npl 1 -famain: n_kv_max = 32768, n_batch = 1024, n_ubatch = 512, flash_attn = 1, is_pp_shared = 0, n_gpu_layers = -1, n_threads = 8, n_threads_batch = 8
PPTGBN_KVT_PP sS_PP t/sT_TG sS_TG t/sT sS t/s
102432110560.8641184.900.44671.681.311805.71
204832120801.7571165.380.46169.352.219937.45
153603211539222.336687.680.67547.4223.011668.90
163843211641624.443670.310.69146.3025.134653.15
307203213075262.397492.340.93134.3763.328485.60
317443213177665.603483.880.94833.7566.551477.47

M2 Ultra

./llama-batched-bench -m models/qwen2.5-7b-coder/ggml-model-q8_0.gguf -c 32768 -b 1024 -npp 1024,2048,15360,16384,30720,31744 -ntg 32 -npl 1 -famain: n_kv_max = 32768, n_batch = 1024, n_ubatch = 512, flash_attn = 1, is_pp_shared = 0, n_gpu_layers = -1, n_threads = 16, n_threads_batch = 16
PPTGBN_KVT_PP sS_PP t/sT_TG sS_TG t/sT sS t/s
102432110560.8151257.060.48765.731.301811.40
204832120801.5971282.410.50563.332.102989.40
153603211539216.988904.180.74642.8917.734867.94
163843211641618.456887.760.77441.3519.229853.69
307203213075243.314709.241.02631.2044.340693.56
317443213177645.426698.801.04530.6346.471683.78

From these numbers we can estimate the prompt processing and text generation speeds, as well as the expected FIM time at different levels of context occupation. Here we assume that the FIM request would require to process 1/4 of--batch tokens as prompt and generate32 tokens as suggestion:

M1 Pro, LLM 1.5B, Q8_0:

- empty context: p: ~1150 t/s | g: ~70 t/s- half  context: p:  ~480 t/s | g: ~47 t/s- full  context: p:  ~320 t/s | g: ~34 t/s
  • expected FIM time in ms:

    batchemptyhalffull
    256512.80814.181141.18
    512568.45947.521341.18
    1024679.751214.181741.18

M2 Ultra, LLM 7B, Q8_0:

- empty context: p: ~1300 t/s | g: ~64 t/s- half  context: p:  ~700 t/s | g: ~42 t/s- full  context: p:  ~480 t/s | g: ~31 t/s
  • expected FIM time in ms:

    batchemptyhalffull
    256549.23853.331165.59
    512598.46944.761298.92
    1024696.921127.621565.59

Examples

Usingllama.vim on M1 Pro (2021) withQwen2.5-Coder 1.5B Q8_0:

image

The orange text is the generated suggestion. The green text contains performance stats for the FIM request: the currently used context is15186 tokens and the maximum is32768. There are30 chunks in the ring buffer with extra context (out of64). So far,1 chunk has been evicted in the current session and there are0 chunks in queue. The newly computed prompt tokens for this request were260 and the generated tokens were25. It took1245 ms to generate this suggestion after entering the letterc on the current line.

Usingllama.vim on M2 Ultra withQwen2.5-Coder 7B Q8_0:

llama.vim-0-lq.mp4

Demonstrates that the global context is accumulated and maintained across different files and showcases the overall latency when working in a large codebase.

TODO

  • add infill sampler
  • suggest gray text
  • auto-suggest
  • rolling context
  • clipboard/yanked contents
  • test if multi-user works (increase-np and-c as needed)
  • send current filename

Future ideas

  • Cleverer chunk collection (reranking?)
  • Display (and edit?) the extra context in Vim
  • https://github.com/junegunn/vim-plug support
  • Cache chunk tokenizations server-side and reuse
  • Cache completions client-side and reuse on auto FIM
  • Add Vim support
  • VS Code plugin

ngxson, Green-Sky, thorvaldur-arnar, lin72h, Vaibhavs10, erusev, astoilkov, Mihaiii, rgerganov, felladrin, and 9 more reacted with hooray emojingxson, lin72h, Vaibhavs10, thorvaldur-arnar, erusev, astoilkov, Mihaiii, he29-net, UncleGravity, felladrin, and 18 more reacted with heart emojierusev, astoilkov, Mihaiii, rgerganov, felladrin, lin72h, cwegener, pabl-o-ce, mtwebb, mounta11n, and 4 more reacted with rocket emoji
@ggerganovggerganovforce-pushed thellama.vim branch 2 times, most recently from73fa77d to391ea30CompareOctober 9, 2024 07:28
ggerganov added a commit that referenced this pull requestOct 9, 2024
An updated version will be added in#9787
@ggerganovggerganov changed the base branch frommaster togg/infill-0October 9, 2024 08:05
@ggerganovggerganovforce-pushed thellama.vim branch 2 times, most recently from76e5d87 tocefd4acCompareOctober 11, 2024 09:59
@ggerganovggerganov changed the titlellama : improve infill support + neovim pluginllama.vim : plugin for NeovimOct 11, 2024
@ggerganovggerganov marked this pull request as ready for reviewOctober 11, 2024 10:32
Base automatically changed fromgg/infill-0 tomasterOctober 12, 2024 05:21
@ggerganovggerganovforce-pushed thellama.vim branch 3 times, most recently fromc7d8904 tod2c559aCompareOctober 13, 2024 10:43
@ggerganovggerganov changed the base branch frommaster togg/server-reuse-contextOctober 13, 2024 10:45
Base automatically changed fromgg/server-reuse-context tomasterOctober 13, 2024 15:52
@ggerganovggerganovforce-pushed thellama.vim branch 3 times, most recently from5155b68 toacf6d19CompareOctober 15, 2024 14:19
@ggerganov
Copy link
MemberAuthor

This plugin (or script?) was quite fun to implement! Will be merging after a few days of testing. If anyone gives this a try, would be happy to hear any feedback. This is running pretty smooth on M2 Ultra with Qwen2.5 7B Q8, though I think it should work reasonably well even on lower end hardware.

Green-Sky, mtwebb, and mounta11n reacted with thumbs up emoji

@ggerganovggerganov merged commitdbd5f2f intomasterOct 21, 2024
1 check passed
@ggerganovggerganov deleted the llama.vim branchOctober 21, 2024 17:25
@Green-Sky
Copy link
Collaborator

You explicitly state neovim, but is there anything you use that prevents the use of vim?

@ggerganov
Copy link
MemberAuthor

As far as I know, the async job and virtual text APIs are a bit different in Vim. Though it's probably quite easy to adapt the script to work both with Vim and Neovim.

ggerganov added a commit that referenced this pull requestOct 21, 2024
'eol' messes up the rendering with nvim v0.10.2 for some reason
@m18coppola
Copy link
Contributor

@Green-Sky I have a treat for you in#9995

Green-Sky, mtwebb, and jsu-sc reacted with rocket emoji

@ggerganov
Copy link
MemberAuthor

Thellama.vim plugin is now available as a standalone repo athttps://github.com/ggml-org/llama.vim. This makes it possible to install the plugin through popular plugin managers.

Further development will continue in thehttps://github.com/ggml-org/llama.vim repo.

Green-Sky reacted with thumbs up emoji

dsx1986 pushed a commit to dsx1986/llama.cpp that referenced this pull requestOct 29, 2024
An updated version will be added inggml-org#9787
dsx1986 pushed a commit to dsx1986/llama.cpp that referenced this pull requestOct 29, 2024
dsx1986 pushed a commit to dsx1986/llama.cpp that referenced this pull requestOct 29, 2024
'eol' messes up the rendering with nvim v0.10.2 for some reason
dsx1986 pushed a commit to dsx1986/llama.cpp that referenced this pull requestOct 29, 2024
arthw pushed a commit to arthw/llama.cpp that referenced this pull requestNov 15, 2024
An updated version will be added inggml-org#9787
arthw pushed a commit to arthw/llama.cpp that referenced this pull requestNov 15, 2024
arthw pushed a commit to arthw/llama.cpp that referenced this pull requestNov 15, 2024
'eol' messes up the rendering with nvim v0.10.2 for some reason
arthw pushed a commit to arthw/llama.cpp that referenced this pull requestNov 15, 2024
arthw pushed a commit to arthw/llama.cpp that referenced this pull requestNov 18, 2024
An updated version will be added inggml-org#9787
arthw pushed a commit to arthw/llama.cpp that referenced this pull requestNov 18, 2024
arthw pushed a commit to arthw/llama.cpp that referenced this pull requestNov 18, 2024
'eol' messes up the rendering with nvim v0.10.2 for some reason
arthw pushed a commit to arthw/llama.cpp that referenced this pull requestNov 18, 2024
mjrusso added a commit to mjrusso/wingman that referenced this pull requestJul 3, 2025
The llama.cpp server relies heavily on KV cache reuse to achieve low-latencycompletions, as explained here:ggml-org/llama.cpp#9787When we send the contents of the ring buffer (via `input_extra`) for a FIMcompletion request, we only send chunks from the ring buffer that correspond tothe active project. (The llama.vim implementation does not have the concept ofan active project, only a single global ring buffer.)However, we were priming the KV cache in the background by sending *all* chunksfrom the global ring buffer, undermining the ability use reuse the KV cache forreal FIM completion requests.This commit changes the implementation of background cache priming to beproject aware, including chunks only from a single project per request.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@ggerganov@Green-Sky@m18coppola

[8]ページ先頭

©2009-2025 Movatter.jp