from transformers import AutoModelForCausalLM, AutoTokenizer model_id = "finndot/finnai-slm-v4"tokenizer = AutoTokenizer.from_pretrained(model_id)model = AutoModelForCausalLM.from_pretrained( model_id, torch_dtype="bfloat16", device_map="auto") messages = [ { "role": "system", "content": ( "Extract transaction details from this SMS as JSON: " "{amount, merchant, type, account, balance, category}. " "type is one of: INCOME, EXPENSE, CREDIT, TRANSFER, INVESTMENT. " "If this is not a transaction (OTP, promo, KYC), return {}." ), }, { "role": "user", "content": "HDFC Bank: Rs.499.00 debited from A/c XX1234 to SWIGGY via UPI. Avl Bal Rs.15000.50", },]text = tokenizer.apply_chat_template( messages, tokenize=False, add_generation_prompt=True, enable_thinking=False)inputs = tokenizer(text, return_tensors="pt").to(model.device)out = model.generate(**inputs, max_new_tokens=256, do_sample=False)print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))