A summary word-based dense sparse retrieval fusion method and device

CN120336506BActive Publication Date: 2026-08-07BEIJING DP TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING DP TECH CO LTD
Filing Date
2025-04-16
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

这两类检索方法各有优缺点,且目前尚没有一种比较通用的技术方案能对二者进行互补融合

Benefits of technology

[0062]本发明实施例提供了一种基于概要词的稠密稀疏检索融合方法、装置、电子设备及计算机可读存储介质。由上述内容可知,本发明实施例先选择一款已经完成预训练任务的大语言模型作为工作模型,并将该模型在其下一词预测任务中使用的下一词任务预测头和指令模板作为对应的概要词预测头和概要词指令模板,并将该模型的指定词表作为对应的工作词表;再将目标检索文库作为第一文库,并使用概要词指令模板、工作模型和概要词预测头为第一文库创建一个对应的文档概要词稠密向量映射空间即第一空间;然后,在收到用户输入的查询文本(即第一查询)时先使用概要词指令模板、工作模型和概要词预测头对第一查询的概要词稠密向量hq及概率分布向量Pq进行识别,再根据第一查询、概率分布向量Pq和工作词表进行关键词识别,再根据概要词稠密向量hq和第一空间对第一文库进行稠密检索、并根据关键词序列对第一文库进行稀疏检索,最后将稠密、稀疏检索结果的融合结果反馈给用户。本发明实施例在稠密检索时只对查询与文档的概要词稠密向量进行计算和比对从而降低了计算资源开销,在稀疏检索时利用伪关键词对关键词范围进行扩充从而提高了检索准确度,在得到稠密、稀疏检索结果之后对二者进行融合从而进一步提高了检索准确度;通过本发明实施例既降低了计算开销又提高了检索精度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120336506B_ABST
    Figure CN120336506B_ABST
Patent Text Reader

Abstract

The embodiment of the application relates to a kind of based on summary word's dense sparse retrieval fusion method and device, the method comprises: select large language model as working model, and the prediction head / instruction template used in the next word prediction task of this model is used as summary word prediction head / instruction template, and the model vocabulary is used as working vocabulary;Using instruction template, working model and prediction head creates document summary word dense vector mapping space of library, i.e. first space;Receive user query;Using instruction template, working model and prediction head identifies the summary word dense vector and probability distribution vector of query, and according to query, probability distribution vector and working vocabulary, keyword identification is carried out;According to the dense vector of query and first space, dense retrieval is carried out on library;According to keyword sequence, sparse retrieval is carried out on library;The fusion result of dense sparse retrieval is fed back to user. Through the application, the computing overhead can be reduced, and the retrieval accuracy can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a method and apparatus for dense and sparse retrieval fusion based on summary terms. Background Technology

[0002] In the field of information retrieval, dense retrieval and sparse retrieval are two common retrieval methods. Dense retrieval is a semantic feature-based method that converts both the query text (query) and the retrieved documents (documents) into dense semantic vectors in a high-dimensional feature space, and then filters the search results by calculating vector similarity. Sparse retrieval is an inverted index-based method that matches query keywords with documents containing those keywords, calculates a relevance score based on the degree of term matching between the documents and the query, and finally determines the documents relevant to the query based on the ranking of relevance scores. Compared to sparse retrieval, dense retrieval has higher accuracy, while sparse retrieval has lower computational resource overhead. Both methods have their advantages and disadvantages, and currently there is no universally applicable technical solution that can complement and integrate them.

[0003] Large Language Models (LLMs) are highly powerful in natural language learning, capable of fully understanding the personalized semantics of each word segment in the input text, as well as context-dependent semantics. The next word prediction task is a typical pre-training task for LLM models, requiring the model to predict the next word in the input text. Before training, a prediction network (also known as the next word prediction head), consisting of linear layers and a softmax function layer, is connected to the model's output. A custom instruction template is provided to the model to generate the input text through configuration. The prediction process is as follows: the text configured by the instruction template is used as input (considered as a concatenation of multiple word segments) and fed into the LLM model for forward inference to obtain a text latent vector H (composed of multiple word segment latent vectors h). The last word segment latent vector h is then used as the input text. end The next word prediction head is fed into the forward inference to obtain a probability distribution vector P (composed of multiple word probabilities p, with each word probability p corresponding to a word in the specified vocabulary) with the total number of words in the specified vocabulary (the dictionary or vocabulary used by the LLM model) as the vector length. The word with the highest probability in the probability distribution vector P is taken as the predicted next word text.

[0004] Two insights can be gained from the next word prediction task: 1) The feature space of the text latent vector H is a high-dimensional semantic feature space, and each word segmentation latent vector h can be regarded as a dense vector, while the last word segmentation latent vector h end Then it can be regarded as a dense vector that is highly related to the predicted word; 2) The relevance distribution of a word can be observed from the probability distribution vector P.

[0005] Based on the first insight, the following analysis results can be drawn: If the query / document can be condensed into a summary term through the next word prediction task, and then the dense vector of the two highly correlated summary terms can be calculated, the computational resource overhead of dense retrieval will be greatly reduced.

[0006] Based on the second insight, the following analysis results can be drawn: If the query can be condensed into a query summary term through the next word prediction task, then a word distribution related to the query summary term can be observed from the probability distribution vector P. If each word with a higher probability in this word distribution is regarded as a pseudo-keyword indirectly related to the query, then the keyword range can be further expanded. Then, sparse retrieval based on this expanded keyword range can naturally improve the retrieval accuracy.

[0007] Furthermore, if the search results obtained from the above two types of analysis can be integrated, it will inevitably achieve the complementary integration goal of improving search accuracy and reducing computational overhead.

[0008] The technical problem that this invention aims to solve is precisely: how to perform retrieval based on the above two types of analysis, and how to integrate the two types of retrieval results. Summary of the Invention

[0009] The purpose of this invention is to address the shortcomings of existing technologies by providing a method, apparatus, electronic device, and computer-readable storage medium for dense and sparse retrieval fusion based on summary terms. This invention first selects a large language model that has completed pre-training as the working model, and uses the next-word prediction head and instruction template used by this model in its next-word prediction task as the corresponding summary term prediction head and summary term instruction template, and uses the model's specified vocabulary as the corresponding working vocabulary. Next, the target retrieval library is used as the first library, and a corresponding document summary term dense vector mapping space, i.e., the first space, is created for the first library using the summary term instruction template, the working model, and the summary term prediction head. Then, upon receiving the user-input query text (i.e., the first query), the summary term instruction template, the working model, and the summary term prediction head are used to map the summary term dense vector h of the first query. q and probability distribution vector P q Perform identification, and then based on the first query and the probability distribution vector P q Keyword identification is performed using the working thesaurus, and then based on the summary term density vector hq This invention performs a dense search on a first document library and a sparse search on the same library based on keyword sequences. Finally, it returns the fused results of the dense and sparse searches to the user. In dense searching, this invention only calculates and compares the dense vectors of the query and document summary terms, thus reducing computational resource overhead. In sparse searching, it uses pseudo-keywords to expand the keyword range, thereby improving search accuracy. After obtaining the dense and sparse search results, the two are fused to further improve search accuracy. This invention reduces computational overhead while improving search precision.

