Retrieval enhancement generation method and device, electronic equipment, medium and program product

Through the retrieval enhancement generation method of dynamic demand perception and multi-level query decomposition, the retrieval noise and computational overhead problems of the static RAG model are solved, efficient and accurate external knowledge integration is achieved, and the quality and efficiency of generated content are improved.

CN120670548APending Publication Date: 2025-09-19CHINA TELECOM CORP LTD TECHNOLOGY INNOVATION CENTER +1
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202510725404.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-30
Publication Date
2025-09-19

AI Technical Summary

Technical Problem

Existing static RAG models lack the ability to judge retrieval needs, resulting in unnecessary computational overhead and potential retrieval noise problems. In addition, the retrieval module is highly dependent on the quality and update of the knowledge base, which may cause generated content errors or semantic inconsistencies.

Method used

Through the retrieval-enhanced generation method of dynamic demand perception and multi-level query decomposition, it is possible to determine in real time whether external information is needed during the generation process, construct precise query statements based on the self-attention mechanism, and retrieve the decomposed sub-questions separately to ensure the coherence and accuracy of the generated content.

Benefits of technology

It effectively improves the coherence and practicality of the generated content, reduces the introduction of redundant information, significantly improves the generation effect, and reduces computing resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120670548A_ABST
    Figure CN120670548A_ABST
Patent Text Reader

Abstract

The invention provides a retrieval enhancement generation method and device, electronic equipment, a medium and a program product, and relates to the technical field of computers. The retrieval enhancement generation method comprises the following steps: inputting a user question into a language model, and carrying out word segmentation processing on the user question to obtain a plurality of word segmentation units; performing retrieval necessity evaluation on the plurality of word segmentation units based on knowledge demand indexes; determining that retrieval enhancement is needed based on an evaluation result, and constructing a query statement based on the attention scores of the plurality of word segmentation units; decomposing the query statement into a plurality of sub-questions so as to respectively perform retrieval enhancement on the plurality of sub-questions; and enabling the language model to output a first response result of the user question based on a retrieval enhancement result. According to the technical scheme, the retrieval necessity is dynamically evaluated on the basis of the knowledge demand indexes, so that the simple problem that external knowledge is not needed is filtered, blind retrieval of a static RAG model is prevented, and invalid calculation overhead is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a search enhancement generation method, a search enhancement generation device, an electronic device, a computer-readable storage medium, and a computer program product. Background Art

[0002] Retrieval-Augmented Generation (RAG) refers to the process of dynamically retrieving relevant information from an external knowledge base during natural language generation and using it as additional contextual input to generate a model to compensate for the model's own knowledge limitations. However, the current static RAG model lacks the ability to judge retrieval needs. It will perform retrieval regardless of whether the input requires external knowledge support, resulting in unnecessary computational overhead and potential retrieval noise problems.

[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute prior art known to ordinary technicians in the field. Summary of the Invention

[0004] The purpose of the present disclosure is to provide a retrieval enhancement generation method, configuration device, electronic device, storage medium and computer program product, which at least to some extent overcome the problem of unnecessary computational overhead and potential retrieval noise generated by static RAG models in related technologies.

[0005] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by practice of the present disclosure.

[0006] According to one aspect of the present disclosure, a retrieval enhancement generation method is provided, comprising: inputting a user question into a language model to perform word segmentation processing on the user question to obtain a plurality of word segmentation units; performing a retrieval necessity evaluation on the plurality of word segmentation units based on a knowledge requirement index; determining that retrieval enhancement is required based on the evaluation result, and constructing a query statement based on the attention scores of the plurality of word segmentation units; decomposing the query statement into a plurality of sub-questions to perform retrieval enhancement on the plurality of sub-questions respectively; and causing the language model to output a first answer result to the user question based on the result of the retrieval enhancement.

[0007] In one embodiment of the present disclosure, the knowledge requirement index includes the uncertainty and semantic contribution of the word segmentation unit, and the retrieval necessity evaluation of the multiple word segmentation units is performed based on the knowledge requirement index, including: for any of the word segmentation units, calculating the information entropy representing the uncertainty, and calculating the contribution value of the semantic contribution; determining the product of the information entropy and the contribution value as the evaluation result, wherein, if the evaluation result of any of the word segmentation units is greater than the evaluation threshold, it is determined that retrieval enhancement is required, and if the evaluation results of all the word segmentation units are less than or equal to the evaluation threshold, it is determined that retrieval enhancement is not required.

[0008] In one embodiment of the present disclosure, calculating the information entropy representing the uncertainty includes: calculating the information entropy based on the probability distribution of candidate words when generating the word segmentation unit.

[0009] In one embodiment of the present disclosure, calculating the contribution value of the semantic contribution includes: filtering out stop words in the multiple word segmentation units based on a preset stop word list to obtain multiple contribution word segmentation units; inputting the multiple contribution word segmentation units into a BERT model, so that the BERT model outputs a context embedding vector corresponding to each of the contribution word segmentation units; and calculating the semantic importance of the contribution word segmentation unit based on the context embedding vector as the contribution value of the semantic contribution.

[0010] In one embodiment of the present disclosure, the semantic importance of the contributing word segmentation unit is calculated based on the context embedding vector, including: performing a multi-layer perceptron transformation on the context embedding vector to obtain a transformation value; performing normalization compression on the transformation value, and determining the obtained probability value as the semantic importance.

[0011] In one embodiment of the present disclosure, a query statement is constructed based on the attention scores of the multiple word segmentation units, including: the language model includes multiple stacked Transformer layers, the Transformer layers are used to calculate the attention scores between the word segmentation units based on a self-attention mechanism, and the attention score of each word segmentation unit in the last Transformer layer relative to the previous word segmentation unit is extracted; and a query unit is selected from the multiple word segmentation units based on the attention scores to construct the query sequence based on the query units.

[0012] In one embodiment of the present disclosure, query units are selected from the multiple word segmentation units based on the attention scores to construct the query sequence based on the query units, including: sorting the attention scores in descending order to obtain a corresponding word segmentation unit sequence; selecting a specified number of the word segmentation units ranked at the top in the word segmentation unit sequence as the query units, wherein the ratio of the sum of the attention scores of the query units to the total attention scores is greater than a ratio threshold; searching for words corresponding to the query units from a model prediction vocabulary as query words; arranging the query words based on the word order in the user question to obtain a query sequence; and rewriting the query sequence based on the language model to obtain the query statement.

[0013] In one embodiment of the present disclosure, the query statement is decomposed into multiple sub-problems, including: identifying semantic elements in the query statement, the semantic elements including core query entities, attributes used to describe the core query entities, and relationships between the core query entities; mapping the semantic elements to preset multiple dimension labels; and converting the dimension labels into the multiple sub-problems based on the mapping results.

[0014] In one embodiment of the present disclosure, decomposing the query statement into a plurality of sub-questions includes decomposing the query statement into the plurality of sub-questions at multiple levels based on necessary knowledge, supplementary knowledge, and extended knowledge.

[0015] In one embodiment of the present disclosure, retrieval enhancement is performed on the multiple sub-questions respectively, including: searching each of the sub-questions in the knowledge base respectively to obtain retrieval results; and performing correlation detection on the multiple retrieval results and the user question to obtain retrieval-enhanced questions based on the detection results.

[0016] In one embodiment of the present disclosure, a plurality of the retrieval results are tested for relevance to the user question to obtain a retrieval-enhanced question based on the test result, including: organizing each of the retrieval results and the user question into a structured text pair; performing a relevance test on the text pair based on the language model to obtain a JSON result; parsing the JSON result to obtain a relevance evaluation result; removing irrelevant retrieval results based on a relevance threshold to obtain a retained result; and performing a coherence test on the retained results based on the language model to remove incoherent retained results to obtain the retrieval-enhanced question.

[0017] In one embodiment of the present disclosure, it further includes: determining that retrieval enhancement is not required based on the evaluation result, and directly outputting a second answer result of the user question by the language model.

[0018] According to another aspect of the present disclosure, a retrieval enhancement generation device is provided, including: a word segmentation processing module, which is used to input a user question into a language model to perform word segmentation processing on the user question to obtain multiple word segmentation units; an evaluation module, which is used to evaluate the retrieval necessity of the multiple word segmentation units based on a knowledge requirement index; a construction module, which is used to determine the need for retrieval enhancement based on the evaluation result, and construct a query statement based on the attention scores of the multiple word segmentation units; a retrieval enhancement module, which is used to decompose the query statement into multiple sub-questions to perform retrieval enhancement on the multiple sub-questions respectively; and an output module, which is used to enable the language model to output a first answer result of the user question based on the result of the retrieval enhancement.

[0019] According to another aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; the processor is configured to execute the retrieval enhancement generation method of the first aspect by executing the executable instructions.

[0020] According to another aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned search enhancement generation method is implemented.

[0021] According to another aspect of the present disclosure, a computer program product is provided, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned search enhancement generation method is implemented.

[0022] The retrieval enhancement generation solution provided by the embodiments of the present disclosure dynamically evaluates the necessity of retrieval based on knowledge demand indicators to filter out simple questions that do not require external knowledge, which is conducive to preventing blind retrieval of static RAG models and reducing invalid computing overhead. Furthermore, the attention mechanism is used to construct query statements, which can enable the query statements to focus on the core intentions of users, and combine the multi-dimensional sub-questions generated by decomposing the query statements to achieve fine-grained retrieval, which is conducive to improving the relevance of retrieval results to user questions, thereby reducing noise interference, and inputting questions including retrieval results into the large language model for answering, which can improve the completeness and accuracy of answers to complex questions, thereby achieving coordinated optimization of retrieval efficiency and generation quality.

[0023] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] The accompanying drawings are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification, are used to explain the principles of the present disclosure. Obviously, the drawings described below are only some embodiments of the present disclosure, and those skilled in the art can derive other drawings based on these drawings without inventive effort.

