--- pipeline_tag: text-generation library_name: gguf tags: - finance - phi3 - unsloth - llama-cpp - gguf-4bit --- # 📈 Financial Analyst AI (Phi-3 Mini 4K Instruct) This is a fine-tuned, 4-bit quantized (GGUF) version of Microsoft's `Phi-3-Mini-4k-instruct`, specialized in professional financial analysis, stock market valuation, and corporate finance. The model was trained using **Unsloth** on a financial instruction dataset and has been aggressively optimized for low-memory environments. It easily runs on standard laptops with less than **3GB of RAM** while maintaining high factual accuracy. --- # 🧠 Model Persona & Use Cases This model is explicitly trained to act as a **Professional Financial Analyst**. It is best used for: - Stock market analysis and valuation metrics - Corporate finance and accounting principles - Investment strategy and portfolio management - Explaining economic trends and market indicators - Risk assessment and financial modeling --- # 🚀 How to Use You can interact with this model directly in your browser, via Ollama, or using Python. --- ## Option 1: Hugging Face Widget You can test the model immediately using the **Hosted Inference API** widget on the right side of this page. > **Note:** Because this is a GGUF model, it may take **15–30 seconds** to load into Hugging Face's server RAM on the first prompt. --- ## Option 2: Run Locally via Ollama If you have Ollama installed, you can pull and run the model directly from this repository with a single command. It will automatically download the weights and apply the correct system prompt. ```bash ollama run hf.co/Wellwisher12/finance-phi3-gguf ``` --- ## Option 3: Run via Python (`main.py`) This repository includes `main.py` script that utilizes `llama-cpp-python` to run the model with strict memory constraints (`n_ctx=1024`) to prevent out-of-memory errors on local machines. ### Prerequisites ```bash pip install llama-cpp-python huggingface-hub ``` ### Execution ```bash # Clone the repository git clone https://huggingface.co/Wellwisher12/finance-phi3-gguf # Navigate into the directory cd finance-phi3-gguf # Launch the interactive terminal python main.py ``` --- # ⚙️ Required System Prompt To achieve the best and most accurate results, the model should be initialized with the following system prompt. > **Note:** This is automatically handled if you use the provided `Modelfile` or `main.py` script. ```text You are a professional Financial Analyst with expertise in: - Stock market analysis and valuation - Corporate finance and accounting - Investment strategy and portfolio management - Economic trends and market indicators - Risk assessment and financial modeling Your responses should be: - Accurate and data-driven - Professional and neutral in tone - Comprehensive yet concise - Based on sound financial principles Always provide specific examples and metrics when relevant. ``` --- # 📊 Technical Specifications | Specification | Details | |---|---| | Base Model | `unsloth/phi-3-mini-4k-instruct` | | Dataset | `gbharti/finance-alpaca` | | Quantization | `Q4_K_M (4-bit)` | | Format | `GGUF` | | Recommended Temperature | `0.2` | | Recommended Context Window | `1024 - 2048 tokens` | --- # ✅ Key Features - Fine-tuned specifically for financial reasoning tasks - Lightweight and optimized for low-RAM systems - Compatible with Ollama and `llama.cpp` - Quantized GGUF format for efficient local inference - Professional analyst-style responses - Reduced hallucinations with low-temperature inference --- # 💡 Recommended Hardware | Hardware | Recommendation | |---|---| | RAM | Minimum 4GB | | CPU | Modern multi-core CPU | | GPU | Optional | | Storage | ~2-3GB free space | --- # 📌 Example Prompt ```text Analyze Apple's current valuation using P/E ratio, revenue growth, and free cash flow trends. ``` --- # 📜 License Please follow the licensing terms of the original base model and dataset used in this project. - Base Model: `Microsoft Phi-3 Mini` - Dataset: `finance-alpaca` --- # 🙌 Credits - Microsoft for the Phi-3 architecture - Unsloth for efficient fine-tuning - Hugging Face ecosystem - Finance-Alpaca dataset contributors