[0010] To achieve the above objectives, a first aspect of the present invention provides a dense-sparse retrieval fusion method based on summary terms, the method comprising:

[0011] Select a large language model that has completed the pre-training task as the corresponding working model; and use the next word prediction head and instruction template used by the working model in its next word prediction task as the corresponding summary word prediction head and summary word instruction template; and use the specified vocabulary of the working model as the corresponding working vocabulary; the pre-training task includes the next word prediction task;

[0012] The preset search library is taken as the corresponding first library; and the summary term instruction template, the working model and the summary term prediction head are used to create a corresponding document summary term dense vector mapping space for the first library, which is denoted as the first space;

[0013] Receive the query text entered by the user as the first query;

[0014] The summary word instruction template, the working model, and the summary word prediction head are used to identify the dense vector and probability distribution vector of the summary words in the first query to obtain the corresponding dense vector h. q and probability distribution vector P q ; and based on the first query and the probability distribution vector P q The first keyword sequence is obtained by performing keyword identification on the working vocabulary;

[0015] According to the dense vector h q The first space is used to perform a dense search on the first library to obtain the corresponding first search sequence;

[0016] Based on the first keyword sequence, a sparse search is performed on the first document library to obtain the corresponding second search sequence;

[0017] The search results are fused based on the first and second search sequences to obtain the corresponding third search sequence, which is then fed back to the current user.

[0018] Preferably, the summary word prediction head is composed of a linear layer and a Softmax function layer connected together;

[0019] The summary word instruction template is a formatted instruction text template; the configurable parameters of the summary word instruction template include text configuration parameters; the summary word instruction template is used to take the text configuration parameters as the corresponding current text and prompt the working model to predict the summary words of the current text.

[0020] The working vocabulary includes multiple first-word terms. i 1 ≤ index i ≤ N W N W The total number of words in the working vocabulary; each of the first words w i As a single text of a word or phrase;

[0021] The first document library includes multiple first documents D j 1 ≤ index j ≤ N D N D This represents the total number of documents in the first document library;

[0022] The spatial dimension of the first space matches the feature dimension of the latent vector output by the working model; the first space includes multiple first spatial points n. j The first spatial point n j With the first document D j One-to-one correspondence;

[0023] The first keyword sequence includes multiple first keywords, and each first keyword corresponds to a keyword weight;

[0024] The first search sequence includes multiple first search documents, each of which corresponds to a first document score; the score of the first document ranges from 0 to 1.

[0025] The second search sequence includes multiple second search documents, each second search document corresponding to a second document score; the score of the second document ranges from 0 to 1.

[0026] The third search sequence includes multiple third search documents, each of which corresponds to a third document score; the score of the third document ranges from 0 to 1.

[0027] Preferably, the step of creating a corresponding document summary term dense vector mapping space, denoted as the first space, for the first document library using the summary term instruction template, the working model, and the summary term prediction head specifically includes:

[0028] Step 31, transfer each of the first documents D from the first document library. j As the corresponding current document; and setting the text configuration parameters of the summary word instruction template to the current document to obtain a document summary word prediction instruction text, denoted as the corresponding first instruction text; and inputting the first instruction text into the working model for forward inference, and denoting the text latent vector output by this model inference as latent vector H. j ; and the hidden vector H j The last latent vector of the word segmentation is used as the corresponding dense vector of the document summary words and denoted as the dense vector h. j,end ;

[0029] Wherein, the hidden vector H j Includes multiple latent vectors h for word segmentation j,k 1 ≤ index k ≤ N j N j The working model segments the first document D according to its corresponding word segmentation rules. j The total number of words obtained after word segmentation; the dense vector h j,end The corresponding latent vector for word segmentation

[0030] Step 32: Initialize a multidimensional space based on the latent vector feature dimensions output by the working model, denoted as the corresponding first space; and initialize each of the dense vectors h j,end The matching point in the first space is denoted as the corresponding first space point n. j .

[0031] Preferably, the process of using the summary word instruction template, the working model, and the summary word prediction head to identify the summary word density vector and probability distribution vector of the first query to obtain the corresponding density vector h is described. q and probability distribution vector P q Specifically, it includes:

[0032] The text configuration parameters of the summary word instruction template are set to the first query to obtain a query summary word prediction instruction text, which is recorded as the corresponding second instruction text; the second instruction text is then input into the working model for forward inference, and the text latent vector output by this model inference is recorded as latent vector H. q ; and the hidden vector H q The last segmented latent vector is used as the corresponding dense vector h. q ; and the dense vector h q Input the summary term prediction head for forward inference, and use the probability distribution vector output by the prediction head in this inference as the corresponding probability distribution vector P. q ;

[0033] Wherein, the hidden vector H q Includes multiple latent vectors h for word segmentation q,u 1 ≤ index u ≤ N q N q The total number of words obtained after the working model performs word segmentation on the first query according to its corresponding word segmentation rules; the dense vector h q The corresponding latent vector for word segmentation The probability distribution vector P q By N W The probability p of each word q,i Composition, the word probability p q,i The first vocabulary w in the working vocabulary i One-to-one correspondence; the word probability p q,i The value of is between 0 and 1.

[0034] Preferably, the step of using the first query and the probability distribution vector P... q The first keyword sequence is obtained by performing keyword identification on the working vocabulary, specifically including:

[0035] Based on preset keyword recognition rules, the first query is subjected to keyword recognition to obtain one or more corresponding keywords A; and a corresponding weight parameter a is set for each keyword A; and each weight parameter a is set to 1.

[0036] The probability distribution vector P is arranged in descending order of probability value. q N W The probability p of each of the given words q,i Sort the data to obtain the corresponding first probability sequence; and then determine the number N of the first instructions in the first probability sequence. P The probability p of each of the given words q,i Extract them to form the corresponding second probability sequence; and then extract the probability p of each word in the second probability sequence. q,i As a corresponding weight parameter b, and the probability p of each word in the second probability sequence q,i The first word w corresponding to the working vocabulary i As the corresponding pseudo-keyword B; the number of instructions N P It is a pre-set positive integer;

[0037] Each keyword A and its corresponding weight parameter a are used as a set of first keywords and keyword weights; each pseudo keyword B and its corresponding weight parameter b are used as a set of first keywords and keyword weights; and all the obtained first keywords form the corresponding first keyword sequence.

[0038] Preferably, the step based on the dense vector h q The first space performs a dense search on the first library to obtain the corresponding first search sequence, specifically including:

[0039] The dense vector h q The matching spatial point in the first space is denoted as the current spatial point; and in the first space, the approximate nearest neighbor spatial points of the current spatial point are retrieved based on a preset approximate nearest neighbor search algorithm to obtain the corresponding first spatial point set; the approximate nearest neighbor search algorithm includes the LSH algorithm and the VQ algorithm; the first spatial point set includes multiple first spatial points n. j ;

[0040] Each of the first spatial points n in the first spatial point set j Each of these is taken as the corresponding current comparison point; and the word segmentation latent vector corresponding to the current comparison point is taken as the corresponding current dense vector; and based on the cosine vector similarity algorithm, the dense vector h is... q The similarity with the current dense vector is calculated to obtain the corresponding current similarity; and when the current similarity is greater than a preset first similarity threshold, the first document D corresponding to the current comparison point is... j As a corresponding first retrieved document, the current similarity is used as a corresponding first document score; the first similarity threshold is a pre-set threshold parameter greater than 0;

[0041] All the first search documents obtained are sorted in descending order of their first document scores to form the corresponding first search sequence.

[0042] Preferably, the step of performing a sparse search on the first document library based on the first keyword sequence to obtain the corresponding second search sequence specifically includes:

[0043] The total number N is obtained by counting the total number of the first keywords in the first keyword sequence. S And each of the first keywords and its corresponding keyword weights is recorded as the corresponding keyword x. s Weight y s ; 1 ≤ index s ≤ N S ;

[0044] Each of the first documents D in the first document library j Each of these is treated as the corresponding current document; a document cumulative score is initialized to 0 for each current document; and all keywords x are assigned a score. sPerform one round of traversal; and during this round of traversal, change the keyword x that is currently being traversed. s and its corresponding weight y s As the corresponding current keyword and current weight; and when the current document contains the current keyword, the sum of the current document's cumulative score and the current weight is taken as the latest cumulative score of the current document;

[0045] From the obtained N D The maximum and minimum values ​​are selected from the cumulative scores of the documents as the corresponding maximum and minimum scores; and the corresponding normalized score is calculated based on the maximum and minimum scores to obtain the normalized score = (cumulative score of document - minimum score) / (maximum score - minimum score); the value of the normalized score is between 0 and 1;

[0046] Each normalized score exceeding a preset first score threshold is taken as a corresponding second document score; and the first document D corresponding to each second document score is... j As a corresponding second search document; and sort all the obtained second search documents in descending order of their second document scores to form the corresponding second search sequence.

[0047] Preferably, the step of fusing the search results based on the first and second search sequences to obtain a corresponding third search sequence and then feeding it back to the current user specifically includes:

[0048] All first and second search documents in the first and second search sequences are recorded as documents to be screened; and two score parameters initialized to 0 are set for each document to be screened, which are recorded as the corresponding first parameter and second parameter; and each document to be screened is identified. If the document to be screened exists in both the first and second search sequences, its corresponding first and second parameters are reset to the corresponding first and second document scores. If the document to be screened exists only in the first search sequence or the second search sequence, its corresponding first parameter or second parameter is reset to the corresponding first document score or second document score.

[0049] The first average score is obtained by averaging the first and second parameters of each document to be screened; each first average score that exceeds a preset second score threshold is taken as a corresponding third document score; each document to be screened corresponding to a third document score is taken as a corresponding third search document; and all the obtained third search documents are sorted in descending order of the third document scores to form a corresponding third search sequence and fed back to the current user.

[0050] A second aspect of the present invention provides an apparatus for implementing the summary term-based dense and sparse retrieval fusion method described in the first aspect above. The apparatus includes: an LLM model preparation module, a target library preparation module, a query receiving module, an LLM model processing module, a dense retrieval module, a sparse retrieval module, and a retrieval fusion module.

[0051] The LLM model preparation module is used to select a large language model that has completed a pre-training task as the corresponding working model; and to use the next word prediction head and instruction template used by the working model in its next word prediction task as the corresponding summary word prediction head and summary word instruction template; and to use the specified vocabulary of the working model as the corresponding working vocabulary; the pre-training task includes the next word prediction task;

[0052] The target document preparation module is used to take the preset search document as the corresponding first document; and uses the summary term instruction template, the working model and the summary term prediction head to create a corresponding document summary term dense vector mapping space for the first document, denoted as the first space;

[0053] The query receiving module is used to receive the query text input by the user as the first query;

[0054] The LLM model processing module is used to identify the dense vector h of the summary word dense vector and probability distribution vector of the first query using the summary word instruction template, the working model, and the summary word prediction head. q and probability distribution vector P q ; and based on the first query and the probability distribution vector P q The first keyword sequence is obtained by performing keyword identification on the working vocabulary;

[0055] The dense retrieval module is used to retrieve data based on the dense vector h. q The first space is used to perform a dense search on the first library to obtain the corresponding first search sequence;

[0056] The sparse retrieval module is used to perform a sparse retrieval on the first document library based on the first keyword sequence to obtain the corresponding second retrieval sequence.

[0057] The retrieval fusion module is used to fuse the retrieval results based on the first and second retrieval sequences to obtain a corresponding third retrieval sequence and then feed it back to the current user.

[0058] A third aspect of the present invention provides an electronic device, including: a memory, a processor, and a transceiver;

[0059] The processor is used to couple with the memory, read and execute instructions in the memory to implement the steps of the method described in the first aspect above;

[0060] The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.

[0061] A fourth aspect of the present invention provides a computer-readable storage medium storing computer instructions that, when executed by a computer, cause the computer to perform the instructions described in the first aspect.

[0062] This invention provides a method, apparatus, electronic device, and computer-readable storage medium for dense and sparse retrieval fusion based on summary terms. As described above, this invention first selects a large language model that has completed pre-training as the working model, and uses the next-word prediction head and instruction template used by this model in its next-word prediction task as the corresponding summary term prediction head and summary term instruction template, and uses the model's specified vocabulary as the corresponding working vocabulary. Then, the target retrieval library is used as the first library, and a corresponding document summary term dense vector mapping space, i.e., the first space, is created for the first library using the summary term instruction template, the working model, and the summary term prediction head. Finally, upon receiving the user's input query text (i.e., the first query), the summary term instruction template, the working model, and the summary term prediction head are used to map the summary term dense vector h of the first query. q and probability distribution vector P q Perform identification, and then based on the first query and the probability distribution vector P q Keyword identification is performed using the working thesaurus, and then based on the summary term density vector h q The invention performs a dense search on a first document library and a sparse search on the first document library based on keyword sequences. Finally, the fused results of the dense and sparse searches are fed back to the user. In this embodiment, the dense search only calculates and compares the dense vectors of the query and document summary terms, thus reducing computational resource overhead. In the sparse search, pseudo-keywords are used to expand the keyword range, thereby improving search accuracy. After obtaining the dense and sparse search results, the two are fused to further improve search accuracy. This embodiment of the invention reduces computational overhead while improving search accuracy. Attached Figure Description

[0063] Figure 1 This is a schematic diagram of a dense and sparse retrieval fusion method based on summary terms provided in Embodiment 1 of the present invention;

[0064] Figure 2 This is a module structure diagram of a dense and sparse retrieval fusion device based on summary terms provided in Embodiment 2 of the present invention;

[0065] Figure 3 This is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present invention. Detailed Implementation

[0066] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0067] Embodiment 1 of the present invention provides a dense-sparse retrieval fusion method based on summary terms, such as... Figure 1 The schematic diagram of a dense-sparse retrieval fusion method based on summary terms provided in Embodiment 1 of the present invention is shown. The method mainly includes the following steps:

[0068] Step 1: Select a large language model that has completed pre-training tasks as the corresponding working model; use the next word prediction head and instruction template used by the working model in its next word prediction task as the corresponding summary word prediction head and summary word instruction template; and use the specified vocabulary of the working model as the corresponding working vocabulary.

[0069] The pre-training task includes the next word prediction task.

[0070] Here, the working model of this invention is any large language model that has completed pre-training tasks, such as the BERT series models, RoBERTa series models, ALBERT series models, DeBERTa series models, etc., implemented based on the Encoder-Only framework; the GPT series models, Llama series models, etc., implemented based on the Decoder-Only framework; and the T5 series models, BART series models, Pegasus models, Longformer-Encoder-Decoder models, etc., implemented based on the Encoder-Decoder framework. Each large language model is trained based on the next word prediction task during its pre-training stage, and each is configured with a corresponding next word task prediction head. The structure of the next word task prediction head of each large language model is approximately the same, consisting of a linear layer and a Softmax function layer connected together. Therefore, the summary word prediction head of this invention is composed of a linear layer and a Softmax function layer connected together.

[0071] In simple terms, the reasoning process of the working model in this embodiment of the invention is as follows: First, the input text is segmented into words based on a corresponding word segmentation rule to obtain the corresponding word segmentation sequence; second, the word segmentation sequence is embedded and encoded based on a corresponding embedding encoding rule to obtain the corresponding embedding vector; in the third step, if the working model is implemented based on an Encoder-Only framework, then the third step involves an Encoder network extracting high-dimensional features from the embedding vector and outputting the corresponding latent vector H; if the working model is implemented based on a Decoder-Only framework, then the third step involves a Decoder network extracting high-dimensional features from the embedding vector and outputting the corresponding latent vector H; if the working model is implemented based on an Encoder-Decoder framework, then the third step involves an Encoder network first performing high-dimensional feature encoding on the embedding vector, and then a Decoder network extracting features based on the feature-encoded vector and outputting the corresponding latent vector H. It should be noted that the latent vector H consists of multiple word segmentation latent vectors h, and each word segmentation latent vector h in the latent vector H corresponds one-to-one with a word in the word segmentation sequence.

[0072] In simple terms, the reasoning process of the next word prediction head in the working model of this invention is as follows: the last word segmentation latent vector h of the latent vector H output by the working model is processed by the linear layer. end The vocabulary feature vectors are mapped, and the Softmax function layer calculates the probability distribution based on the vocabulary feature vectors to obtain the corresponding probability distribution vector P.

[0073] The summary word instruction template in this embodiment of the invention is a formatted instruction text template; the configurable parameters of the summary word instruction template include text configuration parameters; the summary word instruction template is used to take the text configuration parameters as the corresponding current text and prompt the working model to predict the summary words of the current text.

[0074] For example, the summary term instruction template can be:

[0075] “Text configuration parameters = ''; Please use a summary term to summarize the content of the text configuration parameters; summary term = .

[0076] The working vocabulary of this invention includes multiple first vocabulary words. i 1 ≤ index i ≤ N W N W The total number of words in the working vocabulary; each first word w i It is a single text of a word or phrase.

[0077] Step 2: Use the preset search library as the corresponding first library; and use the summary term instruction template, working model and summary term prediction head to create a corresponding document summary term dense vector mapping space for the first library, denoted as the first space;

[0078] Specifically, this includes: Step 21, using the preset search library as the corresponding first library;

[0079] Here, the preset search library is the pre-defined target search library; the first library in this embodiment of the invention includes multiple first documents D. j 1 ≤ index j ≤ N D N D This represents the total number of documents in the first document library.

[0080] Step 22, and use the summary term instruction template, working model and summary term prediction head to create a corresponding document summary term dense vector mapping space for the first library, denoted as the first space;

[0081] Specifically, this includes: Step 221, which involves storing each first document D in the first document library. j As the corresponding current document; and setting the text configuration parameters of the summary word instruction template to the current document to obtain a document summary word prediction instruction text, denoted as the corresponding first instruction text; and inputting the first instruction text into the working model for forward inference, and denoting the text latent vector output by this model inference as latent vector H. j ; and the implicit vector H j The last latent vector of the word segmentation is used as the corresponding dense vector of the document summary words and denoted as the dense vector h. j,end ;

[0082] Among them, the hidden vector H j Includes multiple latent vectors h for word segmentation j,k 1 ≤ index k ≤ N j N j The working model segments the first document D according to its corresponding word segmentation rules. j The total number of words obtained after word segmentation; dense vector h j,end The corresponding latent vector for word segmentation

[0083] Step 222: Initialize a multidimensional space based on the latent vector feature dimensions output by the working model, denoted as the corresponding first space; and initialize each dense vector h j,end The matching point in the first space is denoted as the corresponding first space point n. j .

[0084] Here, the spatial dimension of the first space in this embodiment matches the feature dimension of the latent vector output by the working model; the first space includes multiple first space points n. jFirst spatial point n j With the first document D j One-to-one correspondence.

