Skip to content

Commit

Permalink
Merge pull request #21 from shawiz/main
Browse files Browse the repository at this point in the history
Pass false for special tokens to be compatible with llama.cpp commit 40f74e4
  • Loading branch information
eastriverlee authored Apr 27, 2024
2 parents a86ad40 + 0ac1019 commit 0b196e8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/LLM/LLM.swift
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,12 @@ extension Model {
public func decode(_ token: Token, with multibyteCharacter: inout [CUnsignedChar]) -> String {
var bufferLength = 16
var buffer: [CChar] = .init(repeating: 0, count: bufferLength)
let actualLength = Int(llama_token_to_piece(self, token, &buffer, Int32(bufferLength)))
let actualLength = Int(llama_token_to_piece(self, token, &buffer, Int32(bufferLength), false))
guard 0 != actualLength else { return "" }
if actualLength < 0 {
bufferLength = -actualLength
buffer = .init(repeating: 0, count: bufferLength)
llama_token_to_piece(self, token, &buffer, Int32(bufferLength))
llama_token_to_piece(self, token, &buffer, Int32(bufferLength), false)
} else {
buffer.removeLast(bufferLength - actualLength)
}
Expand Down

0 comments on commit 0b196e8

Please sign in to comment.