/ Модель

Характеристики

Контекст
512 токенов
Параметры
40 млн
Лицензия
MIT
Архитектура
bert · dense
Базовая модель
MiniLM-L12-H384-uncased
Библиотека
transformers
Опубликована
24 июн 2026

finbert-minilm-sentiment

Классификация текстаТекст → label3 профессии

Компактная англоязычная MiniLM-модель для классификации тональности коротких финансовых текстов на негативную, нейтральную и позитивную.

737скачиваний за 30 дней0лайковвеса обновлены14 ноя 2026

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

finbert-minilm-sentiment — компактный классификатор тональности финансового текста, разработанный автором репозитория на основе Microsoft MiniLM-L12-H384-uncased. Модель относится к архитектуре BERT и дообучена на финансовых предложениях, публикациях в соцсетях о рынках и заголовках пресс-релизов; в метаданных указано 40 млн параметров, форматы safetensors и ONNX, контекст до 512 токенов. В оценке автора использовались последовательности длиной до 96 токенов.

Модель относит короткий англоязычный финансовый текст к классам «негативный», «нейтральный» и «позитивный». Её можно применять для анализа тональности новостных предложений, заголовков, финансовых публикаций в соцсетях и заметок аналитиков, а также для прототипирования и исследований на CPU. Автор сообщает точность 97,9% на тестовой выборке Financial PhraseBank и 86,4% на финансовых твитах; результаты зависят от набора данных и определения тональности.

Модель иногда ошибается на неоднозначных формулировках и слабо выявляет негативные заголовки пресс-релизов; для части финансовых твитов класс отражает направление рынка, а не эмоциональный тон текста. Входные последовательности длиннее 96 токенов при оценке обрезались. Результаты не являются финансовой рекомендацией. Лицензия — MIT.

Сценарии применения

  • оценка тональности финансовых новостных предложений
  • классификация заголовков пресс-релизов компаний
  • анализ тональности финансовых публикаций в соцсетях
  • разметка заметок финансовых аналитиков
  • прототипирование классификатора финансовых текстов на CPU

Ограничения

Модель рассчитана на английский язык и при оценке автора ограничивалась последовательностями до 96 токенов; длинный текст обрезается. Она слабо выявляет негативные заголовки пресс-релизов, а метки финансовых твитов могут отражать направление рынка, а не тональность; результаты не являются финансовой рекомендацией.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

finbert-minilm-sentiment

A compact financial-sentiment classifier: 33.4M parameters, 97.9% on PhraseBank test, 86.4% on finance tweets.

finbert-minilm-sentiment classifies financial text into negative / neutral / positive sentiment. It is a compact MiniLM encoder (microsoft/MiniLM-L12-H384-uncased, 33.4M parameters) fine-tuned on a mix of formal financial sentences (Financial PhraseBank), finance tweets (zeroshot/twitter-financial-news-sentiment) and press-release headlines (Jean-Baptiste/financial_news_sentiment). All numbers below are measured on data held out from training and model selection.

This is version 3 (October 2026): the same architecture and file format as before, now the uniform weight average of ten fine-tuning runs, with extra PhraseBank sentences in training. Earlier weights stay available at git tags:

Companion project: the from-scratch educational transformer (~2M params, no pretrained weights, fully annotated) lives at github.com/shaikn6/nano-finbert.

Results (held-out sets)

All versions were scored with the same code (eval_model.py): max 96 tokens, highest-probability label. Measured 2026-10-28. Cells are accuracy / macro-F1.

Held-out setnv1v2v3
PhraseBank Sentences_AllAgree, stratified 15% test split34095.29% / 0.936896.47% / 0.953297.94% / 0.9643
Finance tweets, full validation file2,38868.22% / 0.616583.75% / 0.799586.43% / 0.8300
Press-release headlines (title field), full test split26771.16% / 0.586472.28% / 0.559475.28% / 0.5904
SEntFiN news headlines, full test split, unanimous headlines93369.67% / 0.697773.20% / 0.736175.99% / 0.7627

Mean macro-F1 over the four sets: v1 0.7093, v2 0.7620, v3 0.7868 (+2.48 points over v2).

Label mapping: tweets Bearish = negative, Bullish = positive, Neutral = neutral. Press-release headlines use the dataset's own class names (0 negative, 1 neutral, 2 positive). SEntFiN labels each company or entity in a headline; only headlines where every entity carries the same label are kept. SEntFiN was never used for training or model selection.

95% intervals (2,000 bootstrap resamples of the rows), v2 vs v3:

Setnv2 macro-F1v3 macro-F1v2 negative recallv3 negative recall
PhraseBank test3400.953 (0.921 to 0.978)0.964 (0.934 to 0.988)0.933 (0.848 to 1.000)0.911 (0.816 to 0.979)
Tweets2,3880.800 (0.781 to 0.817)0.830 (0.812 to 0.847)0.865 (0.827 to 0.900)0.850 (0.810 to 0.886)
Press-release headlines2670.559 (0.470 to 0.648)0.590 (0.485 to 0.695)0.167 (0.000 to 0.417)0.167 (0.000 to 0.417)
SEntFiN headlines9330.736 (0.708 to 0.763)0.763 (0.735 to 0.790)0.757 (0.703 to 0.808)0.722 (0.667 to 0.773)

The intervals overlap on every set, so treat any single-set gain as uncertain; the consistent direction across all four sets is the stronger evidence.

Per-class results, v3 (v2 in brackets):

SetClassSupportPrecisionRecallF1
PhraseBank testnegative450.953 (0.955)0.911 (0.933)0.932 (0.944)
PhraseBank testneutral2091.000 (0.995)0.990 (0.971)0.995 (0.983)
PhraseBank testpositive860.944 (0.902)0.988 (0.965)0.966 (0.933)
Tweetsnegative3470.725 (0.638)0.850 (0.865)0.782 (0.734)
Tweetsneutral1,5660.946 (0.941)0.870 (0.837)0.906 (0.886)
Tweetspositive4750.752 (0.741)0.857 (0.819)0.801 (0.778)
Press-release headlinesnegative120.667 (0.286)0.167 (0.167)0.267 (0.211)
Press-release headlinesneutral1560.764 (0.774)0.853 (0.769)0.806 (0.772)
Press-release headlinespositive990.733 (0.676)0.667 (0.717)0.698 (0.696)
SEntFiN headlinesnegative2590.850 (0.794)0.722 (0.757)0.781 (0.775)
SEntFiN headlinesneutral3420.676 (0.668)0.825 (0.754)0.743 (0.709)
SEntFiN headlinespositive3320.811 (0.763)0.723 (0.690)0.764 (0.725)

Reading the tables:

  • v3 is better than v2 on macro-F1 on all four sets. On tweets it labels far fewer neutral or bullish tweets as negative (negative precision 0.638 to 0.725).
  • Where negative F1 rose, it came from precision, not recall. Negative recall is slightly lower on PhraseBank (0.933 to 0.911), tweets (0.865 to 0.850) and SEntFiN (0.757 to 0.722): v3 misses a few more negatives and raises fewer false alarms on tweets and SEntFiN.
  • Negative press-release headlines are still weak: v3 finds 2 of 12 (v2 found 2). With 12 negatives that figure is very uncertain. On SEntFiN (259 negative headlines) negative recall is 0.722, so the problem is mainly with this one set of press releases.
  • The datasets define sentiment differently (tweets label market direction, PhraseBank labels the tone of a reporting sentence), so the numbers are not directly comparable across rows.

Release rule (and one change to it)

The rule for releasing v3 was set before training: mean macro-F1 over the held-out sets up by at least 1.5 points, no set down by more than 1.0 point, and negative-class F1 no worse on any set.

The candidate (chosen on validation slices only, before any held-out score was seen) met the first two conditions but failed the third by one sentence: PhraseBank negative F1 fell from 0.944 to 0.932 because it found 41 of the 45 negative test sentences and v2 found 42. It was therefore not released at first.

After seeing those held-out results, the third condition was amended to "negative-class F1 falls by no more than 2.0 points on any set". The reason: on PhraseBank that condition is judged on 45 negatives, so one sentence decides it, which is far inside the bootstrap noise (the negative-recall interval spans about 16 points). Changing a rule after seeing test results is a weaker form of evidence, so the original outcome is stated here. No other candidate was searched for after the amendment; the same recipe was retrained and the retrained weights re-scored before release. Before the amendment, one other candidate (a single run, picked on validation with a negative-F1 filter) was scored on the held-out sets once; it failed (mean +0.87 points) and was discarded.

Released weights against v2 (macro-F1 change in points; negative F1):

SetMacro-F1 changev2 negative F1v3 negative F1Change (points)
PhraseBank test+1.120.9440.932-1.20
Tweets+3.050.7340.782+4.81
Press-release headlines+3.090.2110.267+5.61
SEntFiN headlines+2.670.7750.781+0.61

Mean macro-F1 change +2.48 points. Under the original strict rule these released weights would still fail (PhraseBank negative F1 0.932 vs 0.944); under the amended rule they pass. The first-pass candidate scored +2.38 points mean; because Apple-GPU training is not bit-for-bit deterministic, the retrained weights differ slightly from it, and the numbers in this card are for the released file.

Training data

Held out and never used for training or model selection: the PhraseBank 15% test split, the full tweet validation file, the headline test split and all of SEntFiN. Any training text that also appears in one of these or in a validation slice (17 rows, case-insensitive) was dropped.

SourceUsed for trainingUsed for validation
PhraseBank Sentences_AllAgree70% train split (1,584), repeated 3x per epoch15% validation split (340)
PhraseBank 50% / 66% / 75% agreement filesonly sentences not in the all-agree file at all (2,582 / 1,953 / 1,189); majority label; one variant per run-
Tweets, sent_train.csv90% stratified (8,588)10% stratified (955)
Headlines, train split90% stratified (1,360); repeated 2x in three runs10% stratified (152)

Because the extra PhraseBank sentences exclude every all-agree sentence, none of the all-agree test or validation sentences can appear in training. PhraseBank split: stratified 70 / 15 / 15 with scikit-learn train_test_split(random_state=42), test carved first, then validation. Tweets and headlines: one stratified 90 / 10 split (random_state=42) of each training file.

Training details

SettingValue
Base encodermicrosoft/MiniLM-L12-H384-uncased (12 layers, hidden 384)
Parameters33,361,155 (~33.4M)
Objectiveclass-weighted cross-entropy (inverse class frequency)
OptimizerAdamW, weight decay 0.01, gradient clip 1.0
Schedulelinear, 10% warmup; batch 16; max 96 tokens
Epochsup to 3 (4 for the 2e-5 run); validation twice per epoch, early stopping
Checkpoint per runbest mean macro-F1 over the three validation slices
Final weightsuniform average of the ten run checkpoints below (same architecture, same file format)
Hardwareone laptop (Apple GPU)

The ten runs (train.py flags):

RunFlags
1--lr 3e-5
2--lr 3e-5 --pb-extra 50Agree
3--lr 3e-5 --pb-extra 75Agree
4--lr 3e-5 --pb-extra 66Agree
5--lr 2e-5 --pb-extra 66Agree --epochs 4 --patience 3
6--lr 5e-5 --pb-extra 66Agree
7--lr 3e-5 --pb-extra 66Agree --seed 1
8--lr 3e-5 --pb-extra 66Agree --jb-rep 2 --seed 2
9--lr 3e-5 --pb-extra 66Agree --jb-rep 2 --seed 3
10--lr 5e-5 --pb-extra 66Agree --jb-rep 2 --seed 4

Also tried and not used: label smoothing 0.1, and 8,000 short machine-labelled news snippets from NOSIBLE/financial-sentiment; neither improved the validation score.

Reproduce

train.py, common.py, eval_model.py and average.py in this repo hold the code; requirements-train.txt lists the package versions. All datasets are downloaded from the Hub at pinned revisions.

pip install -r requirements-train.txt
python train.py --lr 3e-5 --out run1          # one run, about 10-20 minutes on a laptop GPU
# ... the other nine runs from the table above, each with its own --out
python average.py v3 run1 run2 run3 run4 run5 run6 run7 run8 run9 run10
python eval_model.py v3 - scores.json         # all held-out sets, with bootstrap intervals

Training on an Apple GPU is not bit-for-bit deterministic, so a rerun lands close to, not exactly on, the published numbers. v2 was trained with an earlier copy of train.py that dropped 12 held-out overlaps instead of 17.

Usage

import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer

model_id = "9mark9/finbert-minilm-sentiment"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)
model.eval()

texts = [
    "The company reported record quarterly profit, beating analyst expectations.",
    "Net sales decreased by 12% and the firm warned of further losses ahead.",
    "The board will meet next Tuesday to review the quarterly schedule.",
]

enc = tokenizer(texts, padding=True, truncation=True, max_length=96, return_tensors="pt")
with torch.no_grad():
    probs = model(**enc).logits.softmax(-1)

for text, p in zip(texts, probs):
    label = model.config.id2label[int(p.argmax())]
    print(f"[{label:8s} {p.max():.2f}] {text}")

To load an earlier version, pass revision="v2-mixed-domain" or revision="v1-phrasebank-only" to both from_pretrained calls.

Intended use

  • Sentiment scoring of short financial text: news sentences, headlines, finance tweets, analyst notes.
  • Research, prototyping and teaching, as a compact CPU-friendly alternative to 110M-parameter FinBERT.

Limitations

  • Overlap found after release: when links and punctuation are also stripped before comparing, 80 of the tweet training rows and 8 of the headline training rows match held-out test text (for example the same headline with a different link). This model was trained on them. Worst case, if all 80 matching tweets were answered correctly only because of that, the tweet accuracy of 86.4% would be about 0.5 points lower (85.96% on the other 2,308 tweets). The newer finbert-deberta-large-sentiment was trained without those rows.

  • English only. Max sequence length 96 tokens; longer text is truncated.

  • Weak on negative press-release headlines (2 of 12 found in that test split). On a larger set of news headlines (SEntFiN, 259 negatives) negative recall is 0.722.

  • On finance tweets about 28% of the tweets it calls negative are labelled neutral or bullish.

  • PhraseBank AllAgree is the cleanest, easiest part of that benchmark; expect lower accuracy on ambiguous sentences.

  • Tweet labels describe bullish / bearish market direction, which is not the same as the tone of a sentence. The model mixes both conventions.

  • Not financial advice. Outputs are sentiment labels, not buy/sell signals.

Serving & latency

Full evaluation on the entire zeroshot/twitter-financial-news-sentiment validation split (2,388 rows, not a sample), plus a serving benchmark with ONNX Runtime and dynamic INT8 quantization. CPU, Apple Silicon, 1 inference thread per request (concurrency comes from workers, not intra-op threads).

variantaccuracymacro-F1p50p99peak throughputon-disk
PyTorch (fp32)0.86430.8306.8 ms24.1 ms263 req/s @4w (collapses past 4w, p99 185 ms @8w)—
ONNX fp320.86430.83014.6 ms30.2 ms395 req/s @8w133.7 MB
ONNX INT80.87100.8356.0 ms12.4 ms956 req/s @8w34.0 MB

INT8 quantization gives ~3.6× throughput and a ~3.9× smaller model with no accuracy loss (re-measured on the full set after quantizing, not assumed), and keeps p99 under 19 ms under concurrent load where the PyTorch path degrades.

The quantized model (onnx/model_quantized.onnx) and the reproducible harness (benchmark/) are included in this repo. Numbers are machine-specific; the point is the relative win and the shape of the load curve.

Citation

Dataset:

@article{malo2014good,
  title={Good debt or bad debt: Detecting semantic orientations in economic texts},
  author={Malo, Pekka and Sinha, Ankur and Korhonen, Pekka and Wallenius, Jyrki and Takala, Pyry},
  journal={Journal of the Association for Information Science and Technology},
  volume={65}, number={4}, pages={782--796}, year={2014}
}

Contact

Maintainer: nagizaazs@gmail.com

License

MIT

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · transformers · text-classification

Можно запустить

Подбираем GPU…

Класс архитектуры
BertForSequenceClassification
Ревизия весов
b17b64a

0 моделей