[0085] Step 3: Receive the query text entered by the user as the first query.

[0086] Step 4: Use the summary word instruction template, working model, and summary word prediction head to identify the summary word dense vector and probability distribution vector of the first query to obtain the corresponding dense vector h. q and probability distribution vector P q ; and based on the first query and the probability distribution vector P q The first keyword sequence is obtained by performing keyword identification with the working thesaurus;

[0087] Specifically, this includes: Step 41, using the summary word instruction template, working model, and summary word prediction head to identify the dense vector and probability distribution vector of the summary words in the first query to obtain the corresponding dense vector h. q and probability distribution vector P q ;

[0088] Specifically, this includes: setting the text configuration parameters of the summary word instruction template to the first query to obtain a query summary word prediction instruction text, which is recorded as the corresponding second instruction text; inputting the second instruction text into the working model for forward inference, and recording the text latent vector output by the model inference as the latent vector H. q ; and the implicit vector H q The last word segmentation latent vector is used as the corresponding dense vector h. q ; and the dense vector h q Input the summary term prediction head for forward inference, and use the probability distribution vector output by this prediction head as the corresponding probability distribution vector P. q ;

[0089] Among them, the hidden vector H q Includes multiple latent vectors h for word segmentation q,u 1 ≤ index u ≤ N q N q The total number of words obtained after the working model performs word segmentation on the first query according to its corresponding word segmentation rules; dense vector h q The corresponding latent vector for word segmentation probability distribution vector P q By N W The probability p of each word q,i Composition, word probability p q,i The first word of the working vocabulary w i One-to-one correspondence; word probability p q,i The value of is between 0 and 1;

[0090] Step 42, and based on the first query and probability distribution vector P q The first keyword sequence is obtained by performing keyword identification with the working thesaurus;

[0091] Specifically, this includes: Step 421, based on preset keyword recognition rules, performing keyword recognition on the first query to obtain one or more corresponding keywords A; and setting a corresponding weight parameter a for each keyword A; and setting each weight parameter a to 1;

[0092] Here, the keyword recognition rule in this embodiment of the invention is a pre-set grammar rule, which can be customized according to application requirements; one customization method is to use the subject of the sentence, i.e., the first query, as the keyword; another customization method is to use the nouns and / or pronouns in the sentence, i.e., the first query, as the keyword.

[0093] Step 422, sort the probability distribution vector P in descending order of probability values. q N W The probability p of each word q,i Sort the data to obtain the corresponding first probability sequence; and then select the number N of instructions that appear first in the first probability sequence. P The probability p of each word q,i Extract them to form the corresponding second probability sequence; and assign the probability p of each word in the second probability sequence to... q,i As a corresponding weight parameter b, and the probability p of each word in the second probability sequence q,i The first word in the working thesaurus is w i As the corresponding pseudo-keyword B;

[0094] Here, the number of instructions N in this embodiment of the invention P It is a pre-set positive integer;

[0095] Step 43: Take each keyword A and its corresponding weight parameter a as a set of corresponding first keywords and keyword weights; take each pseudo keyword B and its corresponding weight parameter b as a set of corresponding first keywords and keyword weights; and form a corresponding first keyword sequence from all the obtained first keywords.

[0096] Here, the first keyword sequence in this embodiment of the invention includes multiple first keywords, and each first keyword corresponds to a keyword weight.

[0097] Step 5, based on the dense vector h q The first space performs a dense search on the first library to obtain the corresponding first search sequence;

[0098] The first search sequence includes multiple first search documents, each first search document corresponds to a first document score; the score range of the first document score is between 0 and 1.

[0099] Specifically, this includes: Step 51, dividing the dense vector h q The matching spatial point in the first space is denoted as the current spatial point; and in the first space, the approximate nearest neighbor spatial points of the current spatial point are retrieved based on the preset approximate nearest neighbor search algorithm to obtain the corresponding first spatial point set;

[0100] Here, the approximate nearest neighbor search algorithm in this embodiment of the invention includes the Locality Sensitive Hashing (LSH) algorithm and the Vector Quantization (VQ) algorithm; the first spatial point set includes multiple first spatial points n. j ;

[0101] Step 52, set each of the first spatial points n in the first spatial point set. j Each node is used as the corresponding current comparison point; the word segmentation latent vector corresponding to the current comparison point is used as the corresponding current dense vector; and based on the cosine vector similarity algorithm, the dense vector h is... q The current similarity is calculated by comparing it with the current dense vector; and if the current similarity is greater than a preset first similarity threshold, the first document D corresponding to the current comparison point is selected. j As the corresponding first retrieved document, the current similarity is used as the score of the corresponding first document;

[0102] Here, the first similarity threshold in this embodiment of the invention is a pre-set threshold parameter greater than 0;

[0103] Step 53: Sort all the first search documents in descending order of their first document scores to form the corresponding first search sequence.

[0104] Step 6: Perform a sparse search on the first document library based on the first keyword sequence to obtain the corresponding second search sequence;

[0105] The second search sequence includes multiple second search documents, each of which corresponds to a second document score; the score range of the second document score is between 0 and 1.

[0106] Specifically, this includes: Step 61, counting the total number of first keywords in the first keyword sequence to obtain the corresponding total number N. S And each primary keyword and its corresponding keyword weight are denoted as the corresponding keyword x. s Weight y s ;

[0107] Where 1 ≤ index s ≤ N S ;

[0108] Step 62, transfer each first document D from the first document library. j Each keyword is treated as the corresponding current document; a cumulative score of 0 is initialized to the current document; and all keywords x are assigned a cumulative score. s Perform one iteration; and during this iteration, change the keyword x being iterated over. s and its corresponding weight y s This serves as the corresponding current keyword and current weight; and when the current document contains the current keyword, the sum of the current document's cumulative score and current weight is used as the latest cumulative score for the current document;

[0109] Step 63, from the obtained N D The maximum and minimum scores are selected from the cumulative scores of each document as the corresponding maximum and minimum scores; and the cumulative scores of each document are normalized based on the maximum and minimum scores to obtain the corresponding normalized score = (cumulative score of document - minimum score) / (maximum score - minimum score);

[0110] The normalized score ranges from 0 to 1.

[0111] Step 64: Each normalized score exceeding a preset first score threshold is taken as a corresponding second document score; and the first document D corresponding to each second document score is... j This serves as a corresponding second search document; and all the obtained second search documents are sorted in descending order of their scores to form the corresponding second search sequence.

