@@ -2474,7 +2474,6 @@ def __init__(self, *args, **kwargs):
24742474
24752475 def set_vocab (self ):
24762476 self ._set_vocab_gpt2 ()
2477- self .gguf_writer .add_add_bos_token (True )
24782477
24792478 def set_gguf_parameters (self ):
24802479 super ().set_gguf_parameters ()
@@ -4247,9 +4246,6 @@ def _xlmroberta_set_vocab(self) -> None:
42474246 special_vocab = gguf .SpecialVocab (self .dir_model , n_vocab = len (tokens ))
42484247 special_vocab .add_to_gguf (self .gguf_writer )
42494248
4250- self .gguf_writer .add_add_bos_token (True )
4251- self .gguf_writer .add_add_eos_token (True )
4252-
42534249
42544250@ModelBase .register ("DistilBertModel" , "DistilBertForMaskedLM" , "DistilBertForSequenceClassification" )
42554251class DistilBertModel (BertModel ):
@@ -4291,8 +4287,6 @@ def set_vocab(self):
42914287 bpe_tok_path = self .dir_model / "tokenizer.json"
42924288 if bpe_tok_path .exists ():
42934289 self ._set_vocab_gpt2 ()
4294- self .gguf_writer .add_add_bos_token (True )
4295- self .gguf_writer .add_add_eos_token (True )
42964290
42974291 # we need this to validate the size of the token_type embeddings
42984292 # though currently we are passing all zeros to the token_type embeddings
@@ -5177,8 +5171,6 @@ def set_vocab(self):
51775171 self .gguf_writer .add_token_type_count (2 )
51785172 else :
51795173 raise NotImplementedError (f'Tokenizer { tokenizer_class } is not supported for JinaBertModel' )
5180- self .gguf_writer .add_add_bos_token (True )
5181- self .gguf_writer .add_add_eos_token (True )
51825174
51835175
51845176@ModelBase .register ("OpenELMForCausalLM" )
@@ -5780,9 +5772,6 @@ def set_vocab(self):
57805772 special_vocab = gguf .SpecialVocab (self .dir_model , n_vocab = len (tokens ))
57815773 special_vocab .add_to_gguf (self .gguf_writer )
57825774
5783- self .gguf_writer .add_add_bos_token (False )
5784- self .gguf_writer .add_add_eos_token (True )
5785-
57865775 def set_gguf_parameters (self ):
57875776 if (n_ctx := self .find_hparam (["n_positions" ], optional = True )) is None :
57885777 logger .warning ("Couldn't find context length in config.json, assuming default value of 512" )
@@ -5920,9 +5909,6 @@ def set_vocab(self):
59205909 special_vocab = gguf .SpecialVocab (self .dir_model , n_vocab = len (tokens ))
59215910 special_vocab .add_to_gguf (self .gguf_writer )
59225911
5923- self .gguf_writer .add_add_bos_token (False )
5924- self .gguf_writer .add_add_eos_token (True )
5925-
59265912 def set_gguf_parameters (self ):
59275913 if (n_ctx := self .find_hparam (["n_positions" ], optional = True )) is None :
59285914 logger .warning ("Couldn't find context length in config.json, assuming default value of 512" )
@@ -6718,8 +6704,8 @@ def parse_args() -> argparse.Namespace:
67186704 help = "model is executed on big endian machine" ,
67196705 )
67206706 parser .add_argument (
6721- "model" , type = Path ,
6722- help = "directory containing model file" ,
6707+ "model" , type = str ,
6708+ help = "directory containing model file or huggingface repository ID (if --remote) " ,
67236709 nargs = "?" ,
67246710 )
67256711 parser .add_argument (
@@ -6826,18 +6812,20 @@ def main() -> None:
68266812 else :
68276813 logging .basicConfig (level = logging .INFO )
68286814
6829- dir_model = args .model
6830-
68316815 if args .remote :
6816+ hf_repo_id = args .model
68326817 from huggingface_hub import snapshot_download
68336818 local_dir = snapshot_download (
6834- repo_id = str ( dir_model ) ,
6819+ repo_id = hf_repo_id ,
68356820 allow_patterns = ["LICENSE" , "*.json" , "*.md" , "*.txt" , "tokenizer.model" ])
68366821 dir_model = Path (local_dir )
68376822 logger .info (f"Downloaded config and tokenizer to { local_dir } " )
6823+ else :
6824+ hf_repo_id = None
6825+ dir_model = Path (args .model )
68386826
68396827 if not dir_model .is_dir ():
6840- logger .error (f'Error: { args . model } is not a directory' )
6828+ logger .error (f'Error: { dir_model } is not a directory' )
68416829 sys .exit (1 )
68426830
68436831 ftype_map : dict [str , gguf .LlamaFileType ] = {
@@ -6910,9 +6898,9 @@ def main() -> None:
69106898
69116899 if args .outfile is not None :
69126900 fname_out = args .outfile
6913- elif args . remote :
6901+ elif hf_repo_id :
69146902 # if remote, use the model ID as the output file name
6915- fname_out = Path ("./" + str ( args . model ) .replace ("/" , "-" ) + "-{ftype}.gguf" )
6903+ fname_out = Path ("./" + hf_repo_id .replace ("/" , "-" ) + "-{ftype}.gguf" )
69166904 else :
69176905 fname_out = dir_model
69186906
@@ -6942,7 +6930,7 @@ def main() -> None:
69426930 split_max_tensors = args .split_max_tensors ,
69436931 split_max_size = split_str_to_n_bytes (args .split_max_size ), dry_run = args .dry_run ,
69446932 small_first_shard = args .no_tensor_first_split ,
6945- remote_hf_model_id = str ( args . model ) if args . remote else None ,
6933+ remote_hf_model_id = hf_repo_id ,
69466934 thread_count = args .threads )
69476935
69486936 if args .vocab_only :
0 commit comments