[0025] Figure 1 A schematic diagram of a search enhancement generation system according to an embodiment of the present disclosure is shown;

[0026] Figure 2 A flow chart of a search enhancement generation method according to an embodiment of the present disclosure is shown;

[0027] Figure 3 A schematic diagram of a search enhancement generation solution according to an embodiment of the present disclosure is shown;

[0028] Figure 4 A flow chart of another search enhancement generation method according to an embodiment of the present disclosure is shown;

[0029] Figure 5 A schematic diagram of a search enhancement generation device according to an embodiment of the present disclosure is shown;

[0030] Figure 6 A structural block diagram of a computer device in an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0031] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be embodied in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete and will fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

[0032] In addition, the accompanying drawings are merely schematic illustrations of the present disclosure and are not necessarily drawn to scale. Identical reference numerals in the figures denote identical or similar parts, and thus repetitive descriptions thereof will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities that do not necessarily correspond to physically or logically separate entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0033] Large models have been a major breakthrough in the field of artificial intelligence in recent years. Leveraging deep learning, they are widely used in natural language processing (NLP) tasks. These models are typically based on the Transformer architecture and learn language patterns and semantic knowledge from large pre-training corpora. They are characterized by large parameter sizes and extensive training data sets, such as classic models like GPT and LLAMA. LARGE MODELS, through autoregressive or autoencoding mechanisms, have demonstrated outstanding performance in tasks such as text generation, translation, question answering, and summarization, and possess strong transfer learning capabilities. Pretraining and fine-tuning are the core training strategies for large models. The pretraining phase uses unsupervised learning to acquire general language representations, while the fine-tuning phase optimizes specific objectives using a small amount of task data. The rapid development of large models has not only driven cutting-edge advances in artificial intelligence technology but also demonstrated broad application potential across various sectors of society.

[0034] The RAG (Retrieval-Augmented Generation) method effectively improves the performance of natural language generation tasks by combining the retrieval module with the generation module, especially when dealing with open-domain question-answering, knowledge-enhanced dialogue, and complex text generation tasks. Unlike traditional generation models, the RAG method dynamically retrieves relevant information from an external knowledge base during the generation process, and inputs the retrieved content into the generation model as additional context, thereby making up for the knowledge blind spots caused by the limited parameter scale or insufficient training corpus of the generation model. This mechanism enables the RAG method to not only generate more accurate and knowledge-rich content, but also maintain the real-time nature of the model knowledge with the support of a continuously expanding and updated knowledge base. However, the existing RAG method also has significant shortcomings. First, the static RAG model lacks the ability to judge retrieval needs. It will perform retrieval regardless of whether the input requires external knowledge support, which leads to unnecessary computational overhead and potential retrieval noise problems. Second, the retrieval module is highly dependent on the quality and updating of the knowledge base. If there are deviations or outdated information in the knowledge base, the generated content may be incorrect. In addition, semantic inconsistency may occur during the integration of the retrieval and generation modules. Especially when the retrieval results are not relevant enough or the context is too complex, the generated content may deviate from user needs or produce false inferences. Therefore, dynamic retrieval control is needed to further improve the model's adaptability to complex scenarios, thereby making the RAG method more efficient, reliable and intelligent.

