Spaces:
Sleeping
Sleeping
File size: 846 Bytes
923c242 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from transformers import pipeline
# Load a free model for text generation
llm_pipeline = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct", device_map="auto")
def analyze_spending_pattern(df):
prompt = f"""
Here is the user's spending data:
{df.to_string(index=False)}
Identify spending trends, categorize expenses, and highlight areas for cost-saving.
"""
response = llm_pipeline(prompt, max_length=200, do_sample=True)
return response[0]['generated_text']
def get_financial_advice(df):
prompt = f"""
Given the following transaction history:
{df.to_string(index=False)}
Provide personalized recommendations to reduce expenses and improve financial health.
"""
response = llm_pipeline(prompt, max_length=200, do_sample=True)
return response[0]['generated_text'] |