mdrokz / rust-llama.cpp

LLama.cpp rust bindings
https://crates.io/crates/llama_cpp_rs/
MIT License
290 stars 42 forks source link

fix missized vec #35

Closed kallsyms closed 5 months ago

kallsyms commented 5 months ago

This PR changes the way data is passed back from C to rust, primarily to fix a heap overflow. The out vec is currently allocated with capacity = the number of tokens to predict, however the data copied into out is the full detokenized string, which always has length > the number of tokens. This means every predict() call with a specified token count overflows the out vec's heap allocation.

msuiche commented 5 months ago

well done