bert-news-en-score

A BERT model that reads a financial news item and judges how it affects one target company's stock. It returns two numbers: whether the item is about the target company at all, and an impact score from -1 (very bad for the stock) to +1 (very good).

Fine-tuned from google-bert/bert-base-uncased.

Input

English text: a headline, optionally followed by a newline and a short snippet.

Company names must be replaced with placeholders before the text is passed in:

  • [MASK] marks the target company, the one you want the judgment for.
  • [ORG] marks any other company.

The same news item gives different results for different target companies, so mask it once per company you care about.

[MASK] wins 1.2 trillion won battery supply contract from [ORG]

Output

The model returns two logits per item.

Index Meaning How to read it
0 Relevance Apply a sigmoid. Below 0.5, the item is not about [MASK] (a passing mention, a market wrap, another company's news).
1 Impact score Roughly -1 to +1. Only meaningful when the item is relevant.

To turn the two numbers into four classes:

Class Rule
unrelated relevance < 0.5
positive relevance ≥ 0.5 and score ≥ 0.25
negative relevance ≥ 0.5 and score ≤ -0.25
neutral relevance ≥ 0.5 and score between -0.25 and 0.25

Do not use the text-classification pipeline: it applies a softmax across the two outputs, which is wrong for this model.

Usage

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] Q3 operating profit falls 15%, missing consensus\n[MASK] posted operating profit of 108.4 billion won for the third quarter, well below market estimates.",
    "[MASK] wins 1.2 trillion won battery supply contract from [ORG]",
    "[MASK] donates 100 million won to local scholarship fund",
    "KOSPI closes up 0.4% as foreign buying returns\n[ORG] rose 1.8% while [MASK] and other energy shares were little changed.",
]
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()
    label = "unrelated" if relevance < 0.5 else "positive" if score >= 0.25 else "negative" if score <= -0.25 else "neutral"
    print(f"relevance={relevance:.2f}  score={score:+.2f}  {label}")
relevance=1.00  score=-0.65  negative
relevance=1.00  score=+0.69  positive
relevance=0.98  score=+0.00  neutral
relevance=0.02  score=+0.05  unrelated

Evaluation

Measured on a held-out test set of 10,024 items. The split is by company: no company in the test set appears in training.

Metric Value
4-class accuracy 0.752
4-class macro F1 0.717
F1 unrelated / positive / negative / neutral 0.843 / 0.708 / 0.687 / 0.630
Relevance accuracy 0.845
Score mean absolute error (relevant items) 0.109
Score Pearson correlation (relevant items) 0.863

Limitations

  • Scores are compressed toward zero. Strong events are predicted about 20% weaker than their reference scores (for example, a reference average of -0.76 comes out as -0.61). Items near the ±0.25 boundary are often classed as neutral.
  • The hardest call is unrelated versus neutral, that is, whether the target company is the subject of the item or only mentioned. This accounts for the largest share of errors.
  • Scores are annotation-based estimates of likely impact, not measured stock price reactions.
  • The model sees only a headline and a short snippet, in English. It was not trained on full articles or on other languages.
  • This is a research model. It is not financial advice.

Training

  • Training data. Private dataset, not released.
  • 3 epochs, batch size 32, learning rate 2e-5, maximum length 256 tokens. [ORG] was added to the tokenizer as a special token.
  • Loss: binary cross-entropy for relevance plus mean squared error for the score (weight 10), with the score loss computed only on relevant items.
Downloads last month
29
Safetensors
Model size
0.1B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for podongchip/bert-news-en-score

Finetuned
(7,286)
this model