Downloads · 30 days
2
1% of all-time downloads
ArpitJha/Indian-FinBert
Indian-FinBert is a text classification model from ArpitJha. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as mit.
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. Th…
Downloads · 30 days
2
1% of all-time downloads
All-time downloads
275
Public
Parameters
109M
462 MB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors438 MB · 96%
From the Hugging Face model README
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 model itself, you don't need to download file , just go to the How to use model section of this read me and check how to do inference.
├── config.json
├── labeled_dataset.csv # training dataset
├── result.png # Result image
├── model.safetensor # Whole merged model
├── tokenizer.json
├── tokenizer_config.json # Tokenizer settings
└── README.md
| ID | Label | Meaning |
|---|---|---|
| 0 | POSITIVE | Bullish sentiment |
| 1 | NEGATIVE | Bearish sentiment |
| 2 | NEUTRAL | No clear directional signal |
pip install torch==2.6.0 transformers==4.47.0 peft==0.13.0 safetensors==0.4.3
Have an NVIDIA GPU? Install the CUDA build of torch for faster inference:
pip install torch==2.6.0 --index-url https://download.pytorch.org/whl/cu124 pip install transformers==4.47.0 peft==0.13.0 safetensors==0.4.3
import torch
from transformers import pipeline
LABEL_MAP = {"LABEL_0": "POSITIVE", "LABEL_1": "NEGATIVE", "LABEL_2": "NEUTRAL"}
# HuggingFace downloads and caches the model automatically on first run
nlp = pipeline(
"sentiment-analysis",
model = "ArpitJha/Indian-FinBert",
tokenizer = "ArpitJha/Indian-FinBert",
device = 0 if torch.cuda.is_available() else -1
)
headlines = [
"Reliance Industries posts record quarterly profit.",
"Adani Group stocks crash amid fraud allegations.",
"RBI keeps interest rates unchanged in policy meeting.",
"Infosys wins $2 billion AI transformation deal.",
]
for h in headlines:
result = nlp(h)[0]
sentiment = LABEL_MAP.get(result["label"], result["label"])
print(f"{sentiment} ({result['score']*100:.1f}%) — {h}")
Install pandas using the command : pip install pandas
import torch
import pandas as pd
from transformers import pipeline
LABEL_MAP = {"LABEL_0": "POSITIVE", "LABEL_1": "NEGATIVE", "LABEL_2": "NEUTRAL"}
# 1. Initialize the pipeline
print("Loading model...")
nlp = pipeline(
"sentiment-analysis",
model="ArpitJha/Indian-FinBert",
tokenizer="ArpitJha/Indian-FinBert",
device=0 if torch.cuda.is_available() else -1
)
# 2. Load the CSV data
csv_file_path = "input_data.csv" # Change this to your file's path
print(f"Loading data from {csv_file_path}...")
df = pd.read_csv(csv_file_path)
# Ensure the column exists (replace 'headline' with your actual column name)
text_column = "headline"
if text_column not in df.columns:
raise ValueError(f"Column '{text_column}' not found in the CSV. Available columns: {df.columns.tolist()}")
# Convert the column to a standard Python list
texts_to_analyze = df[text_column].astype(str).tolist()
# 3. Run Batch Inference
print(f"Processing {len(texts_to_analyze)} rows. This might take a moment...")
# Adjust batch_size based on your GPU memory (e.g., 8, 16, 32, 64)
results = nlp(texts_to_analyze, batch_size=16)
# 4. Extract labels and scores
mapped_sentiments = []
confidence_scores = []
for result in results:
mapped_sentiments.append(LABEL_MAP.get(result["label"], result["label"]))
confidence_scores.append(round(result["score"] * 100, 2)) # Score as a percentage
# 5. Add the results back to the DataFrame
df["predicted_sentiment"] = mapped_sentiments
df["confidence_score_%"] = confidence_scores
# 6. Save the results to a new CSV
output_path = "output_results.csv"
df.to_csv(output_path, index=False)
print(f"Batch inference complete! Results saved to {output_path}")
torch>=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 |
The adapter weights in this repository are released under the MIT License.
The base model (ProsusAI/finbert) is subject to its own Apache 2.0 license.