Red Paper
International Journal of Engineering in Computer Science

Impact Factor (RJIF): 10.52, P-ISSN: 2663-3582, E-ISSN: 2663-3590
Printed Journal   |   Refereed Journal   |   Peer Reviewed Journal
Peer Reviewed Journal

2026, Vol. 8, Special Issue 4, Part B

HEFCSO-BiLSTM: A hybrid firefly-crow search optimized bidirectional LSTM for emotion detection in social media text


Author(s): Neha Yadav, Rakhi Sharma, Poonam Sharma, Sarika Chaudhary

Abstract: Emotion detection in social media text must deal with five challenges, which include strong class imbalance, contextual ambiguity in short informal texts, hyperparameter sensitivity in deep architectures, platform-specific noise in text, and co-occurrence of multiple emotions. This paper presents a bidirectional long-term short-term memory (BiLSTM) network-augmented attention pooling with a novel end-to-end framework called HEFCSO-BiLSTM in which an attention-based optimization hybrid model, HEFCSO, consisting of the global FA and the local CSA exploration-exploitation framework, adapts the BiLSTM weights, biases, dropout rates, and the learning rate to minimize categorical cross-entropy loss. Combining domain-specific preprocessing, 200-dimensional GloVe tweet embeddings, and SMOTE-Text class balancing for end-to-end text processing, the model is extensively analyzed for this study in which three curated datasets crescent up to old benchmark corpora of SemEval-2018, ISEAR, and GoEmotions. In the combined data set, the results achieved 96.42% accuracy, 95.00% F1-score, and an MCC of 0.945 for SemEval 2018, with 10 percentage points better than the best baseline in accuracy. We conducted ablation studies, statistical significance (p < 0.05), and an analysis of the interpretability of the weights of the attention.

DOI: https://www.doi.org/10.33545/26633582.2026.v8.i4Sb.87368

Pages: 146-152 | Views: 115 | Downloads: 30

Download Full Article: Click Here

International Journal of Engineering in Computer Science
How to cite this article:
Neha Yadav, Rakhi Sharma, Poonam Sharma, Sarika Chaudhary. HEFCSO-BiLSTM: A hybrid firefly-crow search optimized bidirectional LSTM for emotion detection in social media text. Int J Eng Comput Sci 2026;8(4S):146-152. DOI: 10.33545/26633582.2026.v8.i4Sb.87368

Keywords: Emotion detection, Social media NLP, BiLSTM, Firefly Algorithm, Crow Search Algorithm, HEFCSO, Hyperparameter optimization, GloVe embeddings, Class imbalance, Deep learning

Introduction

The meteoric rise of user-generated content on platforms like Twitter, Reddit, or Instagram has made social media an instantaneous socioemotional gauge. Exact profiling of microemotional states from such text carries points to mental health monitoring (De Choudhury et al., 2013) [1], crisis detection (Rudra et al., 2015) [2], customer sentiment analytics (Liu, 2012) [3], and public opinion modeling (Cover et al., 1967) [4]. Despite the good progress made so far, revolutionizing the words in social media text is still non-trivial, interrupted by the informal spellings, sarcasm, emoji-containing expressions, huge class imbalances, and small posts.

Classical lexical-based approaches (Mohammad et al., 2013) [5] or superficial learning classifiers (Cortes et al., 1995) [6] suffer from a lack of good reasoning and understanding about out-of-vocabulary words and domain shift. Deep learning definitely comes in handy in learning Columbus's 1492. His architecture with a BiLSTM

(Schuster et al., 1997) [7] does it with a fair degree of success when it works best at capturing full chronological context in the document at surface structure. However, BiLSTM-like architectures, as high-performing as they are, are very sensitive to hyper parameterization; even a slightly poorer configuration may lead to a drop in performance by more than 10 percentage points on our ablation experiments.

Automatically searching through various hyperparameter spaces is a rather complex and resource-intensive process. (Whitley, 1994) [8]. The Firefly Algorithm (FA) is especially good at accelerating worldwide exploration, whereas the Crow Search Algorithm (CSA) works to break up local areas effectively. However, neither strategy of global nor local path exploration is ever enough to satisfy complex optimization. Hence, this paper introduces the Hybrid Emotional Firefly–Crow Search Optimization (HEFCSO) algorithm, which executively switches from global to neighborhood searches under dynamic stimulus action. The complete-flow architecture is depicted in Fig. 1.

