Ujeshhh commited on
Commit
c75e97c
·
verified ·
1 Parent(s): 8bc6866

Update analysis.py

Browse files
Files changed (1) hide show
  1. analysis.py +17 -2
analysis.py CHANGED
@@ -1,9 +1,21 @@
1
  from transformers import pipeline
 
 
2
 
3
- # Use Mistral-7B instead of Google Gemma (No login required)
4
- llm_pipeline = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct", device_map="auto")
 
 
 
 
 
 
 
5
 
6
  def analyze_spending_pattern(df):
 
 
 
7
  prompt = f"""
8
  Here is the user's spending data:
9
  {df.to_string(index=False)}
@@ -14,6 +26,9 @@ def analyze_spending_pattern(df):
14
  return response[0]['generated_text']
15
 
16
  def get_financial_advice(df):
 
 
 
17
  prompt = f"""
18
  Given the following transaction history:
19
  {df.to_string(index=False)}
 
1
  from transformers import pipeline
2
+ from huggingface_hub import login
3
+ import pandas as pd
4
 
5
+ # 🔹 OPTIONAL: Authenticate if using a gated/private model
6
+ # login(token="your_huggingface_token") # Uncomment and replace if needed
7
+
8
+ # ✅ Use a Free Model (Mistral-7B-v0.1 OR Gemma-2B)
9
+ MODEL_NAME = "mistralai/Mistral-7B-v0.1" # Publicly available
10
+ # MODEL_NAME = "google/gemma-2b" # Alternative (smaller but open-access)
11
+
12
+ # Load the text generation model
13
+ llm_pipeline = pipeline("text-generation", model=MODEL_NAME, device_map="auto")
14
 
15
  def analyze_spending_pattern(df):
16
+ """
17
+ Analyze the user's spending behavior.
18
+ """
19
  prompt = f"""
20
  Here is the user's spending data:
21
  {df.to_string(index=False)}
 
26
  return response[0]['generated_text']
27
 
28
  def get_financial_advice(df):
29
+ """
30
+ Provide personalized financial recommendations.
31
+ """
32
  prompt = f"""
33
  Given the following transaction history:
34
  {df.to_string(index=False)}