Figure 1. Formatting sentiment analysis dataset into instruction tuning dataset
Although pre-trained language models have abilities such as reasoning, understanding numbers, knowledge of the world, and multilingualism, they still have trouble effectively applying these abilities to specific tasks. This limitation limits their ability to achieve state-of-the-art (SOTA)[45] performance on particular tasks, thus limiting their application potential.
For example, researchers have found that the zero-sample performance of pre-trained language models is significantly lower than in the case of small samples. In our scenario, we provide supervised signals using instruction data, which often contains numeric values, financial context, and financial terminology, to improve the model’s performance. Through instruction tuning, we match the ability of the language model to the sentiment analysis label, resulting in a more accurate and nuanced understanding of the emotions expressed in financial texts, making it better at financial sentiment analysis than pre-trained language models and specially designed supervised models.
We use the instruction-tuned LLaMA-7B LLM model as an example to validate our idea. Instruction tuning is a way to fine-tune a pre-trained language model using formatted instances in natural language. This approach is closely related to supervised fine-tuning. We used formatting examples during training to fine-tune the LLaMA 7B language model using sequence-to-sequence losses[46-47]. This choice allowed us to demonstrate the effectiveness and applicability of instruction tuning in improving the performance of financial sentiment analysis in pre-trained language models such as LLaMA-7B.
Mapping the generated output to emotional labels Since the instruction-fine-tuned LLaMA-7B is an autoregressive generation model, it is still possible to create free-style text even if we train it with an instruction template to guide its output toward the desired emotional judgment. Therefore, we need to map the model output back to the three emotional labels specified to make a proper evaluation. Our approach is as follows: If the production of the model contains the words ”positive”, ”negative”, or ”neutral”, we map it to the appropriate label; Otherwise, we consider it a ”neutral” emotion[48].

## Comparison of LLM and FinBERT in sentiment analysis

Our approach uses a pre-trained language model (LLM) and compares its effectiveness in sentiment analysis with a mature FinBERT model. The comparison is based on three key aspects:
Context understanding: Because LLMS is pre-trained on a large scale on diverse data, they have a more comprehensive general knowledge and can understand the context better than FinBERT. The diversity and richness of LLM’s training datasets are unmatched, giving it a comprehensive knowledge that is superior to FinBERT’s.
Numerical sensitivity: Financial texts often contain significant numerical data, which is critical in conveying emotion. LLM has inherent numerical sensitivity and can better interpret the feelings implied by value fluctuations. For an in-depth study of this feature of LLM, please refer to some academic reports.
• Decoder-only vs encoder-only model[49]: FinBERT is an encoder-only model that encodes an input sequence as a representation and relies on a separate classifier to make predictions based on the encoded representation.
The LLM used, on the other hand, is a decoder-only model that can generate the entire output sequence, including class labels, directly from the underlying representation or fixed-length vectors. This feature allows LLM to be easily adapted to a variety of tasks. In contrast, encoder-only models require the development of task-specific classifiers, which can be more time-consuming and laborious.