]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commit
llama : fix time complexity of string replacement (#9163)
authorJustine Tunney <redacted>
Mon, 26 Aug 2024 06:09:53 +0000 (23:09 -0700)
committerGitHub <redacted>
Mon, 26 Aug 2024 06:09:53 +0000 (09:09 +0300)
commit436787f170329b3f549e6c2c46593d2af8482e7c
treecc30f686b30c888e50306a0bbb4ec525463d780f
parent93bc3839f980ff14be86efe408b4cd7e89b26835
llama : fix time complexity of string replacement (#9163)

This change fixes a bug where replacing text in a very long string could
cause llama.cpp to hang indefinitely. This is because the algorithm used
was quadratic, due to memmove() when s.replace() is called in a loop. It
seems most search results and LLM responses actually provide the O(n**2)
algorithm, which is a great tragedy. Using a builder string fixes things
common/common.cpp
examples/llava/clip.cpp
src/llama-impl.h