bert-news-en-score
scoring the impact of financial news on company stocks
2 min readupdated
Built on google-bert/bert-base-uncased (a language model for text analysis), this model evaluates English financial news to determine how it affects a specific company's stock. It outputs two scores: relevance (whether the news applies to the target company) and an impact score ranging from -1 (negative) to +1 (positive). Before running inference, company names in the text must be replaced with special tokens: [MASK] for the target company and [ORG] for all other entities. This model is useful for developers and researchers building algorithms for financial analysis and market monitoring.
Key features
- Analyzes English financial headlines and short news snippets.
- Outputs logits (raw numerical predictions) to determine relevance and impact strength.
- Classifies news into four categories: unrelated, positive, negative, and neutral.
- Trained on a dataset of over 10,000 examples split by company.
What you can do
- Integrate the model into a trading bot or analytics tool to score breaking news for a stock portfolio.
- Test a financial summary classification script to automatically track market trends.
- Experiment with the model on your own financial headlines by replacing company names with
[MASK].
Example
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
repo = "podongchip/bert-news-en-score"
tokenizer = AutoTokenizer.from_pretrained(repo)
model = AutoModelForSequenceClassification.from_pretrained(repo).eval()
texts = [
"[MASK] wins 1.2 trillion won battery supply contract from [ORG]"
]
with torch.no_grad():
logits = model(**tokenizer(texts, truncation=True, max_length=256, padding=True, return_tensors="pt")).logits
for text, (relevance_logit, score) in zip(texts, logits.tolist()):
relevance = torch.sigmoid(torch.tensor(relevance_logit)).item()
print(f"relevance={relevance:.2f} score={score:+.2f}")
Read more
DetailsTest set metrics: 4-class accuracy — 0.752, 4-class macro F1 — 0.717, Relevance accuracy — 0.845.
Limitations: scores are biased toward zero, the model only handles English headlines and short snippets, and outputs are not financial advice.
Training details: 3 epochs, batch size 32, learning rate 2e-5, with the
[ORG] token added to the tokenizer.









Comments