[0112] Here, the first score threshold in this embodiment of the invention is a pre-set threshold parameter greater than 0.

[0113] Step 7: Merge the search results based on the first and second search sequences to obtain the corresponding third search sequence and then feed it back to the current user;

[0114] The third search sequence includes multiple third search documents, each of which corresponds to a third document score; the score range of the third document score is between 0 and 1.

[0115] Specifically, this includes: Step 71, recording all first and second search documents in the first and second search sequences as documents to be screened; setting two score parameters initialized to 0 for each document to be screened as the corresponding first parameter and second parameter; and identifying each document to be screened. If the document to be screened exists in both the first and second search sequences, its corresponding first and second parameters are reset to the corresponding first and second document scores. If the document to be screened exists only in the first or second search sequence, its corresponding first or second parameter is reset to the corresponding first document score or second document score.

[0116] Step 72: Calculate the average of the first and second parameters of each document to be screened to obtain the corresponding first average score; take each first average score that exceeds the preset second score threshold as a corresponding third document score; take each document to be screened corresponding to the third document score as a corresponding third search document; and sort all the obtained third search documents in descending order of third document scores to form a corresponding third search sequence and feed it back to the current user.

[0117] Figure 2 This is a module structure diagram of a dense-sparse retrieval fusion device based on summary terms provided in Embodiment 2 of the present invention. This device can be a terminal device or server implementing the aforementioned method embodiments, or it can be a device that enables the aforementioned terminal device or server to implement the aforementioned method embodiments. For example, the device can be a device or chip system of the aforementioned terminal device or server. Figure 2 As shown, the device includes: an LLM model preparation module 201, a target library preparation module 202, a query receiving module 203, an LLM model processing module 204, a dense retrieval module 205, a sparse retrieval module 206, and a retrieval fusion module 207.

[0118] The LLM model preparation module 201 is used to select a large language model that has completed a pre-training task as the corresponding working model; and to use the next word prediction head and instruction template used by the working model in its next word prediction task as the corresponding summary word prediction head and summary word instruction template; and to use the specified vocabulary of the working model as the corresponding working vocabulary; the pre-training task includes the next word prediction task.

[0119] The target document preparation module 202 is used to take the preset search document as the corresponding first document; and uses the summary term instruction template, working model and summary term prediction head to create a corresponding document summary term dense vector mapping space for the first document, denoted as the first space.

[0120] The query receiving module 203 is used to receive the query text input by the user as the first query.

[0121] The LLM model processing module 204 is used to identify the dense vector and probability distribution vector of the summary words in the first query using the summary word instruction template, the working model, and the summary word prediction head to obtain the corresponding dense vector h. q and probability distribution vector P q ; and based on the first query and the probability distribution vector P q The first keyword sequence is obtained by performing keyword identification on the working thesaurus.

[0122] Dense retrieval module 205 is used to retrieve data based on dense vector h. q The first space performs a dense search on the first library to obtain the corresponding first search sequence.

[0123] The sparse retrieval module 206 is used to perform sparse retrieval on the first document library based on the first keyword sequence to obtain the corresponding second retrieval sequence.

[0124] The retrieval fusion module 207 is used to fuse the retrieval results based on the first and second retrieval sequences to obtain the corresponding third retrieval sequence and then feed it back to the current user.

[0125] The dense and sparse retrieval fusion device based on summary terms provided in this embodiment of the invention can execute the method steps in the above method embodiment. Its implementation principle and technical effect are similar, and will not be repeated here.

[0126] It should be noted that the division of the various modules in the above device is merely a logical functional division. In actual implementation, they can be fully or partially integrated into a single physical entity, or they can be physically separated. Furthermore, these modules can be implemented entirely in software via processing element calls; they can be fully implemented in hardware; or some modules can be implemented by processing element calls to software, while others are implemented in hardware. For example, the LLM model preparation module can be a separate processing element, or it can be integrated into a chip in the above device. Alternatively, it can be stored as program code in the memory of the above device, and called and executed by a processing element. The implementation of other modules is similar. Moreover, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each of the above modules can be completed through integrated logic circuits in the hardware of the processor element or through software instructions.

[0127] For example, these modules can be one or more integrated circuits configured to implement the above methods, such as one or more Application Specific Integrated Circuits (ASICs), one or more Digital Signal Processors (DSPs), or one or more Field Programmable Gate Arrays (FPGAs). As another example, when a module is implemented using processing element scheduler code, the processing element can be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. Furthermore, these modules can be integrated together as a System-on-a-Chip (SOC).

[0128] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. This computer program product includes one or more computer instructions. When these computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the foregoing method embodiments are generated. The computer described above can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The aforementioned computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the aforementioned computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, Bluetooth, microwave, etc.) means. The aforementioned computer-readable storage medium can be any available medium that a computer can access, or a data storage device such as a server or data center that integrates one or more available media. The aforementioned available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state disks (SSDs)).

[0129] Figure 3 This is a schematic diagram of an electronic device provided in Embodiment 3 of the present invention. This electronic device can be a terminal device or server implementing the methods of the aforementioned embodiments, or it can be a terminal device or server connected to the aforementioned terminal device or server implementing the methods of the aforementioned embodiments. Figure 3As shown, the electronic device may include: a processor 301 (e.g., CPU), a memory 302, and a transceiver 303; the transceiver 303 is coupled to the processor 301, and the processor 301 controls the transmission and reception operations of the transceiver 303. The memory 302 may store various instructions for performing various processing functions and implementing the processing steps described in the foregoing embodiments. Preferably, the electronic device involved in the embodiments of the present invention further includes: a power supply 304, a system bus 305, and a communication port 306. The system bus 305 is used to realize communication connections between components. The communication port 306 is used for communication between the electronic device and other peripherals.

[0130] exist Figure 3 The system bus 305 mentioned can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This system bus can be divided into address bus, data bus, control bus, etc. For ease of representation, it is represented by only one thick line in the figure, but this does not indicate that there is only one bus or one type of bus. The communication interface is used to enable communication between the database access device and other devices (e.g., clients, read-write libraries, and read-only libraries). Memory may include Random Access Memory (RAM) and may also include non-volatile memory, such as at least one disk storage device.

[0131] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), graphics processing units (GPUs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0132] It should be noted that the embodiments of the present invention also provide a computer-readable storage medium storing instructions that, when run on a computer, cause the computer to perform the methods and processes provided in the above embodiments.