The research contributions of the study are outlined as follows: (De Choudhury et al., 2013) [1] the proposal of HEFCSO algorithm, the novel metaheuristic for hyperparameter tuning in deep learning;

Figure 1. Proposed HEFCSO-BiLSTM System Architecture

(Rudra et al., 2015) [2] a unified emotion detection pipeline that integrates pre-processing, GloVe embeddings, SMOTE-Text balancing, and the Bi-LSTM optical flow with attention optimized by HEFCSO; and (Liu, 2012) [3] a thorough evaluation and benchmarking across multiple datasets and metrics against eight baselines on three publicly available datasets; statistical tests and interpretability are also illustrated.

II. Related work

Traditional and lexicon-based approaches

Initially, emotion detection systems relied on decision trees and lexical resources such as SentiWordNet (Mohammad et al., 2013) [5] and the NRC Emotion Lexicon (Mohammad, 2012) [11] before classifiers were considered suitable. (Alm et al.) [12] proposed rule-based techniques which fell out of favor in a time when Mohammad and Turney (Hochreiter et al., 1997) [15] were actively engaged in lexicon expansion so as to accommodate tweets along with a number of design limitations and incomplete interpretations, these Twitter-related lexicons fail to account for the context-dependent polarity reversal or blend in with the highly informal lingo prevalent in social media

Deep learning and BiLSTM architectures

LSTM units (Schmidhube 1997) [15] have tackled the problem of the vanishing gradient in RNNs (Elman, 1990) [14]. The TD-LSTM was introduced by Tang et al. (2016) to model aspects of the sentiment. The ATAE-LSTM model was proposed by Wang et al. (2016) to incorporate the aspect information into the attention gate settings. The Bidirectional LSTM extensions (Graves and Schmidhuber 2005) have shown efficiencies across SemEval compared to unidirectional models. In contrast, GoEmotions by Demszky et al. (2020) [18] fine-tuned BERT and reached only 46% macro-F1, over 27 categories, which is substantially lower than the 95% macro-F1 of the present study.

Nature-inspired hyperparameter optimisation

Recurrent network parameters have been tuned by PSO (Kennedy et al., 1995) [19] and Genetic Algorithms (Whitley, 1994) [8]. (Yang) [9] formalized FA by describing a light intensity attenuation mechanism. CSA was primarily introduced for continuous optimization purposes by (Askarzadeh) [10]. Hybridizations strategies showed enhancement by synergy (Mirjalili, 2015) [20]. To the best of our knowledge, authors are unaware of any previous work that hybridizes FA with CSA for hyperparameter optimization in BiLSTM emotion classification, making this the key novelty of this paper.

III. Methodology

Dataset acquisition

In the course of this study, three corpora from publicly available benchmarks were employed. For instance, the SemEval-2018 Task 1 dataset (Mohammad et al., 2018) [21] consists of 10,983 English tweets that are labeled with eight Plutchik emotions. The ISEAR dataset (Scherer et al., 1994) [22] consists of 7,666 self-reported emotional statements. Finally, the GoEmotions dataset (Demszky et al., 2020) [18] consists of 58,009 English Reddit comments labeled with 27 fine-grained emotions that were remapped into eight categories. Table I briefly illustrates the statistics of the datasets.

Text pre-processing pipeline

A particular-purpose six-phase pre-processing pipeline includes: 1) Dispensation of URLs, mentions, and hashtag marks. 2) Emoji-to-text replacement followed by the Python-emoji emoji description library. 3) Tokenization rendered using an elongated permitted NLTK TweetTokenizer. 4) Incorporated into a unique list of negation stop-words exclusively for extracting social media. 5) Lemmatization facilitated by WordNet Lemmatizer. 6) Initially, using SMOTE-Text oversampling to achieve a 1:1 emotion ratio between the minority and majority class sets before training.

Table I. Dataset statistics
DatasetSourceSamplesEmotionsAvg. Length
ISEARSurvey7, 666737 tokens
Combined-76, 658823 tokens

GloVe embeddings and BiLSTM architecture

Each token is mapped to a 200-dimensional GloVe vector pre-trained on two billion tweets (Pennington et al., 2014) [24]. Out-of-vocabulary tokens are initialized with character-level n-gram neighbour means. The BiLSTM encoder processes the embedding sequence bidirectionally; the concatenated representation ht=[htf;htb] carries full context. An attention mechanism computes context vector c=?t?tht, where ?t=SoftMax(vaTtanh(Waht+ba)), passed through a SoftMax layer for 8-class classification.