[0035] In the present disclosure, a retrieval enhancement generation method based on dynamic demand perception and multi-level query decomposition is proposed. Through real-time retrieval demand detection, query statement construction and decomposition, efficient integration of external knowledge and improvement of generation quality are achieved. First, during the generation process, whether external information is needed in the generation process is judged by indicators such as uncertainty and semantic contribution. Secondly, high-weight tokens related to the context are extracted based on the self-attention mechanism to construct accurate query statements to ensure high relevance of the retrieval results. Finally, the query statement is decomposed, and the decomposed sub-questions are retrieved separately to ensure the coherence and accuracy of the generated content. The retrieval enhancement generation has the advantages of real-time dynamic judgment of information needs, accurate construction of query statements and efficient integration of external knowledge, which effectively improves the coherence and practicality of the generated content, while reducing the introduction of redundant information, making up for the shortcomings of the language model in knowledge coverage, and significantly improving the generation effect.

[0036] Figure 1 1 is a schematic diagram of a search enhancement generation system provided by an exemplary embodiment of the present application. The system includes: a plurality of user terminals 120 and a server terminal 140, wherein the user terminal 120 sends a user question and the server terminal 140 responds.

[0037] The user end 120 can be a mobile terminal such as a mobile phone, a game console, a tablet computer, an e-book reader, smart glasses, an MP4 (Moving Picture Experts Group Audio Layer IV) player, a smart home device, an AR (Augmented Reality) device, a VR (Virtual Reality) device, etc., or the user end 120 can also be a personal computer (PC), such as a laptop computer and a desktop computer.

[0038] The user terminal 120 may be installed with an application for providing search enhancement generation.

[0039] The client 120 and the server 140 are connected via a communication network. Optionally, the communication network is a wired network or a wireless network.

[0040] Server 140 is a server, or a combination of multiple servers, a virtualization platform, or a cloud computing service center. Server 140 provides backend services for applications that provide search-enhanced generation. Optionally, server 140 performs primary computing tasks, while client 120 performs secondary computing tasks. Alternatively, server 140 performs secondary computing tasks, while client 120 performs primary computing tasks. Alternatively, client 120 and server 140 utilize a distributed computing architecture for collaborative computing.

[0041] In some optional embodiments, the server 140 is configured to store and retrieve enhanced generation program information.

[0042] Optionally, the logistics client of the application installed on different user terminals 120 is the same, or the logistics client of the application installed on two user terminals 120 is the logistics client of the same type of application on different control system platforms. Based on the different terminal platforms, the specific form of the logistics client of the application can also vary. For example, the logistics client of the application can be a mobile phone logistics client, a PC logistics client, or a World Wide Web (Web) logistics client.

[0043] Those skilled in the art will appreciate that the number of the user terminals 120 may be greater or less. For example, there may be only one terminal, or there may be dozens, hundreds, or even more terminals. The embodiment of the present application does not limit the number and device type of the terminals.

[0044] Optionally, the system may further include a management device ( Figure 1 (not shown), the management device is connected to the server 140 via a communication network. Optionally, the communication network is a wired network or a wireless network.

[0045] Optionally, the above-mentioned wireless network or wired network uses standard communication technologies and / or protocols. The network is typically the Internet, but it can also be any network, including but not limited to a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN), a mobile, wired or wireless network, a private network or any combination of a virtual private network). In some embodiments, technologies and / or formats including Hypertext Markup Language (HTML), Extensible Markup Language (XML), etc. are used to represent data exchanged over the network. In addition, conventional encryption technologies such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Network (VPN), Internet Protocol Security (IPsec), etc. can be used to encrypt all or some links. In other embodiments, customized and / or dedicated data communication technologies can also be used to replace or supplement the above-mentioned data communication technologies.

[0046] Below, each step of the search enhancement generation method in this example implementation will be described in more detail with reference to the accompanying drawings and embodiments.

[0047] Figure 2 A flow chart of a search enhancement generation method in an embodiment of the present disclosure is shown.

[0048] like Figure 2 As shown, according to an embodiment of the present disclosure, a search enhancement generation method includes:

[0049] Step S202: Input the user question into the language model to perform word segmentation processing on the user question to obtain a plurality of word segmentation units.

[0050] In some embodiments, the word segmentation unit is a Token, which is the smallest discrete unit of the model input. Each Token corresponds to a unique index in the vocabulary and is used to convert natural language into a numerical sequence that can be calculated by the model.

[0051] In some embodiments, large language models (such as GPT, LLaMA, PaLM, etc.) are based on the Transformer architecture, and their input layer requires that the data must be a discrete symbol sequence (i.e., a token sequence) rather than a raw text string. Therefore, when a user question is input into the model, the model's built-in tokenizer will be automatically triggered for word segmentation processing.

[0052] Step S204: performing a search necessity evaluation on the plurality of word segmentation units based on the knowledge requirement index.

[0053] In some embodiments, the knowledge demand index is used to measure whether each information unit (such as token, phrase) in the user question needs to rely on external retrieval (such as knowledge base, database, real-time data) to supplement information. The knowledge demand index includes but is not limited to uncertainty, semantic contribution, timeliness, domain expertise, data sparsity, and clarity of user intent.

[0054] In some embodiments, a comprehensive indicator threshold may be set to trigger a search when the indicator value exceeds the threshold.

[0055] Step S206: Determine whether retrieval enhancement is required based on the evaluation result, and construct a query statement based on the attention scores of multiple word segmentation units.

[0056] In some embodiments, by capturing the importance weights and mutual correlations of semantic units in user questions, a search expression focusing on core information is generated.

[0057] Step S208: decompose the query statement into multiple sub-questions, and perform retrieval enhancement on each of the multiple sub-questions.

[0058] In some embodiments, the query statement can be broken down into multiple semantic units through dependency parsing (such as parsing the subject-verb-object relationship using spaCy).

[0059] In some embodiments, hint engineering can also be used to guide the large model to generate sub-questions.

[0060] In some embodiments, predefined question templates (such as "subject-behavior-consequence", "policy-impact-case", etc.) can be used for structured decomposition for specific fields to ensure that the sub-questions are aligned with the index structure of the domain knowledge base.

[0061] In some embodiments, when humans understand complex problems, they usually automatically break them down into multiple logical dimensions, including but not limited to data dimensions, model dimensions, and evaluation dimensions.

[0062] Step S210 : Based on the result of the retrieval enhancement, the language model is enabled to output a first answer result to the user's question.

[0063] In some embodiments, cross-attention is introduced in the Transformer layer so that the model can explicitly focus on key tokens in the retrieval results when processing user questions, and dynamically adjust the attention weight according to the credibility of the retrieval results (such as the authority of the source) to avoid the model from over-reliance on low-quality information.

