Views
No views yet
1
2optimum-cli export openvino --model .\Your Phi-4-mini path --task text-generation-with-past --weight-format int4 --sym --group-size 128 --ratio 0.6 --sym --trust-remote-code .\Your output Phi-4 OpenVINO location1
2from transformers import AutoConfig, AutoTokenizer
3from optimum.intel.openvino import OVModelForCausalLM
4
5model_dir = 'Your Phi-4-mini OpenVINO Path'
6
7ov_config = {"PERFORMANCE_HINT": "LATENCY", "NUM_STREAMS": "1", "CACHE_DIR": ""}
8
9ov_model = OVModelForCausalLM.from_pretrained(
10 model_dir,
11 device='GPU',
12 ov_config=ov_config,
13 config=AutoConfig.from_pretrained(model_dir, trust_remote_code=True),
14 trust_remote_code=True,
15)
16
17tok = AutoTokenizer.from_pretrained(model_dir, trust_remote_code=True)
18
19tokenizer_kwargs = {"add_special_tokens": False}
20
21prompt = "<|user|>\nI have $20,000 in my savings account, where I receive a 4% profit per year and payments twice a year. Can you please tell me how long it will take for me to become a millionaire? Also, can you please explain the math step by step as if you were explaining it to an uneducated person?\n<|end|><|assistant|>\n"
22
23input_tokens = tok(prompt, return_tensors="pt", **tokenizer_kwargs)
24
25answer = ov_model.generate(**input_tokens, max_new_tokens=1024)
26
27tok.batch_decode(answer, skip_special_tokens=True)[0]
28