Context-Aware Hybrid Text Generation Integrating Bidirectional Long Short-Term Memory Sequencing with Semantic Clustering
DOI:
https://doi.org/10.51173/jt.v8i2.2840Keywords:
Semantic Clustering, Word2Vec, Context-Aware, Natural Language GenerationAbstract
Natural language generation systems sometimes struggle to model long-range semantic connections and maintain contextual consistency, especially when applied to linguistically sophisticated literary corpora. Traditional recurrent neural architectures are good at modeling sequential patterns but typically fail to preserve higher-level thematic and stylistic information in text production. The current paper proposes a semantic-aware hybrid framework based on Word2Vec embedding representations, ++K-Means semantic clustering, and Bidirectional Long Short-Term Memory (Bi-LSTM) sequence learning to improve contextual coherence and next-word prediction performance. In the proposed architecture, the model learns to obtain semantic context vectors from clustered embedding spaces and to fuse them with sequential hidden representations for better language modeling. This study examines the system on three benchmark datasets from English corpora of both literary and general domains: the Nietzsche corpus, Shakespeare plays and WikiText-2. Experimental results show that the proposed semantic-aware recurrent architecture consistently outperforms the standard statistical and neural baseline models. The model achieves prediction accuracies of 67.4%, 61.3%, and 63.1% on the Nietzsche, Shakespeare, and WikiText-2 datasets, respectively, while reducing perplexity values and enhancing linguistic coherence. A more detailed analysis of the robustness test, semantic error evaluation, and ablation experiments confirm that semantic clustering effectively can improve contextual consistency, stylistic preservation, and semantic continuity. The results demonstrate that combining clustering-based semantic abstractions with recurrent sequence modeling is an effective, computationally lightweight approach to context-aware text synthesis for both literary and general-domain applications.
Downloads
References
W. H. Bisen and A. J. Agrawal, “Review on Natural Language Generation,” Int. J. Health Sci., pp. 10365–10376, May 2022, https://doi.org/10.53730/ijhs.v6nS1.7489.
R. Arabelli, S. Gupta, N. Prakash, and Z. Ali, “Natural Language Generation in AI: Developing Human-Like Text Through Deep Learning,” in 2025 First International Conference on Advances in Computer Science, Electrical, Electronics, and Communication Technologies (CE2CT), Bhimtal, Nainital, India: IEEE, Feb. 2025, pp. 1411–1415 https://doi.org/10.1109/CE2CT64011.2025.10939615.
D. Shan, K. Yao, and X. Zhang, “Sequential Learning Network with Residual Blocks: Incorporating Temporal Convolutional Information into Recurrent Neural Networks,” IEEE Trans. Cogn. Dev. Syst., vol. 16, no. 1, pp. 396–401, Feb. 2024, https://doi.org/10.1109/TCDS.2023.3325358.
S. M. Al-Selwi, M. F. Hassan, S. J. Abdulkadir, and A. Muneer, “LSTM Inefficiency in Long-Term Dependencies Regression Problems,” J. Adv. Res. Appl. Sci. Eng. Technol., vol. 30, no. 3, pp. 16–31, May 2023, https://doi.org/10.37934/araset.30.3.1631.
M. Kanmani, S. H S, A. Mergin, I. T. Joseph S, and V. V, “Enhancing Sentence Prediction through Bidirectional Long Short-Term Memory Networks,” Int. J. Electron. Commun. Eng., vol. 13, no. 3, pp. 292–300, Mar. 2026, https://doi.org/10.14445/23488549/IJECE-V13I3P123.
I. van Heerden and A. Bas, “A Perspective on Literary Metaphor in the Context of Generative AI,” 2024. [Online]. Available: https://arxiv.org/pdf/2409.01053
L. Pathak, K. Lochab, and V. Gidwani, “Character-Level Text Generation for Shakespearean Style with LSTMs,” Int. J. Innov. Sci. Res. Technol., vol. X, no. Y, pp. 1425–1431, Sep. 2024, https://doi.org/110.38124/ijisrt/IJISRT24AUG1043.
M. Th, S. Sahu, and A. Anand, “Evaluating distributed word representations for capturing semantics of biomedical concepts,” in Proceedings of BioNLP 15, Beijing, China: Association for Computational Linguistics, 2015, pp. 158–163. https://doi.org/10.18653/v1/W15-3820.
[9] C. Zhang et al., “From Word Vectors to Multimodal Embeddings: Techniques, Applications, and Future Directions for Large Language Models,” arXiv preprint arXiv:2411.05036, 2024, https://doi.org/110.48550/ARXIV.2411.05036.
R. Choudhary, O. Alsayed, S. Doboli, and A. A. Minai, “Building Semantic Cognitive Maps with Text Embedding and Clustering,” in 2022 International Joint Conference on Neural Networks (IJCNN), Padua, Italy: IEEE, Jul. 2022, pp. 01–08. https://doi.org/10.1109/IJCNN55064.2022.9892429.
S. Jung, “Semantic Vector Learning and Visualization with Semantic Cluster Using Transformers in Natural Language Understanding,” J. Comput. Sci. Eng., vol. 16, no. 2, pp. 63–78, Jun. 2022, https://doi.org/10.5626/JCSE.2022.16.2.63.
F. Viegas, L. Rocha, and M. A. Gonçalves, “On the Role of Semantic Word Clusters — CluWords — in Natural Language Processing (NLP) Tasks,” in Anais do XXXVII Concurso de Teses e Dissertações (CTD 2024), Brasil: Sociedade Brasileira de Computação - SBC, Jul. 2024, pp. 38–47. https://doi.org/10.5753/ctd.2024.2036.
S. Jung and S. Lim, “Cluster-aware Semantic Vector Learning Using BERT in Natural Language Understanding,” in 2021 IEEE Int. Conf. Big Data Smart Comput. (BigComp), Jeju Island, South Korea, Jan. 2021, pp. 91–98, https://doi.org/10.1109/BigComp51126.2021.00026.
Q. Guo, X. Qiu, X. Xue, and Z. Zhang, “Low-Rank and Locality Constrained Self-Attention for Sequence Modeling,” IEEE/ACM Trans. Audio Speech Lang. Process., vol. 27, no. 12, pp. 2213–2222, Dec. 2019, doi: 10.1109/TASLP.2019.2944078. https://doi.org/10.1109/TASLP.2019.2944078.
E. Shirazi and A. H. Ardakani, “How Much Attention to Pay? Attention-Enhanced Sequential Learning Models,” in 2025 IEEE PES Innov. Smart Grid Technol. Conf. Eur. (ISGT Europe), Valletta, Malta, Oct. 2025, pp. 1–5, https://doi.org/10.1109/ISGTEurope64741.2025.11305453.
J. Armengol-Estapé and M. R. Costa-Jussà, “Semantic and syntactic information for neural machine translation: Injecting Features to the Transformer,” Mach. Transl., vol. 35, no. 1, pp. 3–17, Apr. 2021, https://doi.org/10.1007/s10590-021-09264-2.
R. Katrix, Q. Carroway, R. Hawkesbury, and M. Heathfield, “Context-Aware Semantic Recomposition Mechanism for Large Language Models,” arXiv:2501.17386, 2025, https://doi.org/10.48550/ARXIV.2501.17386.
J. K. Miller and T. J. Alexander, “Human-interpretable clustering of short text using large language models,” R. Soc. Open Sci., vol. 12, no. 1, Art. no. 241692, 2025, https://doi.org/10.1098/rsos.241692.
N. Fulda, “You Are What You Read: The Effect of Corpus and Training Task on Semantic Absorption in Recurrent Neural Architectures,” in 2020 IEEE 18th World Symp. Appl. Mach. Intell. Informat. (SAMI), Herlany, Slovakia, Jan. 2020, pp. 201–206, https://doi.org/10.1109/SAMI48414.2020.9108757.
P. Le and W. Zuidema, “Quantifying the Vanishing Gradient and Long Distance Dependency Problem in Recursive Neural Networks and Recursive LSTMs,” in Proc. 1st Workshop Represent. Learn. NLP, Berlin, Germany, 2016, pp. 87–93, https://doi.org/10.18653/v1/W16-1610.
H. Okut, “Deep Learning for Subtyping and Prediction of Diseases: Long-Short Term Memory,” in Deep Learning Applications, P. L. Mazzeo and P. Spagnolo, Eds. London, U.K.: IntechOpen, 2021, https://doi.org/10.5772/intechopen.96180.
Q. U. Ain, S. U. Nisa, Aamana, M. Hilal, H. Kabeer, and F. Subhan, “Bidirectional LSTM for Context-Rich Abstractive Summarization: A Step Beyond Sequence-to-Sequence and Applied to Speech Impaired Transcriptions,” in 2025 IEEE 22nd Int. Conf. Smart Communities: Improving Quality of Life Using AI, Robotics and IoT (HONET), Topi, Pakistan, Dec. 2025, pp. 92–97, https://doi.org/10.1109/HONET67928.2025.11318471.
V. Hofmann, J. Pierrehumbert, and H. Schütze, “Dynamic Contextualized Word Embeddings,” in Proc. 59th Annu. Meeting Assoc. Comput. Linguistics and 11th Int. Joint Conf. Natural Language Processing (Vol. 1), Online, 2021, pp. 6970–6984, https://doi.org/10.18653/v1/2021.acl-long.542.
M. Apidianaki, “From Word Types to Tokens and Back: A Survey of Approaches to Word Meaning Representation and Interpretation,” Comput. Linguist., vol. 49, no. 2, pp. 1–59, Mar. 2023, https://doi.org/10.1162/coli_a_00474.
P. Tsvilodub, R. D. Hawkins, and M. Franke, “Integrating Neural and Symbolic Components in a Model of Pragmatic Question-Answering,” arXiv:2506.01474, 2025, https://doi.org/10.48550/ARXIV.2506.01474.
G. Neubig and C. Dyer, “Generalizing and Hybridizing Count-based and Neural Language Models,” in Proc. 2016 Conf. Empirical Methods Natural Language Process. (EMNLP), Austin, TX, USA, 2016, pp. 1163–1172, https://doi.org/10.18653/v1/D16-1124.
J. Björklund, A. Dahlgren Lindström, and F. Drewes, “Bridging Perception, Memory, and Inference through Semantic Relations,” in Proc. 2021 Conf. Empirical Methods Natural Language Process. (EMNLP), Online and Punta Cana, Dominican Republic, 2021, pp. 9136–9142, https://doi.org/10.18653/v1/2021.emnlp-main.719.
Supriyono, A. P. Wibawa, Suyono, and F. Kurniawan, “A survey of text summarization: Techniques, evaluation and challenges,” Nat. Lang. Process. J., vol. 7, Art. no. 100070, 2024, https://doi.org/10.1016/j.nlp.2024.100070.
P. Contreras Kallens and M. H. Christiansen, “Models of Language and Multiword Expressions,” Front. Artif. Intell., vol. 5, Art. no. 781962, 2022, https://doi.org/10.3389/frai.2022.781962.
A. Thielmann, C. Weisser, T. Kneib, and B. Säfken, "Coherence-Based Document Clustering," in 2023 IEEE 17th Int. Conf. Semantic Comput. (ICSC), Laguna Hills, CA, USA, Feb. 2023, pp. 9–16, https://doi.org/10.1109/ICSC56153.2023.00009.
J. Wood, B. Li, J. Lee, C. Arnold, and W. Wang, “On the Utility of Combining Topic Models and Recurrent Neural Networks,” in Recent Advances in Information and Communication Technology 2021, P. Meesad, S. Sodsee, W. Jitsakul, and S. Tangwannawit, Eds. Cham, Switzerland: Springer, 2021, pp. 66–76, https://doi.org/10.1007/978-3-030-79757-7_7.
L. George and P. Sumathy, “An integrated clustering and BERT framework for improved topic modeling,” Int. J. Inf. Technol., vol. 15, no. 4, pp. 2187–2195, Apr. 2023, https://doi.org/10.1007/s41870-023-01268-w.
Kris. (2018, Aug. 30). Nietzsche texts [Online]. Available: https://www.kaggle.com/datasets/pankrzysiu/nietzsche-texts
L. Larsen. (2024, Jan. 15). Shakespeare plays [Online]. Available: https://www.kaggle.com/datasets/kingburrito666/shakespeare-plays/data
V. Mettu. (2021, Jul. 12). WikiText-2 data [Online]. Available: https://www.kaggle.com/datasets/vivekmettu/wikitext2-data
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2026 Mustafa Abbas Hussein

This work is licensed under a Creative Commons Attribution 4.0 International License.