[0064] In this embodiment, by dynamically evaluating the necessity of retrieval based on the knowledge demand index to filter out simple questions that do not require external knowledge, it is beneficial to prevent blind retrieval of the static RAG model. Since the retrieval timing and needs can be judged more accurately, unnecessary retrieval operations are reduced, thereby reducing the consumption of computing resources. Furthermore, the attention mechanism is used to construct query statements, which can make the query statements focus on the core intentions of the user, and combine the multi-dimensional sub-questions generated by decomposing the query statements to achieve fine-grained retrieval, which is beneficial to improve the relevance of the retrieval results to the user's questions, and thus can reduce noise interference. Inputting questions including retrieval results into the large language model for answering can improve the completeness and accuracy of the answers to complex questions, thereby achieving coordinated optimization of retrieval efficiency and generation quality.

[0065] By using tokens generated by a multi-dimensional evaluation model to determine the timing of retrieval, the query statements are carefully constructed and rewritten to obtain accurate knowledge. This method has significant effects in improving retrieval accuracy, the ability to handle complex problems, and generation quality and efficiency. It can be widely used in various natural language processing tasks and has good scalability.

[0066] In practical applications, for large-scale text generation tasks or scenarios that require rapid responses, such as real-time chatbots or online question-answering systems, this method can improve the system's operating efficiency while ensuring generation quality, and provide users with high-quality answers more quickly.

[0067] In one embodiment of the present disclosure, the knowledge requirement index includes the uncertainty and semantic contribution of the word segmentation unit, and a retrieval necessity evaluation is performed on multiple word segmentation units based on the knowledge requirement index, including: for any word segmentation unit, calculating the information entropy representing the uncertainty, and calculating the contribution value of the semantic contribution; determining the product of the information entropy and the contribution value as the evaluation result, wherein, if the evaluation result of any word segmentation unit is greater than the evaluation threshold, it is determined that retrieval enhancement is required, and if the evaluation results of all word segmentation units are less than or equal to the evaluation threshold, it is determined that retrieval enhancement is not required.

[0068] In some embodiments, for any word segmentation unit, information entropy is calculated based on its frequency of occurrence or predicted probability distribution in the language model, reflecting the model's cognitive uncertainty about the unit.

[0069] In some embodiments, the semantic contribution of a word segmentation unit to a user question may be measured by the TF-IDF weight or the weight value output by the attention mechanism.

[0070] In some embodiments, the information entropy is multiplied by the contribution value to obtain the evaluation result of the word segmentation unit, and the retrieval enhancement is triggered only when the evaluation result of at least one word segmentation unit exceeds a preset threshold.

[0071] In some embodiments, a two-factor decision-making mechanism is constructed by utilizing the uncertainty and semantic contribution of a token. When the product of the two exceeds a threshold, it indicates that the knowledge corresponding to the token is crucial to answering the question and the model's endogenous knowledge is insufficient. This triggers retrieval and accurately screens high-value knowledge gaps, such as professional terms and cross-domain concepts, to prevent invalid retrieval of low-contribution tokens (such as stop words) and achieve intelligent scheduling of retrieval resources.

[0072] In this embodiment, by calculating the uncertainty of the token, judging the semantic contribution and other operations, various characteristics of the token in the generation process are comprehensively considered. The uncertainty index can capture the degree of uncertainty of the model about the generated content, and the semantic contribution reflects the impact of the token on the context. It can focus on tokens with substantive meaning, and can more accurately determine whether retrieval is needed and the timing of the retrieval. By quantifying the "uncertainty" and "semantic contribution" of the word segmentation unit, a retrieval necessity evaluation mechanism is constructed, and the information entropy is used to capture the cognitive ambiguity of the model about the word segmentation unit. The core semantic unit of the contribution value positioning problem is combined, and the positioning of high-value uncertain information is achieved through the product operation of the two. As long as there is cognitive ambiguity in the core semantic unit, retrieval enhancement will be triggered. Otherwise, the answer will be generated directly based on the internal knowledge of the model, thereby converting the qualitative need for retrieval into a quantitative mathematical judgment, making the retrieval control more interpretable and adjustable, and realizing the coordinated optimization of the reasonable allocation of retrieval resources and the accuracy of the answer.

[0073] In one embodiment of the present disclosure, calculating information entropy representing uncertainty includes: calculating information entropy based on probability distribution of candidate words when generating word segmentation units.

[0074] In some embodiments, information entropy is calculated based on the probability distribution of candidate words when generating word segmentation units, which can be implemented based on formula (1).

[0075] U=-∑ v∈V p(v)logp(v) (1)

[0076] Where U represents information entropy, which is usually expressed in bits and measures the total uncertainty of a random variable. V refers to the model prediction vocabulary, v is a predefined symbol in the vocabulary, and token is a specific v selected from V when the model is generated. p(v) represents the probability of generating a word v in the vocabulary V. ∑ v∈V p(v)logp(v) refers to the summation of all values ​​in the set V.

[0077] In this embodiment, the higher the U value, the stronger the model's cognitive uncertainty about the word, and the more it needs to use external knowledge to disambiguate. The information entropy is calculated based on the probability distribution of candidate words when generating word segmentation units to quantify the uncertainty of the word segmentation units, providing a basis for retrieval necessity evaluation, improving the intelligence and accuracy of retrieval decisions, and reducing invalid retrieval overhead.

[0078] In one embodiment of the present disclosure, calculating the contribution value of the semantic contribution includes:

[0079] Stop words in multiple word segmentation units are filtered out based on a preset stop word list to obtain multiple contribution word segmentation units.

[0080] In some embodiments, a binary semantic index is used to filter out tokens with important semantic value and remove the interference of stop words.

[0081] Multiple contribution segmentation units are input into the BERT model, so that the BERT model outputs the context embedding vector corresponding to each contribution segmentation unit.

[0082] Among them, BERT (Bidirectional Encoder Representations from Transformers) refers to the bidirectional encoder representation from Transformer.

[0083] The semantic importance of the contributing word unit is calculated based on the context embedding vector as the contribution value of the semantic contribution.

[0084] In one embodiment of the present disclosure, the semantic importance of the contributing word segmentation unit is calculated based on the context embedding vector, including: performing a multi-layer perceptron transformation on the context embedding vector to obtain a transformation value; performing normalization compression on the transformation value, and determining the obtained probability value as the semantic importance.

[0085] In some embodiments, for the i-th token t , if t belongs to the stop word set, then S i =0.

[0086] In some embodiments, if t does not belong to the stop word set, the context importance score is calculated in combination with the BERT model, and the i-th tokent Perform lemmatization to obtain word t i , generate word t through the BERT model i The context embedding vector h i , the vector includes the semantic information of the word in the specific context, and uses the multi-layer perceptron (MLP) to i Perform nonlinear mapping to capture complex semantic features.