[0133] This invention provides a method, apparatus, electronic device, and computer-readable storage medium for dense and sparse retrieval fusion based on summary terms. As described above, this invention first selects a large language model that has completed pre-training as the working model, and uses the next-word prediction head and instruction template used by this model in its next-word prediction task as the corresponding summary term prediction head and summary term instruction template, and uses the model's specified vocabulary as the corresponding working vocabulary. Then, the target retrieval library is used as the first library, and a corresponding document summary term dense vector mapping space, i.e., the first space, is created for the first library using the summary term instruction template, the working model, and the summary term prediction head. Finally, upon receiving the user's input query text (i.e., the first query), the summary term instruction template, the working model, and the summary term prediction head are used to map the summary term dense vector h of the first query. q and probability distribution vector P q Perform identification, and then based on the first query and the probability distribution vector P q Keyword identification is performed using the working thesaurus, and then based on the summary term density vector h q The invention performs a dense search on a first document library and a sparse search on the first document library based on keyword sequences. Finally, the fused results of the dense and sparse searches are fed back to the user. In this embodiment, the dense search only calculates and compares the dense vectors of the query and document summary terms, thus reducing computational resource overhead. In the sparse search, pseudo-keywords are used to expand the keyword range, thereby improving search accuracy. After obtaining the dense and sparse search results, the two are fused to further improve search accuracy. This embodiment of the invention reduces computational overhead while improving search accuracy.

[0134] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented in hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0135] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A dense-sparse retrieval fusion method based on summary terms, characterized in that, The method includes: Select a large language model that has completed the pre-training task as the corresponding working model; and use the next word prediction head and instruction template used by the working model in its next word prediction task as the corresponding summary word prediction head and summary word instruction template; and use the specified vocabulary of the working model as the corresponding working vocabulary; the pre-training task includes the next word prediction task; The preset search library is taken as the corresponding first library; and the summary term instruction template, the working model and the summary term prediction head are used to create a corresponding document summary term dense vector mapping space for the first library, which is denoted as the first space; Receive the query text entered by the user as the first query; The summary word instruction template, the working model, and the summary word prediction head are used to identify the dense vector and probability distribution vector of the summary words in the first query to obtain the corresponding dense vector h. q and probability distribution vector P q ; and based on the first query and the probability distribution vector P q The first keyword sequence is obtained by performing keyword identification on the working vocabulary; According to the dense vector h q The first space is used to perform a dense search on the first library to obtain the corresponding first search sequence; Based on the first keyword sequence, a sparse search is performed on the first document library to obtain the corresponding second search sequence; The search results are fused based on the first and second search sequences to obtain the corresponding third search sequence, which is then fed back to the current user. The summary word prediction head is composed of a linear layer and a Softmax function layer connected together. The summary word instruction template is a formatted instruction text template; the configurable parameters of the summary word instruction template include text configuration parameters; the summary word instruction template is used to take the text configuration parameters as the corresponding current text and prompt the working model to predict the summary words of the current text. The working vocabulary includes multiple first-word terms. i 1 ≤ index i ≤ N W N W The total number of words in the working vocabulary; each of the first words w i As a single text of a word or phrase; The first document library includes multiple first documents D j 1 ≤ index j ≤ N D N D This represents the total number of documents in the first document library; The spatial dimension of the first space matches the feature dimension of the latent vector output by the working model; the first space includes multiple first spatial points n. j The first spatial point n j With the first document D j One-to-one correspondence; The first keyword sequence includes multiple first keywords, and each first keyword corresponds to a keyword weight; The first search sequence includes multiple first search documents, each of which corresponds to a first document score; the score of the first document ranges from 0 to 1. The second search sequence includes multiple second search documents, each second search document corresponding to a second document score; the score of the second document ranges from 0 to 1. The third search sequence includes multiple third search documents, each of which corresponds to a third document score; the score of the third document ranges from 0 to 1.

2. The dense-sparse retrieval fusion method based on summary terms according to claim 1, characterized in that, The step of creating a corresponding document summary term dense vector mapping space, denoted as the first space, for the first document library using the summary term instruction template, the working model, and the summary term prediction head specifically includes: Step 31, transfer each of the first documents D from the first document library. j As the corresponding current document; and setting the text configuration parameters of the summary word instruction template to the current document to obtain a document summary word prediction instruction text, denoted as the corresponding first instruction text; and inputting the first instruction text into the working model for forward inference, and denoting the text latent vector output by this model inference as latent vector H. j ; and the hidden vector H j The last latent vector of the word segmentation is used as the corresponding dense vector of the document summary words and denoted as the dense vector h. j,end ; Wherein, the hidden vector H j Includes multiple latent vectors h for word segmentation j,k 1 ≤ index k ≤ N j N j The working model segments the first document D according to its corresponding word segmentation rules. j The total number of words obtained after word segmentation; the dense vector h j,end The corresponding latent vector for word segmentation ; Step 32: Initialize a multidimensional space based on the latent vector feature dimensions output by the working model, denoted as the corresponding first space; and initialize each of the dense vectors h j,end The matching point in the first space is denoted as the corresponding first space point n. j .

3. The dense-sparse retrieval fusion method based on summary terms according to claim 2, characterized in that, The summary word instruction template, the working model, and the summary word prediction head are used to identify the dense vector and probability distribution vector of the summary words in the first query to obtain the corresponding dense vector h. q and probability distribution vector P q Specifically, it includes: The text configuration parameters of the summary word instruction template are set to the first query to obtain a query summary word prediction instruction text, which is recorded as the corresponding second instruction text; the second instruction text is then input into the working model for forward inference, and the text latent vector output by this model inference is recorded as latent vector H. q ; and the hidden vector H q The last segmented latent vector is used as the corresponding dense vector h. q ; and the dense vector h q Input the summary term prediction head for forward inference, and use the probability distribution vector output by the prediction head in this inference as the corresponding probability distribution vector P. q ; Wherein, the hidden vector H q Includes multiple latent vectors h for word segmentation q,u 1 ≤ index u ≤ N q N q The total number of words obtained after the working model performs word segmentation on the first query according to its corresponding word segmentation rules; the dense vector h q The corresponding latent vector for word segmentation The probability distribution vector P q By N W The probability p of each word q,i Composition, the word probability p q,i The first vocabulary w in the working vocabulary i One-to-one correspondence; the word probability p q,i The value of is between 0 and 1.

