计算机科学 ›› 2026, Vol. 53 ›› Issue (11): 242-248.doi: 10.11896/jsjkx.251000112

• 人工智能 • 上一篇    下一篇

基于专家范例与动态少样本学习的查询改写

李伦兴1,2,5, 郭祥雨1,2, 付立军1,3,4   

  1. 1 中国科学院沈阳计算技术研究所 沈阳 110168
    2 中国科学院大学 北京 100049
    3 山东大学大数据与人工智能技术实验室 济南 250100
    4 中科智合数字科技(北京)有限公司 北京 102218
    5 沈阳中科数控技术股份有限公司 沈阳 110168
  • 收稿日期:2025-10-27 修回日期:2026-03-08 出版日期:2026-11-15 发布日期:2026-11-10
  • 通讯作者: 付立军(fu_lijun@ucas.ac.cn)
  • 作者简介:(lilunxing@sict.ac.cn)
  • 基金资助:
    国家体育总局科技创新项目(24KJCX042)

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 Published:2026-11-15 Online: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).

摘要: 查询改写是提升信息检索和自然语言理解系统性能的关键技术。针对现有查询改写方法在处理垂直领域中多样化、非规范化用户输入时面临的挑战,提出了一种基于专家范例与动态少样本的查询改写框架。该框架的核心思想是构建一个专家级改写范例库,在接收到用户查询时,动态检索与查询意图最相似的若干范例,并将其作为上下文提示注入大型语言模型(LLM),从而引导模型生成更精准、更贴合领域术语的查询。为进一步提升范例选择的针对性,引入基于元学习的范例重排序模块,根据范例对模型生成特定查询的贡献度进行加权,优化了提示的内部结构。为了验证该方法的有效性,额外实现两种基线方法作为对比:基于领域词表嵌入的同义词替换方法和将领域知识作为静态知识库与LLM结合的方法。在一个真实的计算机应用场景(运动心理知识服务)数据集上进行的对比实验表明,虽然所有方法均能提升查询质量,但所提动态少样本方法在处理复杂、模糊查询时表现最优,其生成的改写在BLEU-4和ROUGE-L指标上分别达到了0.78和0.81,并将下游任务的答案检索成功率提升至94.2%。实验验证了该方法在运动心理领域语义改写中的适用性与推广潜力,对优化搜索引擎、智能问答等应用具有重要的参考价值。

关键词: 查询改写, 动态提示工程, 大型语言模型, 领域知识, 少样本学习

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

中图分类号: 

  • 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.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!