File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5284,18 +5284,14 @@ def set_vocab(self):
52845284 self .gguf_writer .add_token_type_count (self .hparams .get ("type_vocab_size" , 1 ))
52855285
52865286 # convert to phantom space vocab
5287- def phantom (tok ):
5288- if tok . startswith ( "[" ) and tok . endswith ( "]" ) :
5287+ def phantom (tok , toktype ):
5288+ if toktype != gguf . TokenType . NORMAL :
52895289 return tok
52905290 if tok .startswith ("##" ):
5291- suffix = tok [2 :]
5292- # If the suffix resembles a special token, keep the original to avoid collision
5293- # E.g., preserve "##[1]" to avoid conflict with an existing "[1]" token.
5294- if suffix .startswith ("[" ) and suffix .endswith ("]" ):
5295- return tok
5296- return suffix
5291+ return tok [2 :]
52975292 return "\u2581 " + tok
5298- tokens = list (map (phantom , tokens ))
5293+ assert len (tokens ) == len (toktypes )
5294+ tokens = list (map (phantom , tokens , toktypes ))
52995295
53005296 # add vocab to gguf
53015297 self .gguf_writer .add_tokenizer_model ("bert" )
You can’t perform that action at this time.
0 commit comments