Skip to content

Commit 2f2c9a2

Browse files
authored
fix trust remote for llm examples (#1537)
1 parent 49ab28d commit 2f2c9a2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

examples/pytorch/nlp/huggingface_models/language-modeling/quantization/llm/run_clm_no_trainer.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def get_user_model():
207207
trust_remote_code=args.trust_remote_code,
208208
revision=args.revision,
209209
)
210-
tokenizer = AutoTokenizer.from_pretrained(args.model)
210+
tokenizer = AutoTokenizer.from_pretrained(args.model, trust_remote_code=args.trust_remote_code)
211211
if args.approach == 'weight_only':
212212
user_model = user_model.float()
213213

@@ -380,7 +380,7 @@ def eval_func(model):
380380
if args.code_generation:
381381
from intel_extension_for_transformers.llm.evaluation.lm_code_eval import evaluate
382382
from transformers import AutoTokenizer
383-
tokenizer = AutoTokenizer.from_pretrained(args.model)
383+
tokenizer = AutoTokenizer.from_pretrained(args.model, trust_remote_code=args.trust_remote_code)
384384
results = evaluate(
385385
model=user_model,
386386
tokenizer=tokenizer,
@@ -419,7 +419,8 @@ def eval_func(model):
419419
start = time.time()
420420
results = evaluate(
421421
model="hf-causal",
422-
model_args='pretrained=' + args.model + ',tokenizer=' + args.model + ',dtype=float32',
422+
model_args='pretrained=' + args.model + ',tokenizer=' + args.model \
423+
+ ',dtype=float32' + ",trust_remote_code=" + str(args.trust_remote_code),
423424
user_model=user_model,
424425
batch_size=args.batch_size,
425426
tasks=args.tasks,
@@ -429,6 +430,8 @@ def eval_func(model):
429430
for task_name in args.tasks:
430431
if task_name == "wikitext":
431432
acc = results["results"][task_name]["word_perplexity"]
433+
elif task_name == "truthfulqa_mc":
434+
acc = results["results"][task_name]["mc1"]
432435
else:
433436
acc = results["results"][task_name]["acc"]
434437
print("Accuracy: %.5f" % acc)

0 commit comments

Comments
 (0)