[0087] Furthermore, the MLP output is compressed to the (0, 1) interval based on the Sigmoid function, so that S i Can be interpreted as word t i The probability of belonging to the key semantic word, that is, the contribution value of semantic contribution, S i As shown in formula (2).

[0088] S i =σ(MLP(h i )) (2)

[0089] S i This ensures that when judging the necessity of retrieval, the main considerations are those words that make substantial contributions to semantics, preventing the influence of stop words on the judgment.

[0090] In this embodiment, stop words without actual semantics are eliminated based on a preset stop word list, and contributing word segmentation units that play a key role in constructing the semantics of the question are screened out to narrow the scope of semantic analysis. The contributing word segmentation units are input into the BERT model, and its bidirectional Transformer architecture is used to generate a dynamic embedding vector containing contextual information to overcome the defect that traditional static word vectors cannot capture ambiguity. The contribution value is calculated by analyzing the semantic relevance of the embedding vector, and the core degree of the vocabulary in the question is quantified, which is conducive to improving the evaluation accuracy of the retrieval necessity evaluation.

[0091] In some embodiments, the uncertainty and semantic contribution are calculated, and a comprehensive score of each token is calculated, as shown in formula (3). When the score of any token exceeds a predefined threshold, it is considered that the model requires external knowledge when generating the token, thereby activating the retrieval module.

[0092] S=U i *S i (3)

[0093] In one embodiment of the present disclosure, a query statement is constructed based on the attention scores of multiple word segmentation units, including:

[0094] The language model includes multiple stacked Transformer layers. The Transformer layer is used to calculate the attention scores between word segmentation units based on the self-attention mechanism, and extract the attention score of each word segmentation unit in the last Transformer layer relative to the previous word segmentation unit; based on the attention score, a query unit is selected from multiple word segmentation units to construct a query sequence based on the query unit.

[0095] Among them, those skilled in the art can understand that BERT is composed of multiple stacked Transformer encoder layers, each layer contains a self-attention mechanism and a feedforward neural network, which is used to extract the deep semantic representation of the input text. The language model, that is, the large language model (LLM), undertakes the core reasoning and retrieval enhancement tasks. The Transformer layer of the large language model can identify the most valuable keywords for retrieval through a multi-layer attention mechanism. In other words, the Transformer layer of BERT focuses on semantic understanding (through context embedding vectors) and evaluates the contribution of each word segmentation unit to the overall semantics. The Transformer layer of the language model focuses on retrieval optimization (through attention scores), identifies the most valuable query keywords, and improves retrieval accuracy.

[0096] In some embodiments, the Transformer model calculates the association strength between word segmentation units (Tokens) through a self-attention mechanism. For each Token in the input sequence, the attention mechanism generates an attention score (Attention Score) for other Tokens, reflecting the semantic dependency between Tokens. The output of the last Transformer layer integrates semantic information from all levels, and its attention score can better reflect the importance of the word segmentation unit in the overall context.

[0097] In some embodiments, assuming the token sequence: [quantum, computing, how, change, cryptography], the attention matrix A[i, j] represents the attention weight of token_i to token_j (i>j), for example: A[4, 0] = 0.7 (that is, the attention of cryptography to quantum).

[0098] In some embodiments, a query unit is selected from the multiple word segmentation units based on the attention score, that is, a highly associated word segmentation unit is selected from the last layer of attention scores as the query unit.

[0099] In this embodiment, through hierarchical attention analysis and dynamic query construction, the stacking structure of the Transformer layer is first used to gradually abstract semantic associations from the bottom layer to the top layer, so that the attention score of the last layer can comprehensively reflect the global semantic relationship. Then, based on the score, the query unit is dynamically selected, and low-association stop words and redundant modifications are automatically excluded. The core semantic units are retained to construct a query sequence focused on the user's intention. The query unit comes directly from the semantic association learned by the model, which improves the semantic fit between the search keywords and the user's questions, thereby improving the accuracy of the retrieval. In addition, the self-attention mechanism automatically captures contextual dependencies, so that the constructed query sequence can dynamically adapt to the context, thereby enhancing the adaptability of the context. For multi-step reasoning or complex problems that require cross-context understanding, such as when processing multi-hop question-answering tasks, the model can obtain external knowledge in a timely manner at key nodes to fill knowledge gaps and avoid erroneous or incomplete answers due to knowledge limitations.

[0100] In one embodiment of the present disclosure, selecting a query unit from a plurality of word segmentation units based on an attention score to construct a query sequence based on the query unit includes:

[0101] The attention scores are sorted in descending order to obtain a corresponding word segmentation unit sequence; a specified number of word segmentation units ranked at the top of the word segmentation unit sequence are selected as query units, wherein the ratio of the sum of the attention scores of the query units to the total attention scores is greater than a ratio threshold; the vocabulary corresponding to the query unit is searched from the model prediction vocabulary table as the query vocabulary; the query vocabulary is arranged based on the word order in the user question to obtain a query sequence; the query sequence is rewritten based on the language model to obtain a query statement.

[0102] In some embodiments, after the tokens are sorted by attention scores, the top tokens correspond to the semantic units that the language model pays most attention to when responding. By setting a ratio threshold, the number of tokens to be retained can be automatically determined to balance information integrity and redundancy.

[0103] In some embodiments, the filtered tokens are reorganized according to their appearance positions in the original question to retain the semantic structure. Furthermore, a large language model is used to convert discrete token sequences into grammatically smooth queries to improve the retrieval module's understanding ability.

[0104] In some embodiments, the attention scores are sorted in descending order, the top n tokens with the highest attention scores are selected, and the sum of the attention scores of the top n tokens is ensured to exceed 70% (i.e., the ratio threshold) of the sum of the attention scores of all tokens, so that the query statement retains necessary information. Finally, the words corresponding to these tokens are found from the vocabulary and arranged in the order they appear in the original text. These word sequences are then rewritten using a large language model to construct a semantically coherent query statement, which can accurately reflect the language model's demand for external knowledge when generating tokens.

[0105] In some embodiments, query statements are constructed and rewritten based on the Transformer attention score, filtering core tokens (such as retaining semantic key units through Top-K and thresholds), reorganizing them in the original word order, and rewriting them into natural queries through a language model to ensure that the query focuses on the essence of the problem and improves the accuracy of retrieval in capturing core knowledge.

