add mixed_precision argument on ppl wikitext evaluation (#11813)
* fix: delete ipex extension import in ppl wikitext evaluation * feat: add mixed_precision argument on ppl wikitext evaluation * fix: delete mix_precision command in perplex evaluation for wikitext * fix: remove fp16 mixed-presicion argument * fix: Add a space. --------- Co-authored-by: Jinhe Tang <jin.tang1337@gmail.com>
This commit is contained in:
parent
828ab16537
commit
28d1c972da
1 changed files with 3 additions and 2 deletions
|
|
@ -20,7 +20,7 @@
|
||||||
import argparse
|
import argparse
|
||||||
import torch
|
import torch
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
from datasets import concatenate_datasets, load_dataset
|
from datasets import load_dataset
|
||||||
from ipex_llm.utils.common import invalidInputError
|
from ipex_llm.utils.common import invalidInputError
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -34,6 +34,7 @@ parser.add_argument("--device", type=str, default="xpu")
|
||||||
parser.add_argument("--precision", type=str, default="sym_int4")
|
parser.add_argument("--precision", type=str, default="sym_int4")
|
||||||
parser.add_argument("--use-cache", action="store_true")
|
parser.add_argument("--use-cache", action="store_true")
|
||||||
parser.add_argument("--max_length", type=int, default=None)
|
parser.add_argument("--max_length", type=int, default=None)
|
||||||
|
parser.add_argument("--mixed_precision", action="store_true")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.precision == "fp16": # ipex fp16
|
if args.precision == "fp16": # ipex fp16
|
||||||
|
|
@ -43,7 +44,7 @@ if args.precision == "fp16": # ipex fp16
|
||||||
else: # ipex-llm
|
else: # ipex-llm
|
||||||
from ipex_llm.transformers import AutoModelForCausalLM
|
from ipex_llm.transformers import AutoModelForCausalLM
|
||||||
model = AutoModelForCausalLM.from_pretrained(args.model_path, load_in_low_bit=args.precision,
|
model = AutoModelForCausalLM.from_pretrained(args.model_path, load_in_low_bit=args.precision,
|
||||||
use_cache=args.use_cache, trust_remote_code=True)
|
use_cache=args.use_cache, trust_remote_code=True, mixed_precision= args.mixed_precision)
|
||||||
model = model.half()
|
model = model.half()
|
||||||
model = model.to(args.device)
|
model = model.to(args.device)
|
||||||
model = model.eval()
|
model = model.eval()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue