1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4# Model and Tokenizer
5model_id = 'FINGU-AI/Qwen2.5-32B-Lora-HQ-e-635'
6model = AutoModelForCausalLM.from_pretrained(model_id, attn_implementation="sdpa", torch_dtype=torch.bfloat16)
7tokenizer = AutoTokenizer.from_pretrained(model_id)
8model.to('cuda')
9
10# Input Messages for Translation
11messages = [
12 {"role": "system", "content": "translate korean to Uzbek"},
13 {"role": "user", "content": """새로운 은행 계좌를 개설하는 절차는 다음과 같습니다:
14
151. 계좌 개설 목적과 신분 확인을 위한 서류 제출
162. 서류 검토 과정을 거치는 것
173. 고객님의 신원 확인 절차를 진행하는 것
184. 모든 절차가 완료되면 계좌 개설이 가능합니다.
19
20계좌 개설을 원하시는 경우, 신분증과 함께 방문해 주시면 됩니다.
21 """},
22]
23
24# Tokenize and Generate Response
25input_ids = tokenizer.apply_chat_template(
26 messages,
27 add_generation_prompt=True,
28 return_tensors="pt"
29).to('cuda')
30
31outputs = model.generate(
32 input_ids,
33 max_new_tokens=500,
34 do_sample=True,
35)
36
37# Decode and Print the Translation
38response = outputs[0][input_ids.shape[-1]:]
39print(tokenizer.decode(response, skip_special_tokens=True))