[0106] In this embodiment, the semantic importance of tokens is quantified based on the Transformer's self-attention score, and core semantic units are screened out through descending sorting and dynamic thresholds to ensure information integrity (through proportional threshold constraints) and reduce redundancy. The queries are then reorganized according to the original question word order and polished by the language model to generate natural language queries that meet the requirements of the retrieval system. The query units are directly derived from the semantic analysis within the model, which can improve the fit between the search keywords and the user's intentions. In addition, selecting a specified number of word segmentation units at the top of the word segmentation unit sequence can also reduce the number of query terms and reduce the load on the retrieval module.

[0107] In one embodiment of the present disclosure, a query statement is decomposed into multiple sub-problems, including: identifying semantic elements in the query statement, where the semantic elements include core query entities, attributes used to describe the core query entities, and relationships between the core query entities; mapping the semantic elements to multiple preset dimension labels; and converting the dimension labels into multiple sub-problems based on the mapping results.

[0108] In some embodiments, core query entities refer to the main objects or subjects involved in the query, attributes describe the characteristics, states or qualifications of core query entities, and relationships refer to associations or actions between core query entities.

[0109] In some embodiments, the preset multiple dimension labels include time, cause and effect, comparison (differences, advantages, disadvantages), definition (concept explanation, principle), application (technology application, scenario implementation), challenges (problems, risks, limitations) and trends (future development, prospects), etc. The core entities, attributes, and relationships are combined into short texts, and the BERT-Query decomposer model is used to classify the short texts, output dimension labels, match templates for each dimension label, fill in the core entities, attributes, and relationships, and output a list of multi-dimensional sub-problems.

[0110] In one embodiment of the present disclosure, decomposing a query statement into a plurality of sub-questions includes decomposing the query statement into a plurality of sub-questions at multiple levels based on necessary knowledge, supplementary knowledge, and extended knowledge.

[0111] In some embodiments, the first level search corresponds to core concept definitions, the second level search corresponds to technical details, and the third level search corresponds to marginal information.

[0112] In some embodiments, hierarchical processing can also be performed based on the data source, with the second level corresponding to authoritative knowledge bases (academic papers, industry standards), the second level corresponding to semi-structured data (reports, blogs), and the third level corresponding to real-time data (news, social media).

[0113] In addition, it can also be based on the generation of a large language model, that is, based on the dimension, prompt words are used to guide the large model to decompose into multiple sub-problems.

[0114] In one embodiment of the present disclosure, performing retrieval enhancement on each of the multiple sub-questions includes:

[0115] Search each sub-question in the knowledge base separately to obtain the search results.

[0116] In some embodiments, the constructed query statement is rewritten and decomposed into multiple related sub-questions. A query is performed in the knowledge base for each sub-question. Based on the dimensional characteristics of each sub-question, matching resources in the knowledge base (such as technical documents, case libraries, trend reports) are searched in a targeted manner to prevent the generalization of results caused by semantic ambiguity in a single search, so as to further optimize the search effect.

[0117] A correlation test is performed between multiple retrieval results and user questions to obtain retrieval-enhanced questions based on the test results.

[0118] In some embodiments, through semantic similarity calculation (such as vector matching, keyword co-occurrence, etc.), the relevance of the retrieval results of each sub-question to the original question is evaluated, and redundant or irrelevant information is filtered out to ensure that the final integrated knowledge fully matches the user's core needs.

[0119] In this embodiment, the query statement is broken down into sub-questions according to logical dimensions, so that the retrieval results of a single sub-question have a high degree of relevance. A dedicated knowledge base can be called according to the characteristics of each sub-question to improve the retrieval efficiency. Through global relevance detection, duplicate or low-relevance results are eliminated, so that the amount of effective information contained in the final retrieval-enhanced question is increased, and the noise rate is reduced. It can be applied to complex problems in professional fields, thereby enhancing the retrieval module's ability to analyze deep user needs and the reliability of knowledge supply.

[0120] In one embodiment of the present disclosure, a plurality of search results are tested for relevance to a user question, and based on the test results, a search-enhanced question is obtained, including:

[0121] Each search result and user question is organized into a structured text pair; the text pair is tested for relevance based on the language model to obtain a JSON result; the JSON result is parsed to obtain a relevance evaluation result; irrelevant search results are removed based on the relevance threshold to obtain a retained result; the retained results are tested for coherence based on the language model to remove incoherent retained results and obtain a search-enhanced question.

[0122] In some embodiments, the JSON result is a structured evaluation output of the language model on the relevance of the retrieval results to the user question.

[0123] In some embodiments, search results from different sources (such as text, data, links) are converted into a unified format to facilitate subsequent processing. Furthermore, semantic similarity calculations (such as text fragment comparisons) can be used to identify duplicate information, merge identical or highly similar content (such as different expressions of the same study), and prioritize the results by source credibility, timeliness (latest first), and matching degree (relevance to the query).

[0124] In some embodiments, user questions and all search results can also be input into the large language model, so that the model can judge the relevance from dimensions such as semantic matching, entity association, and topic consistency, and require the model to grade the relevance of each result to the question.

[0125] In some embodiments, the retained results are checked for coherence based on a language model. First, a semantic association analysis is performed between the user question and each retained search result. Then, the model evaluates the semantic fluency within the search results and between the search results and the questions. For example, by calculating the cosine similarity of the text embedding vector, the results are checked for semantic breaks or logical contradictions. Finally, a coherence threshold is set (such as a similarity score, a logical consistency score), and incoherent results below the threshold are eliminated. The remaining results are integrated according to semantic relevance and logical order to form search enhancement information that covers the core of the question and has coherent content, providing high-quality knowledge input for the subsequent large model to generate accurate answers.

[0126] In this embodiment, by introducing a retrieval enhancement generation framework based on dynamic demand perception and multi-level query decomposition, the problems of knowledge blind spots, inaccurate generated content and context incoherence in the generation process of large language models are solved. By dynamically detecting the retrieval requirements in the generation process, external knowledge is accurately introduced to ensure that the language model can generate more accurate, coherent and logical content in the absence of knowledge. When facing complex tasks or information-deficient scenarios, the model can realize real-time supplementation and efficient integration of external information, preventing redundancy, inefficiency and information mismatch caused by static retrieval, thereby significantly improving the quality and practicality of the generated content. In addition, the solution disclosed in this invention enables the large language model to have stronger context understanding and information scheduling capabilities, ensuring that the output results reach a high level in accuracy, coherence and knowledge coverage, and meet the diverse needs in practical applications.

[0127] In one embodiment of the present disclosure, it is further included that: based on the evaluation result, it is determined that retrieval enhancement is not required, and the second answer result of the user question is directly output by the language model.

