Instructions to use FINGU-AI/FinguAI-Chat-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use FINGU-AI/FinguAI-Chat-v1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="FINGU-AI/FinguAI-Chat-v1") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("FINGU-AI/FinguAI-Chat-v1") model = AutoModelForCausalLM.from_pretrained("FINGU-AI/FinguAI-Chat-v1") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use FINGU-AI/FinguAI-Chat-v1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "FINGU-AI/FinguAI-Chat-v1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FINGU-AI/FinguAI-Chat-v1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/FINGU-AI/FinguAI-Chat-v1
- SGLang
How to use FINGU-AI/FinguAI-Chat-v1 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "FINGU-AI/FinguAI-Chat-v1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FINGU-AI/FinguAI-Chat-v1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "FINGU-AI/FinguAI-Chat-v1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FINGU-AI/FinguAI-Chat-v1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use FINGU-AI/FinguAI-Chat-v1 with Docker Model Runner:
docker model run hf.co/FINGU-AI/FinguAI-Chat-v1
How to Optimize Prompt Engineering for Financial Advice from the FinguAI Language Model?
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:
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?
Apologize, we are still improving the model. This is just for experiment.