How to Optimize Prompt Engineering for Financial Advice from the FinguAI Language Model?

I’m working on a personal finance application that utilizes the FinguAI language model (https://huggingface.co/FINGU-AI/FinguAI-Chat-v1) to generate personalized insights and financial advice based on user-provided expense data. However, I’m facing challenges in getting the model to produce accurate and relevant responses.

Here’s what I’ve tried so far:

Simplified the input data and formatted it as JSON.
Iterated on various prompts, providing explicit instructions and desired output format.
Experimented with temperature and top-p parameters.
Despite these efforts, the model’s responses often lack accuracy, miss crucial details, or offer generic advice that’s not tailored to the specific user data.

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
import pandas as pd
from datetime import datetime, timedelta
import random
import json

# Define categories
categories = ["Groceries", "Utilities", "Entertainment", "Transport", "Rent", "Miscellaneous"]

# Generate dummy data (replace with your actual data later)
data = []
for i in range(30):
    date = (datetime.now() - timedelta(days=i)).strftime("%Y-%m-%d")
    category = random.choice(categories)
    amount = round(random.uniform(100, 1000), 2)  # Adjust random amount range for more realistic data
    description = f"{category} expense"
    data.append([date, category, amount, description])

df = pd.DataFrame(data, columns=["Date", "Category", "Amount", "Description"])
category_totals = df.groupby('Category')['Amount'].sum().to_dict()

# --- VARIABLES TO CHANGE ---
monthly_income = 5000  # Replace with the user's actual monthly income in ₹
# --- END VARIABLES TO CHANGE ---

# Format the category totals for the prompt
category_totals_string = "n".join([f"- {category}: ₹{amount:.2f}" for category, amount in category_totals.items()])

# Load the model and tokenizer
model_id = 'FINGU-AI/FinguAI-Chat-v1'
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16)
tokenizer = AutoTokenizer.from_pretrained(model_id)
streamer = TextStreamer(tokenizer)
model.to('cuda')  # Move model to GPU if available

# Create the prompt with improved instructions
prompt_template = """You are a financial advisor in India analyzing monthly expenses for a user earning ₹{income}.
Their goal is to improve financial health.

Analyze this spending data (in ₹):

{expenses_string}

Provide personalized insights and actionable suggestions focusing on:

1.  Top 2 highest spending categories and 2-3 specific, actionable ways to reduce spending in each.
2.  Lowest spending category and if any adjustments are needed there.
3.  Realistic monthly savings goal, considering their income and expenses.
4.  Overall financial health assessment, including strengths, weaknesses, and potential risks.
"""

prompt = prompt_template.format(income=monthly_income, expenses_string=category_totals_string)


# Tokenize the input
tokenized_chat = tokenizer.apply_chat_template([{"role": "user", "content": prompt}], tokenize=True, add_generation_prompt=True, return_tensors="pt").to("cuda")


# Set generation parameters
generation_params = {
    'max_new_tokens': 250,
    'use_cache': True,
    'do_sample': True,
    'temperature': 0.7,
    'top_p': 0.95,
    'top_k': 50,
    'eos_token_id': tokenizer.eos_token_id,
}

# Generate insights
outputs = model.generate(tokenized_chat, **generation_params, streamer=streamer)
decoded_outputs = tokenizer.batch_decode(outputs)

print(decoded_outputs[0])

response

Assessment of支出 in the user’s monthly expenses data:

  1. Entertainment: A notable expenditure that results in an average of around 1013.13 in姬ar Rupee ($). This category could be reduced by allocating funds towards hobbies or leisure activities that align with the user’s personality or interests. For example, investing in a subscription service like Netflix or shopping at local markets can be cost-effective alternatives to entertainment expenditures. Additionally, allocating a portion of the budget towards entertainment would allow for a more balanced and fulfilling lifestyle without compromising the quality of life. The user should prioritize spending in areas that bring them joy and fulfillment, such as self-care, hobbies, or hobbies that they enjoy. It’s crucial to track these amounts regularly to ensure continued satisfaction with their overall financial well-being and goals. 2. Groceries: In姬ar Rupee ($), groceries accounted for approximately $2590.55. To reduce expenses in grocery purchases, the user can adopt a portion-based approach, where they spend a portion of their姬ar Rupee per week on groceries. For instance, instead of spending full weeks on groceries, the user might allocate $50 in姬ar Rupee each month to purchase items that they

Prompt Engineering for Financial Advice from the FinguAI Language Model?

New contributor

Ramesh Adhikari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật