Computer Science ›› 2026, Vol. 53 ›› Issue (11): 242-248.doi: 10.11896/jsjkx.251000112

• Artificial Intelligence • Previous Articles     Next Articles

Query Rewriting Based on Expert Examples and Dynamic Few-shot Learning

LI Lunxing1,2,5, GUO Xiangyu1,2, FU Lijun1,3,4   

  1. 1 Shenyang Institute of Computing Technology,Chinese Academy of Sciences,Shenyang 110168,China
    2 University of Chinese Academy of Sciences,Beijing 100049,China
    3 Laboratory of Big Data and Artificial Intelligence Technolgy,Shandong University,Jinan 250100,China
    4 Zhongke Zhihe Digital Technology(Beijing) Co.,Ltd.,Beijing 102218,China
    5 Shenyang Zhongke Numerical Control Technology Co.,Ltd.,Shenyang 110168,China
  • Received:2025-10-27 Revised:2026-03-08 Online:2026-11-15 Published:2026-11-10
  • About author:LI Lunxing,born in 1983,senior engineer.His main research interests include intelligent manufacturing technology,robotic automation integration technology,digital system integration technology,and intelligent integrated manufacturing systems and equipment,etc.
    FU Lijun,born in 1977,Ph.D,professor.His main research interests include data analysis,NLP and multimodal technologies.
  • Supported by:
    Science and Technology Innovation Project of the General Administration of Sport of China(24KJCX042).

Abstract: Query rewriting is a critical technology for enhancing the performance of information retrieval and natural language understanding systems.To address the challenges of handling diverse and non-standardized user inputs in vertical domains,this paper proposes a query rewriting framework leveraging expert demonstrations and dynamic few-shot learning.Specifically,it constructs a repository of expert-level rewriting demonstrations.For each user query,the framework dynamically retrieves examples with the highest intent similarity and injects them as contextual prompts into a large language model(LLM).This in-context learning paradigm guides the LLM to generate precise queries that strictly adhere to domain terminology.Furthermore,to refine example selection,it introduces a meta-learning-based re-ranking module that weights examples based on their contribution to the target generation,thereby optimizing the prompt structure.The proposed approach is validated against two baselines:a synonym replacement technique based on domain embeddings and a static knowledge base integration method.Comparative experiments on a real-world dataset from a sports psychology knowledge service demonstrate that the proposed dynamic few-shot approach achieves superior performance,particularly on complex and ambiguous queries.The generated rewrites achieve BLEU-4 and ROUGE-L scores of 0.78 and 0.81,respectively,boosting the downstream answer retrieval success rate to 94.2%.These results confirm the effectiveness of the proposed method in domain-specific semantic rewriting,providing valuable insights for optimizing search engines and intelligent question-answering systems.

Key words: Query rewriting, Dynamic prompt engineering, Large language models(LLMs), Domain knowledge, Few-shot learning

CLC Number: 

  • TP391
[1] CARPINETO C,ROMANO G.A survey of query reformula-tions:A framework for evaluation[J].ACM Computing Surveys,2012,44(1):1-50.
[2] WANG Z,CUN Y,YU D.Query2doc:A Simple and Effective Method for Query-to-Document Expansion[C]//Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing.Singapore:Association for Computational Linguistics,2023:10234-10246.
[3] DEVLIN J,CHANG M W,LEE K,et al.BERT:Pre-training of Deep Bidirectional Transformers for Language Understanding[C]//Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics:Human Language Technologies.Minneapolis,Minnesota:Association for Computational Linguistics,2019:4171-4186.
[4] ZHAO Y X,WANG Y,WANG S H,et al.RewriteGen:Autonomous query optimization for retrieval-augmented large language models via reinforcement learning[J].Journal of Nanjing University(Natural Science),2025,61(6):908-916.
[5] TU X H,GUO C,ZONG Y H.Information retrieval reranking method based on bidirectional text expansion[J].Journal of South China University of Technology(Natural Science Edition),2025,53(9):59-67.
[6] MIKOLOV T,CHEN K,CORRADO G,et al.Efficient Estimation of Word Representations in Vector Space[C]//Proceedings of the 1st International Conference on Learning Representations,Workshop Track.2013.
[7] PENNINGTON J,SOCHER R,MANNING C D.Glove:Global Vectors for Word Representation[C]//Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing(EMNLP).Doha,Qatar:Association for Computational Linguistics,2014:1532-1543.
[8] PANG X L,YUAN R F,HUANG J T,et al.Query rewriting technology based on an extractive-generative fusion model[J].Network Security Technology & Application,2023(9):44-46.
[9] LENG L X.Semantic rewriting techniques for general structural retrieval in large model retrieval[J].China Sciencepaper,2025,20(10):856-863.
[10] BROWN T,MANN B,RYDER N,et al.Language Models are Few-Shot Learners[C]//Advances in Neural Information Processing Systems 33.Vancouver,Canada:Curran Associates,Inc.,2020:1877-1901.
[11] LI A,TU X H,YAO B,et al.ChatGPT query rewriting for do-cument retrieval[J].Journal of Chinese Information Processing,2025,39(8):107-116,138.
[12] CHEN B,LI Y,ZHAO W,et al.Query Rewriting for Retrieval-Augmented Generation in Domain-Specific QA[C]//Findings of the Association for Computational Linguistics:ACL 2023.Toronto,Canada:Association for Computational Linguistics,2023:887-900.
[13] LEWIS P,PEREZ E,PIKTUS A,et al.Retrieval-AugmentedGeneration for Knowledge-Intensive NLP Tasks[C]//Advances in Neural Information Processing Systems 33.Vancouver,Canada:Curran Associates,Inc.,2020:9459-9474.
[14] ASAI A,KOMEILI M,HAJISHIRZI H.Selfrag:Learning toRetrieve,Generate,and Critique Through Self-Reflection[C]//Proceedings of the 12th International Conference on Learning Representations(ICLR).Vienna,Austria:OpenReview.net,2024.
[15] DENG P C,HEI Y H,WEI B S,et al.Query rewriting model based on knowledge graph construction and entity correction[J].Application Research of Computers,2025,42(9):2752-2757.
[16] LIU J,SHEN D,ZHANG Y,et al.What makes good in-context examples for GPT-3?[C]//Proceedings of the 60th Annual Meeting of the ACL.Dublin,Ireland:Association for Computational Linguistics,2022:4139-4146.
[17] SHE L L,XIONG L Y,LU X S.Research on knowledge concept extraction method based on few-shot learning and chain-of-thought prompting[J].Big Data Research,2026,12(2):97-110.
[18] MA L K,YUAN M T.Financial relation extraction based on large language model with few-shot demonstration[J].Software Guide,2026,25(7):103-110.
[19] LYU M H,YU L H,HU S W,et al.Prompt-based Two-stage few-shot named entity recognition[J].Computer and Modernization,2026(6):19-24.
[20] HE T,YUAN M,HE M.A fusion algorithm for few-shot relation extraction based on prompt enhancement[J].Journal of Yunnan University(Natural Sciences Edition),2025.
[21] RUBIN O,HERZIG J,BERANT J.Learning to Retrieve Promptsfor In-Context Learning[C]//Proceedings of the 2022 Confe-rence of the NAACL.Seattle,United States:Association for Computational Linguistics,2022:247-261.
[22] PAPINENI K,ROUKOS S,WARD T,et al.Bleu:A Method for Automatic Evaluation of Machine Translation[C]//Proceedings of the 40th Annual Meeting of the Association for Computational Linguistics.Philadelphia,Pennsylvania:Association for Computational Linguistics,2002:311-318.
[23] LIN C Y.Rouge:A package for automatic evaluation of summaries[C]//Proceedings of the Workshop on Text Summarization Branches Out.Barcelona,Spain:Association for Computational Linguistics,2004:74-81.
[24] BAI X,LIU Z,CHEN J,et al.BGE Embeddings:Baichuan General Embeddings for Chinese Semantic Representation[C]//Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing.Singapore:Association for Computational Linguistics,2023.
[25] JOHNSON J,DOUZE M,JÉGOU H.Billion-scale similaritysearch with GPUs[J].IEEE Transactions on Big Data,2021,7(3):535-547.
[1] ZHAO Jingyun, LIU Keying, GUO Wenke. FIN-GDAN:Sentiment Adversarial Transfer Network for Shanghai Gold Futures News [J]. Computer Science, 2026, 53(6A): 250700179-9.
[2] AN Yuexuan, ZHAO Xingyu. Model-agnostic Cross-domain Few-shot Learning Framework Based on Invariant Risk Minimization [J]. Computer Science, 2026, 53(6A): 250900009-8.
[3] XU Rui, LIU Jin, LIU Xudong, GUAN Jian, DONG Wei. Exploring the Generalization Ability of Prompt-based Large Language Models for TextClassification [J]. Computer Science, 2026, 53(6A): 250400092-7.
[4] LI Wenli, FENG Xiaonian, QIAN Tieyun. Few-shot Continuous Toxicity Detection Based on Large Language Model Augmentation [J]. Computer Science, 2026, 53(3): 321-330.
[5] CHEN Lin, MA Longxuan, ZHANG Yongbing, HUANG Yuxin, GAO Shengxiang, YU Zhengtao. Industrial Text Classification for Chinese and Vietnamese Based on Prompt Learning and AdaptiveLoss Weighting [J]. Computer Science, 2026, 53(2): 312-321.
[6] SHAO Xinyi, ZHU Jingwei, ZHANG Liang. LLM-based Business Process Adaptation Method to Respond Long-tailed Changes [J]. Computer Science, 2026, 53(1): 29-38.
[7] WANG Jia, XIA Ying, FENG Jiangfan. Few-shot Video Action Recognition Based on Two-stage Spatio-Temporal Alignment [J]. Computer Science, 2025, 52(8): 251-258.
[8] CHEN Yadang, GAO Yuxuan, LU Chuhan, CHE Xun. Saliency Mask Mixup for Few-shot Image Classification [J]. Computer Science, 2025, 52(6): 256-263.
[9] PAN Jie, WANG Juan, WANG Nan. Large Language Models and Rumors:A Survey on Generation and Detection [J]. Computer Science, 2025, 52(11): 1-12.
[10] FANG Quan, ZHANG Jinlong, WANG Bingqian, HU Jun. Research on Domain Knowledge Question Answering via Large Language Models withCompositional Context Prompting [J]. Computer Science, 2025, 52(11): 13-21.
[11] WANG Jiahui, PENG Guangling, DUAN Liang, YUAN Guowu, YUE Kun. Few-shot Shadow Removal Method for Text Recognition [J]. Computer Science, 2024, 51(9): 147-154.
[12] TANG Ruiqi, XIAO Ting, CHI Ziqiu, WANG Zhe. Few-shot Image Classification Based on Pseudo-label Dependence Enhancement and NoiseInterferenceReduction [J]. Computer Science, 2024, 51(8): 152-159.
[13] ZHANG Rui, WANG Ziqi, LI Yang, WANG Jiabao, CHEN Yao. Task-aware Few-shot SAR Image Classification Method Based on Multi-scale Attention Mechanism [J]. Computer Science, 2024, 51(8): 160-167.
[14] HE Zhilin, GU Tianhao, XU Guanhua. Few-shot Semi-supervised Semantic Image Translation Algorithm Based on Prototype Correction [J]. Computer Science, 2024, 51(8): 224-231.
[15] WANG Jinghong, TIAN Changshen, LI Haokang, WANG Wei. Lagrangian Dual-based Privacy Protection and Fairness Constrained Method for Few-shot Learning [J]. Computer Science, 2024, 51(7): 405-412.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!