[0128] In this embodiment, whether to trigger the retrieval process is dynamically determined by the evaluation results. When it is determined that no retrieval enhancement is required, the second response result is directly generated by the language model based on internal knowledge, thereby realizing intelligent scheduling of retrieval resources and optimization of answer efficiency.

[0129] like Figure 3 As shown in Figure 2, the token calculation uncertainty of the word segmenter output.

[0130] The token output by the word segmenter is input into the BERT encoder to generate a context embedding vector for calculating semantic contribution.

[0131] The embedding vector output by BERT is transformed by MLP to obtain the semantic importance probability value, which is used to participate in the retrieval necessity evaluation.

[0132] If retrieval is required based on the evaluation results, enter the retrieval enhancement path.

[0133] All tokens output by the retrieval-enhanced path tokenizer are input into the Transformer encoder, and attention scores are calculated through multi-layer self-attention, core query units are filtered, and query statements are constructed.

[0134] After the constructed query statement is decomposed into sub-questions and retrieved, the BERT classifier detects the relevance of the retrieval results and the text pairs of the user questions. The filtered results are input into the Transformer decoder to generate the first response result.

[0135] If no retrieval is required, the Transformer encoder and Transformer decoder are directly called to generate the second response result.

[0136] Among them, those skilled in the art will understand that the retrieval enhancement path and the non-retrieval enhancement path can share the Transformer encoder and Transformer decoder.

[0137] like Figure 4 As shown, according to another embodiment of the present disclosure, a search enhancement generation method includes:

[0138] Step S402: Obtain the question input by the user into the language model.

[0139] Step S404: Determine whether the question needs to be retrieved based on the uncertainty of the token generated by the language model. If yes, proceed to step S406; if no, proceed to step S412.

[0140] Step S406: Construct a query statement based on the attention score in the token.

[0141] Step S408: decompose the query statement into multiple sub-questions, search them separately, and then merge the search results.

[0142] Step S410 : continue to perform reasoning on the language model based on the search results.

[0143] In step S412, the retrieval information is not introduced, and the language model continues to perform reasoning based on the token.

[0144] Step S414: Obtain the output result of the model.

[0145] In this embodiment, when judging the necessity of retrieval, the uncertainty and semantic contribution of the token are calculated to determine whether to retrieve, thereby accurately grasping the retrieval timing. When constructing a query statement, the token attention weight is evaluated to select relevant tokens for construction, and then it is decomposed to capture the model knowledge requirements from multiple aspects. When dealing with complex problems, it can dynamically retrieve and integrate knowledge for reasoning, such as timely obtaining key knowledge in multi-hop question-answering tasks, integrating multi-source knowledge to generate in-depth answers in cross-domain problems, reducing irrelevant information interference through precise retrieval, optimizing computing resource allocation, and being applicable to a variety of task scenarios with strong scalability.

[0146] It should be noted that the above figures are merely illustrative of the processes included in the methods according to exemplary embodiments of the present disclosure and are not intended to be limiting. It is readily understood that the processes illustrated in the above figures do not indicate or limit the temporal order of these processes. Furthermore, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.

[0147] Refer to the following Figure 5 The retrieval enhancement generating device 500 according to an embodiment of the present disclosure is described. Figure 5 The search enhancement generation device 500 shown is merely an example and should not limit the functions and scope of use of the embodiments of the present disclosure.

[0148] The search enhancement generation device 500 is implemented as a hardware module. The components of the search enhancement generation device 500 may include, but are not limited to: a word segmentation processing module 502 for inputting a user question into a language model to perform word segmentation processing on the user question and obtain multiple word segmentation units; an evaluation module 504 for evaluating the retrieval necessity of the multiple word segmentation units based on a knowledge requirement indicator; a construction module 506 for determining the need for search enhancement based on the evaluation results and constructing a query statement based on the attention scores of the multiple word segmentation units; a search enhancement module 508 for decomposing the query statement into multiple sub-questions and performing search enhancement on each of the multiple sub-questions; and an output module 510 for causing the language model to output a first response to the user question based on the search enhancement results.

[0149] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods, or program products. Therefore, various aspects of the present disclosure may be implemented in the following forms: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, which may be collectively referred to herein as "circuits," "modules," or "systems."

[0150] Refer to the following Figure 6 hereinafter, an electronic device 600 according to this embodiment of the present disclosure is described. Figure 6 The electronic device 600 shown is merely an example and should not limit the functionality and scope of use of the embodiments of the present disclosure.

[0151] like Figure 6 As shown, electronic device 600 is implemented as a general-purpose computing device. Components of electronic device 600 may include, but are not limited to, the aforementioned at least one processing unit 610, the aforementioned at least one storage unit 620, and a bus 630 connecting different system components (including storage unit 620 and processing unit 610).

[0152] The storage unit stores program codes, which can be executed by the processing unit 610, so that the processing unit 610 performs the steps described in the "Exemplary Method" section of the present disclosure according to various exemplary embodiments. For example, the processing unit 610 can perform the following steps: Figure 2 The described scheme.

[0153] The storage unit 620 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 6201 and / or a cache memory unit 6202 , and may further include a read-only memory unit (ROM) 6203 .

[0154] The storage unit 620 may also include a program / utility 6204 having a set (at least one) of program modules 6205, such program modules 6205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0155] Bus 630 may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.

[0156] The electronic device 600 can also communicate with one or more external devices 670 (e.g., a keyboard, a pointing device, a Bluetooth device, etc.), one or more devices that enable a user to interact with the electronic device 600, and / or any device that enables the electronic device 600 to communicate with one or more other computing devices (e.g., a router, a modem, etc.). Such communication can occur via an input / output (I / O) interface 650. Furthermore, the electronic device 600 can communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network such as the Internet) via a network adapter 660. As shown, the network adapter 660 communicates with other modules of the electronic device 600 via a bus 630. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the electronic device 600, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0157] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.

[0158] In exemplary embodiments of the present disclosure, a computer-readable storage medium is also provided, on which is stored a program product capable of implementing the aforementioned methods of this specification. In some possible implementations, various aspects of the present disclosure may also be implemented in the form of a program product comprising program code. When the program product is executed on an electronic device, the program code is configured to cause the electronic device to execute the steps described in the aforementioned "Exemplary Methods" section of this specification according to various exemplary embodiments of the present disclosure.

[0159] According to an embodiment of the present disclosure, a program product for implementing the above-mentioned method can be a portable compact disc read-only memory (CD-ROM) and include program code, and can be run on an electronic device, such as a personal computer. However, the program product of the present disclosure is not limited thereto. In this document, a readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0160] The program product may be implemented in any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.

[0161] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium that can transmit, propagate, or transfer a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0162] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0163] The program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, and the like, as well as conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a stand-alone software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0164] It should be noted that although several modules or units of the device for action execution are mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be concretized in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units to be concretized.

