[Bugfix] Fix xgrammar failing to read a vocab_size from LlavaConfig on PixtralHF. (#11043)

This commit is contained in:
Jeff Cook 2024-12-09 23:54:22 -07:00 committed by GitHub
parent ebf778061d
commit e35879c276
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -148,7 +148,7 @@ class GrammarConfig:
else:
json_str = guided_params.json
return cls(json_str=json_str,
vocab_size=model_config.hf_config.vocab_size,
vocab_size=model_config.hf_text_config.vocab_size,
encoded_vocab=encoded_vocab,
stop_token_ids=stop_token_ids,
backend_str=backend_str,
@ -168,7 +168,7 @@ class GrammarConfig:
else:
grammar_str = guided_params.grammar
return cls(grammar_str=grammar_str,
vocab_size=model_config.hf_config.vocab_size,
vocab_size=model_config.hf_text_config.vocab_size,
encoded_vocab=encoded_vocab,
stop_token_ids=stop_token_ids,
backend_str=backend_str,
@ -176,7 +176,7 @@ class GrammarConfig:
max_threads=max_threads)
elif guided_params.json_object:
return cls(json_object=True,
vocab_size=model_config.hf_config.vocab_size,
vocab_size=model_config.hf_text_config.vocab_size,
encoded_vocab=encoded_vocab,
stop_token_ids=stop_token_ids,
backend_str=backend_str,