Add --use_fast option (closes #3741)

This commit is contained in:
oobabooga 2023-09-25 12:19:43 -07:00
parent b973b91d73
commit d0d221df49
6 changed files with 22 additions and 13 deletions

View file

@ -99,18 +99,14 @@ def load_tokenizer(model_name, model):
if any(s in model_name.lower() for s in ['gpt-4chan', 'gpt4chan']) and Path(f"{shared.args.model_dir}/gpt-j-6B/").exists():
tokenizer = AutoTokenizer.from_pretrained(Path(f"{shared.args.model_dir}/gpt-j-6B/"))
elif path_to_model.exists():
try:
tokenizer = AutoTokenizer.from_pretrained(
path_to_model,
trust_remote_code=shared.args.trust_remote_code,
use_fast=False
)
except ValueError:
tokenizer = AutoTokenizer.from_pretrained(
path_to_model,
trust_remote_code=shared.args.trust_remote_code,
use_fast=True
)
if shared.args.use_fast:
logger.info('Loading the tokenizer with use_fast=True.')
tokenizer = AutoTokenizer.from_pretrained(
path_to_model,
trust_remote_code=shared.args.trust_remote_code,
use_fast=shared.args.use_fast
)
return tokenizer
@ -249,10 +245,13 @@ def llamacpp_HF_loader(model_name):
logger.error("Could not load the model because a tokenizer in transformers format was not found. Please download oobabooga/llama-tokenizer.")
return None, None
if shared.args.use_fast:
logger.info('Loading the tokenizer with use_fast=True.')
tokenizer = AutoTokenizer.from_pretrained(
path,
trust_remote_code=shared.args.trust_remote_code,
use_fast=False
use_fast=shared.args.use_fast
)
model = LlamacppHF.from_pretrained(model_name)