Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import PeftModel
3
4# Load base model
5base_model = "microsoft/Phi-3-mini-4k-instruct"
6model = AutoModelForCausalLM.from_pretrained(
7 base_model,
8 torch_dtype="auto",
9 device_map="auto"
10)
11
12# Load LoRA adapters
13model = PeftModel.from_pretrained(model, "aamanlamba/phi3-payments-finetune")
14tokenizer = AutoTokenizer.from_pretrained(base_model)
15
16# Generate description
17prompt = """<|system|>
18You are a financial services assistant that explains payment transactions in clear, customer-friendly language.<|end|>
19<|user|>
20Convert the following structured payment information into a natural explanation:
21
22inform(transaction_type[payment], amount[1500.00], currency[USD], sender[Acme Corp], receiver[Global Supplies Inc], status[completed], method[ACH], date[2024-10-27])<|end|>
23<|assistant|>
24"""
25
26inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
27outputs = model.generate(**inputs, max_new_tokens=150, temperature=0.7)
28response = tokenizer.decode(outputs[0], skip_special_tokens=True)
29print(response)Your ACH payment of $1,500.00 to Global Supplies Inc was successfully completed on October 27, 2024.1@misc{phi3-payments-finetuned,
2 author = {aamanlamba},
3 title = {Phi-3 Mini Fine-tuned for Payments Domain},
4 year = {2024},
5 publisher = {HuggingFace},
6 howpublished = {\url{https://huggingface.co/aamanlamba/phi3-payments-finetune}}
7}