allocate a large enough tokens slice
This commit is contained in:
parent
6d6b0d3321
commit
b71c67b6ba
1 changed files with 1 additions and 1 deletions
|
@ -168,7 +168,7 @@ func (llm *llama) tokenize(prompt string) []C.llama_token {
|
|||
cPrompt := C.CString(prompt)
|
||||
defer C.free(unsafe.Pointer(cPrompt))
|
||||
|
||||
tokens := make([]C.llama_token, llm.NumCtx)
|
||||
tokens := make([]C.llama_token, len(prompt)+1)
|
||||
if n := C.llama_tokenize(llm.ctx, cPrompt, unsafe.SliceData(tokens), C.int(len(tokens)), true); n > 0 {
|
||||
return tokens[:n]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue