202404_ramai_financial-sentiment-analysis-with-llm
202404_ramai_financial-sentiment-analysis-with-llm
Financial Sentiment
Analysis with Large
Language Models:
An Introductory & Comparative
Study on News Flow
Systematic Equity Team - Emmanuel Hauptmann, Valentin
Betrix, Nicolas Jamet, Tian Guo, Louis-Alexandre Piquet
Convinction in Fundamentals.
Powered by Technology.
Introduction.
Sentiment Analysis is the process by which a positive, negative or neutral tone is
assigned to text. In finance, the role of sentiment analysis is to extract a numerical
signal from financial text.2,4,10,13 In the last years, the sentiment analysis process
has transitioned from traditional dictionary-based approaches3 to Machine
Learning and Natural Language Processing (NLP) based methods leveraging text
embeddings and (large) language models (LLMs).7,8,12 Text embedding is an NLP
technique that transforms words, phrases or documents into numerical
representations in the high-dimensional vector space, where semantically similar
entities are located closer to each other.1 This technique has significantly
improved NLP research, but cannot consistently adapt to the variability of text
meaning in different contexts.
In this paper, we will introduce two techniques for undertaking financial sentiment analysis using
LLMs. Firstly, we present the pre-training and fine-tuning process of adapting an LLM for financial
sentiment analysis, i.e., from BERT to FinBERT.6,7 Then, we describe a Transformer variant
DeBERTa (Decoding-enhanced BERT with disentangled attention)9,11 and FinDeBERTa featuring
the technique of disentangled representations (or embeddings). As shown in Table 1, DeBERTa
presents a competitive performance on several NLP benchmarks.
BERT is among the first generation of LLMs built with the Transformer architecture, which
implements a self-attention mechanism that considers both left and right contexts for each word
in a text sequence, as shown in Figure 2 (a).
Before training BERT on real text data, it has no language knowledge. The pre-training step is to let
BERT encode the general language pattern in a large corpus, e.g., Wikipedia, BookCorpus, as
illustrated by Figure 2 (a).
Figure 2: Pre-training and fine-tuning Paradigm. The small gray blocks represent individual tokens of a text sequence.
(a) the self-attention first computes pair-wise similarities of tokens and then represents each token with a similarity-
weighted combination of all tokens’ embeddings. (b) after the pre-training, BERT encodes the general language
knowledge. Then, the labelled sentiment data is used to fine-tune BERT. (c) after fine-tuning, financial sentiment analysis
obtains the tailored model FinBERT.
Figure 2 (b) shows the fine-tuning phase typically uses a small and labelled sentiment dataset,
such as the financial PhraseBank, to adapt BERT to the sentiment analysis.4 The parameters of
the pre-trained BERT are marginally updated with better-fitting financial text and associated
sentiment. The outcome is the fine-tuned BERT named FinBERT in Figure 1 (c), which contains
both knowledge of general languages and financial text sentiments.
Figure 3: Disentangled representations in DeBERTa. (a) BERT self-attention mechanism. (b) the self-attention in
DeBERTa uses separate content and position embeddings to represent one token. Unlike BERT in (a), the pair-wise
similarity calculation is based both on the content and position embeddings.
As shown in Figure 3 (b), the disentangled self-attention in DeBERTa has two representations that
account for each token’s positional and content information, respectively. This is motivated by the
observation that the meaning of words or phrases depends not only on the content but also on the
position. For example, the words ‘dividend’ and ‘yield’ refer to the financial ratio (dividend/price) if
they are adjacent while having a different meaning if they are apart. Then, similarly, through the
pre-training and fine-tuning paradigm, we can build FinDeBERTa for financial sentiment tasks.
In this part, we report the backtest results to demonstrate the predictive power of the sentiment
factors for the stock forward return. To compare beyond FinBERT and FinDeBERTa, we add a
baseline, FinVader, a dictionary-based method adapted to add a financial sentiment lexicon.12 The
sentiment factor is constructed by applying these sentiment models to financial news (provided by
StreetAccount) and then aggregating the sentiment values as the factors of the corresponding
stocks.
North North
Europe Europe Global Global
America America
Coverage #news Coverage #news
Coverage #news
56% 5.9million 68% 17.6million 52% 26.5million
Table 2: Statistics of News Flow Data in Different Universes.
The coverage refers to the percentage of stocks in the universe that have associated news.
Backtest Results
The backtest is performed on three different investment universes: Europe (Figure 4),
North America (Figure 5) and Global, including both developed and emerging markets
(Figure 6). The rebalancing frequency is monthly. Details of the news flow and labelled
financial sentiment data are given in Table 2 and 3.
The cumulative performance charts below show that FinDeBERTa mostly outperforms
FinVader and FinBERT. When comparing the charts of the all cap segment to those of large
and small and mid (SMID) caps, it shows that the all cap performance is highly attributed
to the SMID cap, suggesting that SMID companies might be more affected beyond intraday
movements by news events. Large cap stocks tend to be more stable on this monthly
horizon and the impact of news is likely to be evidenced at higher frequencies, e.g., intraday
patterns. We leave this for future work.
As shown in the decile return bar plot in Figures 4, 5 and 6, the decile return of stocks is
positively correlated to the factor value. Therefore, this shows a certain monotonicity which
is favourable for quantitative investing.
Figure 5: North America Investment Universe. Top row: the cumulative return of stocks in the top decile of the
sentiment factor relative to the universe average of all cap, large cap and small and mid (SMID) cap. Bottom row: the
absolute return of the stocks falling in each decile of the sentiment factor.
Qualitative Analysis
Next, we provide a qualitative analysis using news examples to get a sense of these
models’ different capabilities.
Figure 7: News Examples and Sentiment Labels by Models. The green (or red) underlines indicate the determinative
words of the positive (or negative) sentiments.
In Figure 7, we present two news groups: the positive and negative. Each group has four
news pieces. The company or entity names are anonymised to avoid entity bias. The green
(or red) underlines indicate the determinative words of the positive (or negative)
sentiments.
In each group, the first two news items are relatively easy, as the underlined words’
sentiment is evident to determine. The last two are challenging, as they require the
sentiment model to recognise the finance-report-specific comparison pattern (e.g., income
CHF 1.39B vs consensus CHF 1.34B).
In both groups, FinDeBERTa gives correct labels. FinBERT fails on the news, which includes
the comparison pattern and the one where the words combined reverse the sentiment, i.e.,
‘operating costs’ and ‘increased.’ This implies the FinBERT’s context-understanding ability
is still weak.
In this paper, we introduce the techniques to adapt LLMs to financial sentiment analysis tasks
through the pre-training and fine-tuning paradigm. We applied two fine-tuned LLMs, FinBERT and
FinDeBERTa to financial news flow and backtested the derived sentiment factors. The results
demonstrate that the news sentiment captured by LLMs-based models has the desired predictive
power for stock forward returns. Moreover, the effect of news sentiment varies across market
segments, i.e., the sentiment of SMID cap stocks is more predictive for the forward return on the
monthly rebalancing horizon, while large cap stocks tend to be more stable on this horizon. In our
future work, we will be exploring the impact of news at higher rebalancing frequencies.
[email protected]
ram-ai.com © RAM Active Investments 2024. All rights reserved. Private & Confidential.
Disclaimer
Important Information:
The information and analyses contained in this document are based on sources deemed to be reliable. However, RAM Active
Investments S.A. cannot guarantee that said information and analyses are up-to-date, accurate or exhaustive, and accepts no
liability for any loss or damage that may result from their use. All information and assessments are subject to change without
notice.
This document has been drawn up for information purposes only. It is neither an offer nor an invitation to buy or sell the
investment products mentioned herein and may not be interpreted as an investment advisory service. It is not intended to be
distributed, published or used in a jurisdiction where such distribution, publication or use is forbidden, and is not intended
for any person or entity to whom or to which it would be illegal to address such a document. In particular, the investment
products are not offered for sale in the United States or its territories and possessions, nor to any US person (citizens
or residents of the United States of America). The opinions expressed herein do not take into account each customer’s
individual situation, objectives or needs. Customers should form their own opinion about any security or financial instrument
mentioned in this document. Prior to any transaction, customers should check whether it is suited to their personal
situation, and analyse the specific risks incurred, especially financial, legal and tax risks, and consult professional advisers if
necessary.
This document is strictly confidential and addressed solely to its intended recipient; its reproduction and distribution are
prohibited. It has not been approved by any financial Authority. Issued in Switzerland by RAM Active Investments S.A. ((Rue
du Rhône 8 CH-1204 Geneva)) which is authorised and regulated in Switzerland by the Swiss Financial Market Supervisory
Authority (FINMA). Issued in the European Union and the EEA by the Management Company RAM Active Investments
(Europe) S.A., 51 av. John F. Kennedy L-1855 Luxembourg, Grand Duchy of Luxembourg. Distributed in the United Kingdom
to professional investors by RAM AI Advisory, a trading name of Sturgeon Ventures LLP utilised under exclusive license.
Sturgeon Ventures LLP (FRN: 452811) is authorised and regulated by the Financial Conduct Authority (FCA).
No part of this document may be copied, stored electronically or transferred in any way, whether manually or electronically,
without the prior agreement of RAM Active Investments S.A.
[email protected]
ram-ai.com © RAM Active Investments 2024. All rights reserved. Private & Confidential.