from transformers import AutoModelForCausalLM, AutoTokenizer # Target repository pathmodel_name = "izyya/Typhoon-llama3.2-Izy-Translate-EN-TH-1B" # Load the tokenizer and the modeltokenizer = AutoTokenizer.from_pretrained(model_name)model = AutoModelForCausalLM.from_pretrained( model_name, torch_dtype="auto", device_map="auto") # Prepare the translation input snippetprompt = """Translate the following English text to Thai. ### English:But friends, I am so gay, that if I had a wife, I would encourage her to cheat on me.""" messages = [ {"role": "user", "content": prompt}] text = tokenizer.apply_chat_template( messages, tokenize=False, add_generation_prompt=True) model_inputs = tokenizer([text], return_tensors="pt").to(model.device) # Conduct text completiongenerated_ids = model.generate( **model_inputs, max_new_tokens=512) output_ids = generated_ids[0][len(model_inputs.input_ids[0]):]content = tokenizer.decode(output_ids, skip_special_tokens=True).strip("\n") print("content:", content)