Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion examples/models/parakeet/tokenizer_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

namespace {

// SentencePiece's word-boundary marker, spelled as UTF-8 bytes so this remains
// a const char[] literal when compiled as C++20.
constexpr char kSentencePieceWordBoundary[] = "\xE2\x96\x81";

bool is_whitespace_only(const std::string& token) {
if (token.empty()) {
return true;
Expand Down Expand Up @@ -36,7 +40,7 @@ bool is_special_token(const std::string& token) {
if (token.rfind("##", 0) == 0) {
return true;
}
if (token.rfind(u8"▁", 0) == 0) {
if (token.rfind(kSentencePieceWordBoundary, 0) == 0) {
return true;
}
if (is_whitespace_only(token)) {
Expand Down
Loading