[0165] Furthermore, although the steps of the method of the present disclosure are described in a particular order in the accompanying drawings, this does not require or imply that the steps must be performed in this particular order, or that all steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.

[0166] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.

[0167] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the appended claims.

Claims

1. A search enhancement generation method, characterized in that: include: Inputting the user question into the language model to perform word segmentation processing on the user question to obtain multiple word segmentation units; Performing a retrieval necessity evaluation on the plurality of word segmentation units based on the knowledge requirement index; Determining that retrieval enhancement is required based on the evaluation result, and constructing a query statement based on the attention scores of the multiple word segmentation units; Decomposing the query statement into multiple sub-questions, and performing retrieval enhancement on each of the multiple sub-questions; The language model is enabled to output a first answer result to the user question based on the result of the retrieval enhancement.

2. The search enhancement generation method according to claim 1, characterized in that The knowledge requirement index includes the uncertainty and semantic contribution of the word segmentation unit, and performing a search necessity evaluation on the multiple word segmentation units based on the knowledge requirement index includes: For any of the word segmentation units, calculating the information entropy representing the uncertainty, and calculating the contribution value of the semantic contribution; The product of the information entropy and the contribution value is determined as the evaluation result, wherein, if the evaluation result of any of the word segmentation units is greater than the evaluation threshold, it is determined that retrieval enhancement is required; if the evaluation results of all the word segmentation units are less than or equal to the evaluation threshold, it is determined that retrieval enhancement is not required.

3. The search enhancement generation method according to claim 2, characterized in that: Calculating information entropy representing the uncertainty includes: The information entropy is calculated based on the probability distribution of candidate words when the word segmentation unit is generated.

4. The search enhancement generation method according to claim 2, characterized in that: Calculating the contribution value of the semantic contribution includes: Filtering out stop words in the plurality of word segmentation units based on a preset stop word list to obtain a plurality of contribution word segmentation units; Input the multiple contribution segmentation units into a BERT model, so that the BERT model outputs a context embedding vector corresponding to each contribution segmentation unit; The semantic importance of the contribution word segmentation unit is calculated based on the context embedding vector to serve as the contribution value of the semantic contribution.

5. The search enhancement generation method according to claim 4, characterized in that: Calculating the semantic importance of the contributing word segmentation unit based on the context embedding vector includes: Performing a multi-layer perceptron transformation on the context embedding vector to obtain a transformation value; Normalization compression is performed on the transformed value, and the obtained probability value is determined as the semantic importance.

6. The search enhancement generation method according to claim 1, characterized in that: Constructing a query statement based on the attention scores of the multiple word segmentation units, including: The language model includes a plurality of stacked Transformer layers, each of which is used to calculate the attention scores between the word segmentation units based on a self-attention mechanism, and extract the attention score of each word segmentation unit in the last Transformer layer relative to the previous word segmentation unit; A query unit is selected from the plurality of word segmentation units based on the attention scores to construct the query sequence based on the query unit.

7. The search enhancement generation method according to claim 6, characterized in that: Selecting a query unit from the plurality of word segmentation units based on the attention score to construct the query sequence based on the query unit includes: Sort the attention scores in descending order to obtain a corresponding word segmentation unit sequence; Selecting a specified number of the word segmentation units that are ranked first in the word segmentation unit sequence as the query units, wherein a ratio between the sum of the attention scores of the query units and the total attention scores is greater than a ratio threshold; Searching for a word corresponding to the query unit from a model prediction vocabulary table as a query word; Arranging the query words based on the word order in the user question to obtain a query sequence; The query sequence is rewritten based on the language model to obtain the query statement.

8. The search enhancement generation method according to claim 1, characterized in that: Decompose the query into multiple sub-questions, including: Identifying semantic elements in the query statement, wherein the semantic elements include core query entities, attributes used to describe the core query entities, and relationships between the core query entities; Mapping the semantic elements to a plurality of preset dimensional labels; Based on the mapping result, the dimension labels are converted into the multiple sub-questions.

9. The search enhancement generation method according to claim 1, characterized in that: Decompose the query into multiple sub-questions, including: The query statement is decomposed into the plurality of sub-questions at multiple levels based on necessary knowledge, supplementary knowledge and extended knowledge.

10. The search enhancement generation method according to claim 1, characterized in that: Performing retrieval enhancement on the multiple sub-questions respectively includes: Search each of the sub-questions in the knowledge base to obtain search results; A correlation test is performed between the plurality of search results and the user question, so as to obtain a search-enhanced question based on the test result.

11. The search enhancement generation method according to claim 10, characterized in that: Performing relevance detection on the plurality of search results and the user question to obtain a search-enhanced question based on the detection result, including: Arranging each of the search results and the user question into a structured text pair; Perform relevance detection on the text pairs based on the language model to obtain a JSON result; Parse the JSON result to obtain a correlation evaluation result; Removing irrelevant search results based on a relevance threshold to obtain retained results; The retained results are subjected to a consistency check based on the language model to remove incoherent retained results, thereby obtaining the retrieval enhancement question.

12. The search enhancement generation method according to claim 1, characterized in that: Also includes: Based on the evaluation result, it is determined that retrieval enhancement is not required, and the language model directly outputs a second answer result for the user question.

13. A search enhancement generation device, characterized in that: include: A word segmentation processing module is used to input the user question into the language model to perform word segmentation processing on the user question to obtain multiple word segmentation units; An evaluation module, configured to evaluate the retrieval necessity of the plurality of word segmentation units based on a knowledge requirement index; A construction module, configured to determine that retrieval enhancement is required based on the evaluation result, and to construct a query statement based on the attention scores of the plurality of word segmentation units; A retrieval enhancement module, configured to decompose the query statement into multiple sub-questions, and perform retrieval enhancement on each of the multiple sub-questions; An output module is used to enable the language model to output a first answer result of the user question based on the result of the retrieval enhancement.

14. An electronic device, characterized in that: include: processor; as well as a memory for storing executable instructions of the processor; The processor is configured to execute the search enhancement generation method according to any one of claims 1 to 12 by executing the executable instructions.

15. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the search enhancement generation method according to any one of claims 1 to 12 is implemented.

16. A computer program product having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the search enhancement generation method according to any one of claims 1 to 12 is implemented.

Citation Information

Cited By

  • Bilingual question and answer method based on knowledge retrieval and generation cooperative training

    CN121919329A

  • A bilingual question-answering method based on collaborative training of knowledge retrieval and generation

    CN121919329B

  • Instruction processing method and apparatus, vehicle, and storage medium

    CN122451130A