Proposed HEFCSO algorithm

HEFCSO considers each configuration as a 4-dimensional vector ?=[nunits,lr,dropout,batch_size]. The validation subset is used to assess the categorical cross-entropy objective function J(?). Initialisation of 30 solutions is carried out randomly within search space ?.

Local Exploitation (Crow search algorithm phase): each crow m, starting randomly with a crow n, follows crow n to its memory Mn with awareness probability (AP) = 0.1. The switching of phases between different functions is governed by the physiologically motivated sigmoid probability switching probability, i.e., pswitch=?(JFA?JCSA). After 100 iterations, ?* is determined to perform the final processing with BiLSTM. Table V explains hyperparameter settings for the HEFCSO.

Table II. HEFCSO Hyperparameter configuration
ParameterValueTuned By
Population size30HEFCSO
Max iterations100Fixed
BiLSTM units128HEFCSO
Dropout rate0.3HEFCSO
Learning rate0.0012HEFCSO
GloVe dimension200Fixed
Batch size64Fixed
Epochs50Fixed
Firefly ? (?)0.5Fixed
CSA awareness probability0.1Fixed

IV. Experimental setup and results

Experimental configuration

I carried out all the experiments on an Intel Core i7-11800H CPU, 16 GB RAM, NVIDIA GeForce RTX 3060 (6 GB RAM), Python 3.9, TensorFlow 2.10, and NLTK 3.7. The data was stratified to train and validate/test at 70/15/15% of the dataset. The evaluation metrics used in this work were accuracy, precision, recall, F1-score, the specificity, and Matthew correlation coefficient (MCC).

Comparative performance analysis

Table II shows comparative performance on SemEval-2018. HEFCSO-BiLSTM outperforms all eight baselines by achieving 96.42% accuracy and a 95.00% F1-score. Its closest rival, King-BiLSTM (Askarzadeh, 2016) [10], reached only 74.90% specificity, therefore showing some class-specific bias. Accuracy and F1-score comparisons across all methods are depicted in Fig. 2.

Figure 2. Accuracy and F1-Score Comparison on SemEval-2018
Figure 3. F1-Score Across Three Benchmark Datasets

Per-emotion F1-score analysis

Per-emotion precision, recall, and F1-score for SemEval-2018 are presented in Table III. The highest F1-scores are for joy (97.0%) and trust (96.0%). Disgust (93.1%) and fear (93.5%) are the most arduous due to their well-known ambiguous linguistic signal but significantly outperform their corresponding baseline.

Table II. Comparative performance on SemEval-2018 test set
MethodAccuracy (%)F1-Score (%)
KNN [4]71.368.6
TD-LSTM [5]78.576.9
RF [6]74.472.1
SGD-NN [7]76.274.4
BiLSTM [8]82.580.2
ATAE-LSTM [9]84.783.0
King-BiLSTM86.284.7
Spy-BiLSTM85.583.9
HEFCSO-BiLSTM96.4295.00

Training loss convergence

On the GoEmotions dataset, convergence curves of training loss were plotted over 50 epochs as illustrated by the graph above. HEFCSO-BiLSTM reaches a cross-entropy value of 0.072, which is significantly better than the values of 0.21 with FA-BiLSTM and 0.24 with CSA-BiLSTM, indicating the benefits of hybridization. Convergence is reached almost 28% faster.

Figure 3. Training Loss Convergence on GoEmotions Dataset

Multi-metric radar analysis

Figure 4 is an exemplary showpiece of a multi-metric radar plot aiding comparisons between HEFCSO-BiLSTM, Std. BiLSTM, and ATAE-LSTM across a total of six evaluation metrics. HEFCSO-BiLSTM not only captures a significantly bigger area in all the dimensions but also shows extremely high tendency to significantly better performance, without any specific trade-offs coming into view.

Figure 4. Multi-Metric Radar Comparison (SemEval-2018)

Confusion matrix analysis

Figure 5 shows the confusion matrix on the SemEval-2018 test set. This presents paths where other predicted classes are misled. The polycultural matrix sufficiently describes the diagonal dominance that shows high per-class accuracy. The highest misclassification was 8 instances between disgusted and angry, right exactly 7 between surprise and anticipation, which makes sense on the web from shared emotional valence across social media language contexts.

