Skip to content

Commit 2f5a72f

Browse files
committed
handle mask token in modern-bert bpe
1 parent 03693fa commit 2f5a72f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/llama-vocab.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,6 +2103,12 @@ void llama_vocab::impl::load(llama_model_loader & ml, const LLM_KV & kv) {
21032103
} else {
21042104
_set_token_attr("<mask>", LLAMA_TOKEN_ATTR_LSTRIP, true);
21052105
}
2106+
} else if (_contains_any(general_arch, {"modern-bert"})) {
2107+
if (token_to_id.count("[MASK]") == 0) {
2108+
LLAMA_LOG_WARN("%s: Mask token is missing in vocab, please reconvert model!\n", __func__);
2109+
} else {
2110+
_set_token_attr("[MASK]", LLAMA_TOKEN_ATTR_LSTRIP, true);
2111+
}
21062112
} else if (_contains_any(model_name, {"phi-3", "phi3"})) {
21072113
for (auto id : cache_special_tokens) {
21082114
_set_tokenid_attr(id, LLAMA_TOKEN_ATTR_RSTRIP, true);

0 commit comments

Comments
 (0)