Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/hf_tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <fstream>
#include <string>
#include <vector>
#include <limits>

// Third Party
#include <nlohmann/json.hpp>
Expand Down Expand Up @@ -475,7 +476,7 @@ Result<std::vector<uint64_t>> HFTokenizer::byte_pair_encode_(
key.c_str(),
start,
stop);
return uint64_t(0); // Return unknown token ID instead of padding
return std::numeric_limits<uint64_t>::max(); // Return unknown token ID instead of padding
}
});
}
Expand Down Expand Up @@ -521,7 +522,7 @@ std::vector<uint64_t> HFTokenizer::_byte_pair_merge(
}

uint64_t token_id = func(char_start, char_start + char_len);
if (token_id != 0) { // Assuming 0 is padding/error token
if (token_id != std::numeric_limits<uint64_t>::max()) {
word.add(token_id, char_len);
} else {
// Handle unknown character
Expand Down
Loading