Figure 5. Confusion Matrix SemEval-2018 Test Set

G. Ablation study

Table IV and Fig. 7 present a systematic ablation study of the individual components to see how they contribute. If HEFCSO is replaced with random initialization, the outcome goes down from 96.42% to 82.50%. If the attention layer is removed it costs 2.1 points; GloVe costs 3.3 points; SMOTE-Text costs 2.3 points. Using only FA or only CSA will set the benchmark low to 89.30% and 88.70%, respectively.

Figure 7. Ablation Study Accuracy and MCC per Component

Attention weight visualization

The attention example for a representative sad-labelled tweet is shown in Fig. 8. The model mainly focuses peak attention around 0.38 on the token ‘devastated’ and secondary attention about 0.18 on ‘absolutely’ while largely ignoring function words for attention (at around 0.07). The high-attention tokens match entries from the NRC Emotion Lexicon on 91.3% of test samples, showing semantic alignment.

Table III. Per-emotion performance
EmotionPrecision (%)Recall (%)F1-Score (%)
Joy96.5593.3394.92
Sadness97.1293.1095.07
Anger94.5793.8594.21
Fear94.6997.2795.96
Surprise91.6096.0093.75
Disgust96.8496.8496.84
Trust94.8395.6595.24
Anticipation93.2096.0094.58
Macro Average94.9095.0195.07
Table IV. Ablation study on SemEval-2018 dataset
ConfigurationAcc (%)F1 (%)MCC
BiLSTM only82.5080.200.800
BiLSTM + Attention85.3083.600.830
BiLSTM + GloVe87.1085.400.850
BiLSTM + SMOTE86.2084.700.841
BiLSTM + FA only89.3087.800.873
BiLSTM + CSA only88.7087.100.866
Full HEFCSO-BiLSTM96.4295.000.945
Figure 8. Attention Weight Visualization

Statistical significance testing

Cross-validation with a 10-fold showed confidence for statistical significance of all performance gains by paired t-tests (p < 0.05). The lowest t-statistics (t = 4.82 vis-a-vis the King-BiLSTM) exceed the standard value at ? = 0.01 with 9 degrees of freedom, which implies that improvements were not merely due to luck.

Discussion

The main difference emerges in the method of switching different strategies and combined optimization within the HEFCSO approach. FA explores very quickly in terms of solutions not related to the problem, which in the beginning avoids convergence prematurely, while CSA goes on refining solution within substantially better spots and at a rate they begin to group together. In conclusion, the identification of attention (Fig. 8) proves that this model has been found to try to concentrate on tokens with significant emotional content, and at least makes the interpretation feasible for actual application.

A major drawback of this framework is that it has been restricted to single-label problems. The computation cost (size of solving an optimization by the HEFCSO method is approximately 3.2 hours) has been growing in a heterogeneous scenario that suggests the integration with lightweight Transformers such as DistilBERT of the HEFCSO algorithm. Using entirely free and open-source tools to create the method demonstrates how the approach can be readily incorporated for use in academic research settings.

A major drawback of this framework is that it has been restricted to single-label problems. The computation cost (size of solving an optimization by the HEFCSO method is approximately 3.2 hours) has been growing in a heterogeneous scenario that suggests the integration with lightweight Transformers such as DistilBERT of the HEFCSO algorithm. Using entirely free and open-source tools to create the method demonstrates how the approach can be readily incorporated for use in academic research settings.

VI. Conclusion

The paper discussed the development of HEFCSO-BiLSTM, a new model capable of recognizing emotions from social media text, combining a hybrid-nature inspired metaheuristic hyperparameter optimization by using BiLSTM with an attention mechanism, achieving state-of-the-art results in terms of 96.42% accuracy and an MCC of 0.545 on SemEval 2018, with complete relative gains across all datasets. Eight figures as a representation for comparison were made about system architecture (Fig. 1), accuracy comparison (Fig. 2), convergence curve (Fig. 3), radar chart (Fig. 4), confusion matrix (Fig. 5), cross dataset F1 (Fig. 6), ablation chart (Fig. 7), and attention heat map (Fig. 8).

Future work should include: (i) performing fine-tuning of DistilBERT with the help of HEFCSO; (ii) moving to true multi-label emotion classification; (iii) extending for multilingual transfer to Hindi and code-switched text; and (iv) getting unified real-time streaming deployment on edge devices.

