Spaces:
Sleeping
Sleeping
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'] |