Update README.md
Browse files
README.md
CHANGED
|
@@ -1,202 +1,204 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
#
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
| 9 |
|
|
|
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
- **Developed by:** [More Information Needed]
|
| 21 |
-
- **Funded by [optional]:** [More Information Needed]
|
| 22 |
-
- **Shared by [optional]:** [More Information Needed]
|
| 23 |
-
- **Model type:** [More Information Needed]
|
| 24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
-
- **License:** [More Information Needed]
|
| 26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
-
|
| 28 |
-
### Model Sources [optional]
|
| 29 |
-
|
| 30 |
-
<!-- Provide the basic links for the model. -->
|
| 31 |
-
|
| 32 |
-
- **Repository:** [More Information Needed]
|
| 33 |
-
- **Paper [optional]:** [More Information Needed]
|
| 34 |
-
- **Demo [optional]:** [More Information Needed]
|
| 35 |
-
|
| 36 |
-
## Uses
|
| 37 |
-
|
| 38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 39 |
-
|
| 40 |
-
### Direct Use
|
| 41 |
-
|
| 42 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 43 |
-
|
| 44 |
-
[More Information Needed]
|
| 45 |
-
|
| 46 |
-
### Downstream Use [optional]
|
| 47 |
-
|
| 48 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 49 |
-
|
| 50 |
-
[More Information Needed]
|
| 51 |
-
|
| 52 |
-
### Out-of-Scope Use
|
| 53 |
-
|
| 54 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 55 |
-
|
| 56 |
-
[More Information Needed]
|
| 57 |
-
|
| 58 |
-
## Bias, Risks, and Limitations
|
| 59 |
-
|
| 60 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 61 |
-
|
| 62 |
-
[More Information Needed]
|
| 63 |
-
|
| 64 |
-
### Recommendations
|
| 65 |
-
|
| 66 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 67 |
-
|
| 68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 69 |
-
|
| 70 |
-
## How to Get Started with the Model
|
| 71 |
-
|
| 72 |
-
Use the code below to get started with the model.
|
| 73 |
-
|
| 74 |
-
[More Information Needed]
|
| 75 |
-
|
| 76 |
-
## Training Details
|
| 77 |
-
|
| 78 |
-
### Training Data
|
| 79 |
-
|
| 80 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 81 |
-
|
| 82 |
-
[More Information Needed]
|
| 83 |
-
|
| 84 |
-
### Training Procedure
|
| 85 |
-
|
| 86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 87 |
-
|
| 88 |
-
#### Preprocessing [optional]
|
| 89 |
-
|
| 90 |
-
[More Information Needed]
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
#### Training Hyperparameters
|
| 94 |
-
|
| 95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
-
|
| 97 |
-
#### Speeds, Sizes, Times [optional]
|
| 98 |
-
|
| 99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
-
|
| 101 |
-
[More Information Needed]
|
| 102 |
-
|
| 103 |
-
## Evaluation
|
| 104 |
-
|
| 105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
-
|
| 107 |
-
### Testing Data, Factors & Metrics
|
| 108 |
-
|
| 109 |
-
#### Testing Data
|
| 110 |
-
|
| 111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
-
|
| 113 |
-
[More Information Needed]
|
| 114 |
-
|
| 115 |
-
#### Factors
|
| 116 |
-
|
| 117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
-
|
| 119 |
-
[More Information Needed]
|
| 120 |
-
|
| 121 |
-
#### Metrics
|
| 122 |
|
| 123 |
-
|
| 124 |
|
| 125 |
-
|
| 126 |
|
| 127 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
-
|
| 130 |
|
| 131 |
-
##
|
| 132 |
|
|
|
|
|
|
|
| 133 |
|
|
|
|
| 134 |
|
| 135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
|
| 137 |
-
|
| 138 |
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
-
|
| 144 |
|
| 145 |
-
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
-
-
|
| 148 |
-
- **Hours used:** [More Information Needed]
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
|
| 153 |
-
##
|
| 154 |
|
| 155 |
-
|
|
|
|
|
|
|
| 156 |
|
| 157 |
-
|
|
|
|
| 158 |
|
| 159 |
-
|
|
|
|
|
|
|
|
|
|
| 160 |
|
| 161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
|
| 163 |
-
#
|
|
|
|
|
|
|
|
|
|
| 164 |
|
| 165 |
-
|
| 166 |
|
| 167 |
-
##
|
| 168 |
|
| 169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
-
|
| 172 |
|
| 173 |
-
|
| 174 |
|
| 175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
|
| 177 |
-
|
| 178 |
|
| 179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
|
| 181 |
-
|
| 182 |
|
| 183 |
-
##
|
| 184 |
|
| 185 |
-
|
| 186 |
|
| 187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
|
| 189 |
-
|
| 190 |
|
| 191 |
-
|
| 192 |
|
| 193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
|
| 195 |
-
|
| 196 |
|
| 197 |
-
##
|
| 198 |
|
| 199 |
-
[
|
| 200 |
-
|
|
|
|
| 201 |
|
| 202 |
-
- PEFT 0.15.1
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
tags:
|
| 6 |
+
- finance
|
| 7 |
+
- sentiment-analysis
|
| 8 |
+
- text-classification
|
| 9 |
+
- lora
|
| 10 |
+
- mistral
|
| 11 |
+
- indian-market
|
| 12 |
+
- autoscientist
|
| 13 |
+
- adaption
|
| 14 |
+
datasets:
|
| 15 |
+
- financial_phrasebank
|
| 16 |
+
- zeroshot/twitter-financial-news-sentiment
|
| 17 |
+
- flwrlabs/fingpt-sentiment-train
|
| 18 |
+
- TimKoornstra/financial-tweets-sentiment
|
| 19 |
+
- nickmuchi/financial-classification
|
| 20 |
+
base_model: mistralai/Mistral-7B-Instruct-v0.3
|
| 21 |
+
metrics:
|
| 22 |
+
- accuracy
|
| 23 |
---
|
| 24 |
|
| 25 |
+
# ๐น Finance Sentiment Classifier โ Indian Market Focus
|
| 26 |
|
| 27 |
+
> Fine-tuned on Mistral-7B-Instruct using LoRA via Adaption AutoScientist.
|
| 28 |
+
> Classifies financial news, headlines, and social media text into **positive**, **negative**, or **neutral** sentiment.
|
| 29 |
+
> Built for the [HackIndia Adaption AutoScientist Challenge](https://hackindia.xyz) โ Finance track.
|
| 30 |
|
| 31 |
+
---
|
| 32 |
|
| 33 |
+
## ๐ Performance
|
| 34 |
|
| 35 |
+
| Metric | Base Model | Our Model | Improvement |
|
| 36 |
+
|---|---|---|---|
|
| 37 |
+
| Win Rate (our dataset) | 44 | 56 | **+27% relative** |
|
| 38 |
+
| Win Rate (market analysis category) | 40 | 60 | **+50% relative** |
|
| 39 |
+
| Dataset quality grade | E (2.0) | B (8.1) | **+305% relative** |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
Training curves showed clean, consistent loss reduction with no overfitting across 4 epochs.
|
| 42 |
|
| 43 |
+
---
|
| 44 |
|
| 45 |
+
## ๐ง Model Details
|
| 46 |
+
|
| 47 |
+
| Property | Value |
|
| 48 |
+
|---|---|
|
| 49 |
+
| Base model | mistralai/Mistral-7B-Instruct-v0.3 |
|
| 50 |
+
| Training method | Supervised Fine-Tuning (SFT) + LoRA |
|
| 51 |
+
| LoRA rank | 64 |
|
| 52 |
+
| LoRA alpha | 128 |
|
| 53 |
+
| Target layers | q_proj, k_proj, v_proj, o_proj |
|
| 54 |
+
| Epochs | 4 |
|
| 55 |
+
| Optimizer | Cosine LR scheduler |
|
| 56 |
+
| Warmup ratio | 0.05 |
|
| 57 |
+
| Gradient clipping | 1.0 |
|
| 58 |
+
| Weight decay | 0.01 |
|
| 59 |
+
| Training platform | Adaption AutoScientist |
|
| 60 |
+
| Dataset size | 20,000 rows (adapted) |
|
| 61 |
|
| 62 |
+
---
|
| 63 |
|
| 64 |
+
## ๐ Dataset
|
| 65 |
|
| 66 |
+
The training dataset is a curated merge of **6 sources** totalling ~120,000 raw rows,
|
| 67 |
+
cleaned and deduplicated down to 20,000 high-quality rows via Adaption's Adaptive Data pipeline.
|
| 68 |
|
| 69 |
+
### Sources
|
| 70 |
|
| 71 |
+
| Source | Type | Rows (approx) |
|
| 72 |
+
|---|---|---|
|
| 73 |
+
| financial_phrasebank (sentences_allagree) | Human-labeled news sentences | ~2,200 |
|
| 74 |
+
| zeroshot/twitter-financial-news-sentiment | Human-labeled financial tweets | ~9,900 |
|
| 75 |
+
| flwrlabs/fingpt-sentiment-train | Financial NLP training data | ~76,800 |
|
| 76 |
+
| TimKoornstra/financial-tweets-sentiment | Human-labeled financial tweets | ~38,000 |
|
| 77 |
+
| nickmuchi/financial-classification | Financial text classification | ~2,000 |
|
| 78 |
+
| Hand-labeled originals (Indian market) | Original, manually written examples | ~60+ |
|
| 79 |
+
| NewsAPI live headlines | Rule-labelled recent business news | ~500 |
|
| 80 |
|
| 81 |
+
### What makes this dataset original
|
| 82 |
|
| 83 |
+
- **Indian market focus** โ original hand-labeled examples covering NSE, BSE, Sensex, Nifty, RBI decisions, Indian fintech (Paytm, Zomato, PhonePe), and Indian conglomerates (Reliance, Tata, Adani, HDFC)
|
| 84 |
+
- **Multi-source deduplication** โ priority-aware deduplication ensures highest-quality copy is retained when the same text appears across sources
|
| 85 |
+
- **Multilingual context** โ includes financial terminology specific to the Indian subcontinent not present in standard Western finance NLP datasets
|
| 86 |
+
- **Live news augmentation** โ recent business headlines via NewsAPI add temporal diversity beyond static datasets
|
| 87 |
|
| 88 |
+
### Label distribution (after cleaning)
|
| 89 |
+
```
|
| 90 |
+
positive : ~35%
|
| 91 |
+
negative : ~33%
|
| 92 |
+
neutral : ~32%
|
| 93 |
+
```
|
| 94 |
+
Balanced across all three classes to prevent label bias.
|
| 95 |
|
| 96 |
+
### Data quality improvement via Adaptive Data
|
| 97 |
|
| 98 |
+
Adaption's Adaptive Data pipeline was applied before training:
|
| 99 |
+
- **Before:** Grade E, quality score 2.0, percentile 0.1
|
| 100 |
+
- **After:** Grade B, quality score 8.1, percentile 17.8
|
| 101 |
+
- **Relative improvement: 305%**
|
| 102 |
|
| 103 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
+
## ๐ How to Use
|
| 106 |
|
| 107 |
+
```python
|
| 108 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 109 |
+
from peft import PeftModel
|
| 110 |
|
| 111 |
+
base_model = "mistralai/Mistral-7B-Instruct-v0.3"
|
| 112 |
+
lora_model = "Sashank1006/finance-sentiment-mistral-lora"
|
| 113 |
|
| 114 |
+
tokenizer = AutoTokenizer.from_pretrained(base_model)
|
| 115 |
+
model = AutoModelForCausalLM.from_pretrained(base_model, device_map="auto")
|
| 116 |
+
model = PeftModel.from_pretrained(model, lora_model)
|
| 117 |
+
model.eval()
|
| 118 |
|
| 119 |
+
def predict_sentiment(text: str) -> str:
|
| 120 |
+
prompt = f"Classify the sentiment of this financial text as positive, negative, or neutral:\n\n{text}\n\nSentiment:"
|
| 121 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 122 |
+
output = model.generate(**inputs, max_new_tokens=5, do_sample=False)
|
| 123 |
+
result = tokenizer.decode(output[0], skip_special_tokens=True)
|
| 124 |
+
return result.split("Sentiment:")[-1].strip().lower()
|
| 125 |
|
| 126 |
+
# Example
|
| 127 |
+
text = "Reliance Industries reported a 23% jump in quarterly profit."
|
| 128 |
+
print(predict_sentiment(text)) # โ "positive"
|
| 129 |
+
```
|
| 130 |
|
| 131 |
+
---
|
| 132 |
|
| 133 |
+
## ๐ Real-World Applications
|
| 134 |
|
| 135 |
+
- **Retail investor tools** โ classify financial news before displaying to users
|
| 136 |
+
- **Trading signal generation** โ convert news sentiment into bullish/bearish signals
|
| 137 |
+
- **Portfolio risk monitoring** โ flag negative sentiment around held stocks
|
| 138 |
+
- **Indian fintech apps** โ specifically tuned for Indian market terminology and companies
|
| 139 |
+
- **News aggregators** โ auto-tag financial articles by sentiment
|
| 140 |
|
| 141 |
+
---
|
| 142 |
|
| 143 |
+
## โ ๏ธ Limitations
|
| 144 |
|
| 145 |
+
- Trained primarily on English-language financial text; performance on Hindi/Tamil/regional language finance text will be lower
|
| 146 |
+
- Rule-labelled NewsAPI headlines (~500 rows) may contain some label noise
|
| 147 |
+
- Model may underperform on highly technical financial derivative or options-specific language
|
| 148 |
+
- Sentiment is classified at the sentence/headline level โ document-level sentiment aggregation requires additional logic
|
| 149 |
+
- The model reflects sentiment patterns in training data up to mid-2026; sentiment around newer entities may be less accurate
|
| 150 |
|
| 151 |
+
---
|
| 152 |
|
| 153 |
+
## ๐ Training Pipeline
|
| 154 |
+
|
| 155 |
+
```
|
| 156 |
+
Raw data (6 sources, ~120K rows)
|
| 157 |
+
โ
|
| 158 |
+
Merge + deduplicate (prepare_dataset.py)
|
| 159 |
+
โ
|
| 160 |
+
Upload to Adaption Adaptive Data
|
| 161 |
+
โ
|
| 162 |
+
Adaptive Data optimization (Grade E โ B, 305% quality improvement)
|
| 163 |
+
โ
|
| 164 |
+
AutoScientist fine-tuning (Mistral-7B-Instruct, LoRA, 4 epochs)
|
| 165 |
+
โ
|
| 166 |
+
Evaluation (Win rate: 44 โ 56 on dataset, 40 โ 60 on market analysis)
|
| 167 |
+
โ
|
| 168 |
+
Released on HuggingFace + Kaggle
|
| 169 |
+
```
|
| 170 |
|
| 171 |
+
---
|
| 172 |
|
| 173 |
+
## ๐ฅ Team
|
| 174 |
|
| 175 |
+
**Team Caribou** โ HackIndia Adaption AutoScientist Challenge, Finance Track
|
| 176 |
|
| 177 |
+
Built using:
|
| 178 |
+
- [Adaption AutoScientist](https://adaptionlabs.ai) โ automated model training
|
| 179 |
+
- [Adaption Adaptive Data](https://adaptionlabs.ai) โ dataset quality optimization
|
| 180 |
+
- HuggingFace Datasets โ source data
|
| 181 |
+
- NewsAPI โ live headline augmentation
|
| 182 |
|
| 183 |
+
---
|
| 184 |
|
| 185 |
+
## ๐ Citation
|
| 186 |
|
| 187 |
+
```bibtex
|
| 188 |
+
@misc{caribou2026financeSentiment,
|
| 189 |
+
title = {Finance Sentiment Classifier โ Indian Market Focus},
|
| 190 |
+
author = {Team Caribou},
|
| 191 |
+
year = {2026},
|
| 192 |
+
url = {https://huggingface.co/YOUR_HF_USERNAME/finance-sentiment-mistral-lora},
|
| 193 |
+
note = {Built for HackIndia Adaption AutoScientist Challenge}
|
| 194 |
+
}
|
| 195 |
+
```
|
| 196 |
|
| 197 |
+
---
|
| 198 |
|
| 199 |
+
## ๐ Links
|
| 200 |
|
| 201 |
+
- ๐ฆ Dataset: [Kaggle โ finance-sentiment-india](https://www.kaggle.com/Sashank610/finance-sentiment-india)
|
| 202 |
+
- ๐ค Model: [HuggingFace โ finance-sentiment-mistral-lora](https://huggingface.co/Sashank1006/finance-sentiment-mistral-lora)
|
| 203 |
+
- ๐ฎ Demo: [HuggingFace Spaces โ Gradio App](https://huggingface.co/spaces/Sashank1006/finance-sentiment-demo)
|
| 204 |
|
|
|