import torch
from transformers import pipeline
pipe = pipeline(
"text-generation",
model="google/gemma-2-2b-it",
model_kwargs={"torch_dtype": torch.bfloat16},
device="cuda", # replace with "mps" to run on a Mac device
)
messages = [
{"role": "system", "content": "You always put ^^ end of text"},
{"role": "user", "content": "Hello?"},
{"role": "assistant", "content": "Hi^^"},
{"role": "user", "content": "What is your name?"},
]
outputs = pipe(messages, max_new_tokens=256)
assistant_response = outputs[0]["generated_text"][-1]["content"].strip()
print(assistant_response)