from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
import os
device = "cuda"
device_map = {
"lm_head": device,
"model": device
}
model_name = "piotr-ai/polanka-qwen2-3b-v0.3-chat"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, device_map=device_map)
prompt = "Co to jest psychologia?"
messages = [
{"role": "system", "content": "Jeste艣 przydatnym asystentem."},
{"role": "assistant", "content": "Witam, jak mog臋 pom贸c?"},
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(messages, tokenize=False)
model_inputs = tokenizer([text], return_tensors="pt").to(device)
generated_ids = model.generate(
model_inputs.input_ids,
max_new_tokens=256,
num_return_sequences=1,
eos_token_id=tokenizer.convert_tokens_to_ids('<|im_end|>'),
pad_token_id=tokenizer.eos_token_id
)
print(tokenizer.decode(generated_ids[0]))
<|im_start|>system
Jeste艣 przydatnym asystentem.<|im_end|>
<|im_start|>assistant
Witam, jak mog臋 pom贸c?<|im_end|>
<|im_start|>user
Co to jest psychologia?<|im_end|>
<|im_start|>assistant
Psychologia to nauka badaj膮ca zachowanie i procesy umys艂owe. Jest to ga艂膮藕 psychologii, kt贸ra koncentruje si臋 na zrozumieniu i wyja艣nianiu zachowa艅 i proces贸w umys艂owych.<|im_end|>
- Downloads last month
- 2,544
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social
visibility and check back later, or deploy to Inference Endpoints (dedicated)
instead.