Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π§ Finance LLM β Fine-Tuned Phi-3 Mini (LoRA + Full Merge)
|
| 2 |
+
|
| 3 |
+
This model is a **financial question-answering LLM**, fine-tuned on a curated dataset using:
|
| 4 |
+
|
| 5 |
+
- **Base Model:** microsoft/phi-3-mini-4k-instruct
|
| 6 |
+
- **Training Method:** LoRA (Rank=16, Alpha=32, Dropout=0.05)
|
| 7 |
+
- **Merged Model:** Yes (LoRA + Base fully merged into one model)
|
| 8 |
+
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
## π Capabilities
|
| 12 |
+
|
| 13 |
+
- β Financial Q&A
|
| 14 |
+
- β Balance sheet understanding
|
| 15 |
+
- β Profit/Loss interpretation
|
| 16 |
+
- β Ratios / EBITDA / EPS explanation
|
| 17 |
+
- β Market news reasoning
|
| 18 |
+
- β Risk assessment
|
| 19 |
+
- β Investment style suggestions
|
| 20 |
+
- β Banking & loan related Q&A
|
| 21 |
+
|
| 22 |
+
This model is optimized for **Indian finance use cases**.
|
| 23 |
+
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
## π Training Details
|
| 27 |
+
|
| 28 |
+
| Setting | Value |
|
| 29 |
+
|--------|-------|
|
| 30 |
+
| Epochs | 2 |
|
| 31 |
+
| LoRA Rank | 16 |
|
| 32 |
+
| Batch Size | 2 |
|
| 33 |
+
| Learning Rate | 2e-4 |
|
| 34 |
+
| Dataset | FinanceQA (custom cleaned) |
|
| 35 |
+
| Hardware | A100 / T4 / Colab GPU |
|
| 36 |
+
|
| 37 |
+
Purpose:
|
| 38 |
+
To create a small lightweight but finance-aware LLM for **startups, fintech apps, compliance tools, and internal company use**.
|
| 39 |
+
|
| 40 |
+
---
|
| 41 |
+
|
| 42 |
+
## π Dataset
|
| 43 |
+
|
| 44 |
+
This model was trained on:
|
| 45 |
+
|
| 46 |
+
- Financial questions & answers
|
| 47 |
+
- Corporate filings
|
| 48 |
+
- Stock-market explanations
|
| 49 |
+
- Real-world financial reasoning examples
|
| 50 |
+
|
| 51 |
+
Dataset used: **AfterQuery/FinanceQA** (public)
|
| 52 |
+
|
| 53 |
+
---
|
| 54 |
+
|
| 55 |
+
## π§© Model Architecture
|
| 56 |
+
|
| 57 |
+
Based on Phi-3 mini (3.8B parameters) with LoRA applied to:
|
| 58 |
+
|
| 59 |
+
- Self-attention QKV projections
|
| 60 |
+
- Output projections
|
| 61 |
+
- MLP up/down projections
|
| 62 |
+
|
| 63 |
+
Merged model = pure FP16 weights β **No LoRA needed at inference**.
|
| 64 |
+
|
| 65 |
+
---
|
| 66 |
+
|
| 67 |
+
## π‘ Usage Example
|
| 68 |
+
|
| 69 |
+
```python
|
| 70 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 71 |
+
import torch
|
| 72 |
+
|
| 73 |
+
model_id = "devAnurag/finance_llm_full"
|
| 74 |
+
|
| 75 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 76 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16)
|
| 77 |
+
|
| 78 |
+
prompt = "Explain EBITDA in simple terms."
|
| 79 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
| 80 |
+
|
| 81 |
+
outputs = model.generate(**inputs, max_new_tokens=150)
|
| 82 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|