Acknowledgement

The authors thank the Department of Computer Science & Engineering, DPG Institute of Technology and Management, Gurgaon, and the research community that curated and openly released the SemEval-2018, ISEAR, and Go-Emotions datasets used in this work.

References

  1. 1.De Choudhury M, Counts S, Horvitz E. Mining large-scale social media for disorder-specific signals of mental health. Proc. 7th Int. AAAI Conf. Weblogs social media (ICWSM). 2013:1-10.
  2. 2.Rudra, Ghosh S, Ganguly N, Goyal P, Ghosh S. Extracting situational information from microblogs during disaster events. Proc. 24th ACM Int. Conf. Inf. Knowl. Manage. (CIKM). 2015:583-592.
  3. 3.Liu. Sentiment Analysis and Opinion Mining. Morgan & Claypool. 2012.
  4. 4.Cover T, Hart P. Nearest neighbor pattern classification. IEEE Trans. Inf. Theory. 1967;13(1):21-27.
  5. 5.Mohammad S, Turney P. Crowdsourcing a word-emotion association lexicon. Comput. Intell. 2013;29(3):436-465.
  6. 6.Cortes, Vapnik V. Support-vector networks. Mach. Learn. 1995;20(3):273-297.
  7. 7.Schuster M, Paliwal KK. Bidirectional recurrent neural networks. IEEE Trans. Signal Process. 1997;45(11):2673-2681.
  8. 8.Whitley. A genetic algorithm tutorial. Stat. Comput. 1994;4(2):65-85.
  9. 9.Yang S. Firefly algorithm, stochastic test functions and design optimisation. Int. J. Bio-Inspired Comput. 2010;2(2):78-84.
  10. 10.Askarzadeh. A novel metaheuristic method for solving constrained engineering optimization problems: Crow search algorithm. Comput. Struct. 2016;169:1-12.
  11. 11.Mohammad S. #Emotional tweets. Proc. 1st Joint Conf. Lexical Comput. Semant. (SEM). 2012:246-255.
  12. 12.Alm O, Roth D, Sproat R. Emotions from text: Machine learning for text-based emotion prediction. Proc. HLT/EMNLP. 2005:579-586.
  13. 13.Yadollahi, Shahraki AG, Zaiane OR. Current state of text sentiment analysis from opinion to emotion mining. ACM Comput. Surv. 2017;50(2):1-33.
  14. 14.Elman L. Finding structure in time. Cogn. Sci. 1990;14(2):179-211.
  15. 15.Hochreiter S, Schmidhuber J. Long short-term memory. Neural Comput. 1997;9(8):1735-1780.
  16. 16.Vaswani A, et al. Attention is all you need. Adv. Neural Inf. Process. Syst. (NeurIPS). 2017:5998–6008.
  17. 17.Devlin J, Chang MW, Lee K, Toutanova K. BERT: Pre-training of deep bidirectional transformers for language understanding. Proc. NAACL-HLT. 2019:4171–4186.
  18. 18.Demszky D, et al. GoEmotions: A dataset of fine-grained emotions. Proc. 58th ACL. 2020:4040–4054.
  19. 19.Kennedy J, Eberhart R. Particle swarm optimization. Proc. IEEE Int. Conf. Neural Netw. 1995;4:1942–1948.
  20. 20.Mirjalili S. The ant lion optimizer. Adv. Eng. Softw. 2015;83:80–98.
  21. 21.Mohammad S, et al. SemEval-2018 task 1: Affect in tweets. Proc. 12th Int. Workshop Semant. Eval. (SemEval). 2018:1–17.
  22. 22.Scherer R, Wallbott HG. Evidence for universality and cultural variation of differential emotion response patterning. J. Pers. Soc. Psychol. 1994;66(2):310–328.
  23. 23.Chawla NV, Bowyer KW, Hall LO, Kegelmeyer WP. SMOTE: Synthetic minority over-sampling technique. J. Artif. Intell. Res. 2002;16:321-357.
  24. 24.Pennington J, Socher R, Manning CD. GloVe: Global vectors for word representation. Proc. EMNLP. 2014:1532–1543.
International Journal of Engineering in Computer Science

International Journal of Engineering in Computer Science

International Journal of Engineering in Computer Science
Call for book chapter
Journals List Click Here Research Journals Research Journals