Sentiment Bilstm Financial Multimodal
Final SA BiLSTM head trained on top of the multimodal fine-tuned FinBERT (frozen). Input: '[IMG] {caption} [SEP] {tweet}'.
Label mapping
LABEL_MAP = {"Bearish": 0, "Neutral": 1, "Bullish": 2}
Input format
[IMG] {caption} [SEP] {tweet}
Load
import torch
from huggingface_hub import hf_hub_download
from transformers import AutoModel, AutoTokenizer
from src.models import SentimentLSTM # or copy class into your code
# 1. Download BiLSTM weights
weights_path = hf_hub_download(repo_id="gra1111/sentiment-bilstm-financial-multimodal", filename="pytorch_model.pt")
# 2. Build the architecture using the config
config = {
"input_dim": 768,
"hidden_dim": 256,
"num_layers": 3,
"num_classes": 3,
"dropout": 0.5,
"input_format": "[IMG] {caption} [SEP] {tweet}",
"finbert_repo": "gra1111/finbert-financial-sa-multimodal",
"tokenizer_repo": "gra1111/finbert-tokenizer-multimodal"
}
model = SentimentLSTM(
input_dim=config["input_dim"],
hidden_dim=config["hidden_dim"],
num_layers=config["num_layers"],
num_classes=config["num_classes"],
dropout=config["dropout"],
)
model.load_state_dict(torch.load(weights_path, map_location="cpu"))
model.eval()
# 3. Load FinBERT + tokenizer that match this BiLSTM
finbert = AutoModel.from_pretrained(config["finbert_repo"])
tokenizer = AutoTokenizer.from_pretrained(
config.get("tokenizer_repo", config["finbert_repo"])
)
- Downloads last month
- 4
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support