Views
No views yet
FinBERT (ProsusAI/finbert) fine-tuned on Indian financial news headlines using LoRA adapters.
Optimised for Indian market sentiment — Nifty 50 stocks, NSE/BSE news, RBI announcements, and Indian business headlines. This repo contains the adapter files only .
ProsusAI/finbert model which is downloaded automatically from HuggingFace on first use.| ID | Label | Meaning |
|---|---|---|
| 0 | POSITIVE | Bullish sentiment |
| 1 | NEGATIVE | Bearish sentiment |
| 2 | NEUTRAL | No clear directional signal |
1# Make sure git-xet is installed (https://hf.co/docs/hub/git-xet)
2winget install git-xet
3git clone https://huggingface.co/ArpitJha/Indian-FinBert-Adapters1python -m venv .venv
2
3# Linux / macOS
4source .venv/bin/activate
5
6# Windows
7.venv\Scripts\activatepip install torch==2.6.0 transformers==4.47.0 peft==0.13.0 safetensors==0.4.3Have an NVIDIA GPU? Install the CUDA build of torch for faster inference:bash1pip install torch==2.6.0 --index-url https://download.pytorch.org/whl/cu124 2pip install transformers==4.47.0 peft==0.13.0 safetensors==0.4.3
1from transformers import (
2 AutoTokenizer,
3 AutoModelForSequenceClassification,
4 pipeline
5)
6from peft import PeftModel
7import torch
8
9BASE_MODEL = "ProsusAI/finbert"
10
11# Locally after downloading and unzipping the adapter files, we can load them using the path
12ADAPTER_PATH = "YOUR_ADAPTER_FOLDER"
13
14
15tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
16base_model = AutoModelForSequenceClassification.from_pretrained(BASE_MODEL, num_labels=3)
17
18model = PeftModel.from_pretrained(base_model, ADAPTER_PATH)
19model = model.merge_and_unload()
20model.eval()
21
22nlp = pipeline(
23 "sentiment-analysis",
24 model = model,
25 tokenizer = tokenizer,
26 device = 0 if torch.cuda.is_available() else -1
27)
28
29label_map = {
30 "LABEL_0": "POSITIVE",
31 "LABEL_1": "NEGATIVE",
32 "LABEL_2": "NEUTRAL"
33}
34
35test_headlines = [
36"Reliance Industries posts record quarterly profit.",
37 "Adani Group stocks crash amid fraud allegations.",
38 "RBI keeps interest rates unchanged in policy meeting.",
39 "Infosys wins $2 billion AI transformation deal.",
40]
41
42print("=" * 60)
43print("FINBERT + LORA SENTIMENT ANALYSIS")
44print("=" * 60)
45
46for text in test_headlines:
47 result = nlp(text)[0]
48 sentiment = label_map.get(result["label"], result["label"])
49 print(f"\nHeadline : {text}")
50 print(f"Sentiment: {sentiment}")
51 print(f"Confidence: {result['score']:.4f}")
52torch>=2.6.0
transformers==4.47.0
peft==0.13.0
safetensors==0.4.3
pandas>=2.2.0 # only needed for batch CSV inference| Property | Value |
|---|---|
| Base model | ProsusAI/finbert |
| Fine-tuning method | LoRA (PEFT) |
| LoRA rank | 32 |
| LoRA alpha | 64 |
| Target modules | query, value |
| Training data | Indian financial news headlines |
| Task | 3-class sentiment classification |
| Labels | Positive / Negative / Neutral |
| Trainable parameters | ~1% of total |

ProsusAI/finbert) is subject to its own Apache 2.0 license.