Research Article

Prediction of RAG System Retrieval Strategy Selection Based on Multihead-Attention Optimization of LSTM Algorithm

Qi He*
Department of Industrial Engineering, Tsinghua University, Beijing, 100084, China.

* Corresponding author: [email protected]

Abstract

Against the backdrop of the increasing popularity of large language models in knowledge-intensive tasks, Retrieval Enhancement generation (RAG) technology has become a key technical path to break through model illusions and enhance the credibility of output. However, when dealing with the RAG retrieval strategy prediction task, existing machine learning algorithms generally have problems such as unbalanced feature weight configuration and insufficient capture of long sequence dependencies. To this end, this paper proposes an LSTM classification algorithm based on Multihead-Attention optimization. Firstly, data preprocessing is completed through correlation analysis and violin graph analysis, and then performance comparison experiments are conducted with multiple machine learning algorithms. The results show that the proposed Multihead-Attention-LSTM model performs the best in all evaluation indicators: The accuracy rate reached 0.853, the recall rate and precision rate were 0.853 and 0.854 respectively, the F1 value was 0.853, and the AUC value was 0.97. It comprehensively outperformed integrated models such as ExtraTrees and XGBoost, as well as traditional models like Random Forest, GBDT, and decision tree, and was significantly superior to Naive Bayes and KNN. This model, by leveraging the advantages of the multi-head attention mechanism and LSTM, demonstrates outstanding superiority in classification performance and generalization ability. It effectively verifies its applicability in the classification task of retrieval strategies and provides efficient and feasible algorithmic support for the intelligent optimization of retrieval strategies in the RAG system. It has significant practical value for enhancing the output reliability of large language models in knowledge-intensive tasks.

Keywords: RAG; Machine learning algorithm; RAG retrieval strategy; Multihead-Attention
Published: December 3, 2025
DOI: 10.54254/2755-2721/2026.30304
Volume: ACE Vol.189
pp. 48-55
Download PDF

References

  1. Salemi, Alireza, and Hamed Zamani. "Evaluating retrieval quality in retrieval-augmented generation." Proceedings of the 47th International ACM SIGIR Conference on Research and Development in Information Retrieval. 2024.
  2. Leng, Quinn, et al. "Long context rag performance of large language models."  arXiv preprint arXiv: 2411.03538  (2024).
  3. Shi, Yunxiao, et al. "Enhancing retrieval and managing retrieval: A four-module synergy for improved quality and efficiency in rag systems."  arXiv preprint arXiv: 2407.10670  (2024).
  4. Zhao, Shengming, et al. "Towards understanding retrieval accuracy and prompt quality in rag systems."  arXiv preprint arXiv: 2411.19463  (2024).
  5. Jin, Bowen, et al. "Long-context llms meet rag: Overcoming challenges for long inputs in rag."  arXiv preprint arXiv: 2410.05983  (2024).
  6. Mengmeng, Su, et al. "An Effective Retrieval Method to Improve RAG Performance." 2024 7th International Conference on Data Science and Information Technology (DSIT). IEEE, 2024.
  7. Tang, Yixuan, and Yi Yang. "Multihop-rag: Benchmarking retrieval-augmented generation for multi-hop queries."  arXiv preprint arXiv: 2401.15391  (2024).
  8. Jiang, Wenqi, et al. "Rago: Systematic performance optimization for retrieval-augmented generation serving." Proceedings of the 52nd Annual International Symposium on Computer Architecture. 2025.
  9. Oche, Agada Joseph, et al. "A systematic review of key retrieval-augmented generation (rag) systems: Progress, gaps, and future directions."  arXiv preprint arXiv: 2507.18910  (2025).
  10. Luo, Kun, et al. "Does RAG Really Perform Bad For Long-Context Processing?."  arXiv preprint arXiv: 2502.11444  (2025).