|
from transformers import AutoTokenizer |
|
from optimum.intel import OVModelForCausalLM |
|
|
|
model_path = "helenai/ibm-granite-granite-8b-code-instruct-ov" |
|
tokenizer = AutoTokenizer.from_pretrained(model_path) |
|
model = OVModelForCausalLM.from_pretrained(model_path) |
|
|
|
|
|
chat = [ |
|
{ "role": "user", "content": "Write a code to find the maximum value in a list of numbers." }, |
|
] |
|
chat = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True) |
|
|
|
input_tokens = tokenizer(chat, return_tensors="pt") |
|
|
|
output = model.generate(**input_tokens, max_new_tokens=100) |
|
|
|
output = tokenizer.batch_decode(output) |
|
|
|
for i in output: |
|
print(i) |