4. The dense-sparse retrieval fusion method based on summary terms according to claim 3, characterized in that, The first query and the probability distribution vector P are used to... q The first keyword sequence is obtained by performing keyword identification on the working vocabulary, specifically including: Based on preset keyword recognition rules, the first query is subjected to keyword recognition to obtain one or more corresponding keywords A; and a corresponding weight parameter a is set for each keyword A; and each weight parameter a is set to 1. The probability distribution vector P is arranged in descending order of probability value. q N W The probability p of each of the given words q,i Sort the data to obtain the corresponding first probability sequence; and then determine the number N of the first instructions in the first probability sequence. P The probability p of each of the given words q,i Extract them to form the corresponding second probability sequence; and then extract the probability p of each word in the second probability sequence. q,i As a corresponding weight parameter b, and the probability p of each word in the second probability sequence q,i The first word w corresponding to the working vocabulary i As the corresponding pseudo-keyword B; the number of instructions N P It is a pre-set positive integer; Each keyword A and its corresponding weight parameter a are used as a set of first keywords and keyword weights; each pseudo keyword B and its corresponding weight parameter b are used as a set of first keywords and keyword weights; and all the obtained first keywords form the corresponding first keyword sequence.

5. The dense-sparse retrieval fusion method based on summary terms according to claim 1, characterized in that, The dense vector h q The first space performs a dense search on the first library to obtain the corresponding first search sequence, specifically including: The dense vector h q The matching spatial point in the first space is denoted as the current spatial point; and in the first space, the approximate nearest neighbor spatial points of the current spatial point are retrieved based on a preset approximate nearest neighbor search algorithm to obtain the corresponding first spatial point set; the approximate nearest neighbor search algorithm includes the LSH algorithm and the VQ algorithm; the first spatial point set includes multiple first spatial points n. j ; Each of the first spatial points n in the first spatial point set j Each of these is taken as the corresponding current comparison point; and the word segmentation latent vector corresponding to the current comparison point is taken as the corresponding current dense vector; and based on the cosine vector similarity algorithm, the dense vector h is... q The similarity with the current dense vector is calculated to obtain the corresponding current similarity; and when the current similarity is greater than a preset first similarity threshold, the first document D corresponding to the current comparison point is... j As a corresponding first retrieved document, the current similarity is used as a corresponding first document score; the first similarity threshold is a pre-set threshold parameter greater than 0; All the first search documents obtained are sorted in descending order of their first document scores to form the corresponding first search sequence.

6. The dense-sparse retrieval fusion method based on summary terms according to claim 1, characterized in that, The step of performing a sparse search on the first document library based on the first keyword sequence to obtain the corresponding second search sequence specifically includes: The total number N is obtained by counting the total number of the first keywords in the first keyword sequence. S And each of the first keywords and its corresponding keyword weights is recorded as the corresponding keyword x. s Weight y s ; 1 ≤ index s ≤ N S ; Each of the first documents D in the first document library j Each of these is treated as the corresponding current document; a document cumulative score is initialized to 0 for each current document; and all keywords x are assigned a score. s Perform one round of traversal; and during this round of traversal, change the keyword x that is currently being traversed. s and its corresponding weight y s As the corresponding current keyword and current weight; and when the current document contains the current keyword, the sum of the current document's cumulative score and the current weight is taken as the latest cumulative score of the current document; From the obtained N D The maximum and minimum values ​​are selected from the cumulative scores of the documents as the corresponding maximum and minimum scores; and the corresponding normalized score is calculated based on the maximum and minimum scores to obtain the normalized score = (cumulative score of document - minimum score) / (maximum score - minimum score); the value of the normalized score is between 0 and 1; Each normalized score exceeding a preset first score threshold is taken as a corresponding second document score; and the first document D corresponding to each second document score is... j As a corresponding second search document; and sort all the obtained second search documents in descending order of their second document scores to form the corresponding second search sequence.

7. The dense-sparse retrieval fusion method based on summary terms according to claim 1, characterized in that, The step of fusing the search results based on the first and second search sequences to obtain the corresponding third search sequence and then feeding it back to the current user specifically includes: All first and second search documents in the first and second search sequences are recorded as documents to be screened; and two score parameters initialized to 0 are set for each document to be screened, which are recorded as the corresponding first parameter and second parameter; and each document to be screened is identified. If the document to be screened exists in both the first and second search sequences, its corresponding first and second parameters are reset to the corresponding first and second document scores. If the document to be screened exists only in the first search sequence or the second search sequence, its corresponding first parameter or second parameter is reset to the corresponding first document score or second document score. The first average score is obtained by averaging the first and second parameters of each document to be screened; each first average score that exceeds a preset second score threshold is taken as a corresponding third document score; each document to be screened corresponding to a third document score is taken as a corresponding third search document; and all the obtained third search documents are sorted in descending order of the third document scores to form a corresponding third search sequence and fed back to the current user.

8. An apparatus for performing the dense-sparse retrieval fusion method based on summary terms as described in any one of claims 1-7, characterized in that, The device includes: an LLM model preparation module, a target library preparation module, a query receiving module, an LLM model processing module, a dense retrieval module, a sparse retrieval module, and a retrieval fusion module; The LLM model preparation module is used to select a large language model that has completed a pre-training task as the corresponding working model; and to use the next word prediction head and instruction template used by the working model in its next word prediction task as the corresponding summary word prediction head and summary word instruction template; and to use the specified vocabulary of the working model as the corresponding working vocabulary; the pre-training task includes the next word prediction task; The target document preparation module is used to take the preset search document as the corresponding first document; and uses the summary term instruction template, the working model and the summary term prediction head to create a corresponding document summary term dense vector mapping space for the first document, denoted as the first space; The query receiving module is used to receive the query text input by the user as the first query; The LLM model processing module is used to identify the dense vector h of the summary word dense vector and probability distribution vector of the first query using the summary word instruction template, the working model, and the summary word prediction head. q and probability distribution vector P q ; and based on the first query and the probability distribution vector P q The first keyword sequence is obtained by performing keyword identification on the working vocabulary; The dense retrieval module is used to retrieve data based on the dense vector h. q The first space is used to perform a dense search on the first library to obtain the corresponding first search sequence; The sparse retrieval module is used to perform a sparse retrieval on the first document library based on the first keyword sequence to obtain the corresponding second retrieval sequence. The retrieval fusion module is used to fuse the retrieval results based on the first and second retrieval sequences to obtain a corresponding third retrieval sequence and then feed it back to the current user.

9. An electronic device, characterized in that, include: Memory, processor, and transceiver; The processor is used to couple with the memory, read and execute instructions in the memory to implement the dense and sparse retrieval fusion method based on summary words as described in any one of claims 1-7; The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed by a computer, cause the computer to perform the dense-sparse retrieval fusion method based on summary terms as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Control method and device for realizing article recommendation based on user behaviors

    CN112597389A

  • Method and device for improving quality of information generated by large model

    CN116881398A