Information retrieval method, device, electronic device and readable storage medium

By pre-training dense vector models and clustering to generate text paths, the retrieval model is optimized, which solves the problems of high computational and storage costs and neglect of semantic similarity in traditional text retrieval, and achieves efficient and accurate information retrieval.

CN114676218BActive Publication Date: 2024-08-27TSINGHUA UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210233595.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-10
Publication Date
2024-08-27
Estimated Expiration
2042-03-10

AI Technical Summary

Technical Problem

Traditional text retrieval methods are computationally and storage expensive, and ignore semantic similarity, resulting in low retrieval efficiency.

Method used

By pre-training a dense vector model based on massive text samples, performing clustering to generate text paths, converting them into IDs, and performing memory training to optimize the retrieval model and reduce encoding and storage requirements during retrieval.

Benefits of technology

It reduces the calculation and storage costs, improves the retrieval efficiency, enhances the accuracy and efficiency of retrieval, and avoids the vector similarity calculation of the retrieval statements and texts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114676218B
    Figure CN114676218B
Patent Text Reader

Abstract

The present invention provides an information retrieval method, device, electronic device and readable storage medium, wherein the information retrieval method comprises the following steps: obtaining a sentence to be queried; based on a pre-trained retrieval model, outputting an ID having a textual correspondence relationship with the sentence to be queried; wherein the retrieval model is obtained based on a large number of text samples and ID training, and the retrieval model stores the textual correspondence relationship between each of the large number of text samples and the ID. Compared with the prior art, which requires vector similarity calculation between the sentence to be queried and the text during retrieval, the present invention does not require encoding, storage and calculation of the retrieval text during retrieval, thereby reducing the calculation cost and storage cost and improving the efficiency of retrieval.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of machine learning technology, and in particular to an information retrieval method, device, electronic device and readable storage medium. Background Art

[0002] Traditional text retrieval mostly calculates similarity based on word matching. For example, dense vector retrieval converts all text into vectors and calculates text similarity by calculating the dot product of the vectors. This algorithm often causes the model to ignore semantic similarity.

[0003] At the same time, dense vector retrieval requires encoding all the text to be retrieved and storing the corresponding vectors. When searching, the vector representation of the query needs to be calculated, and similarity calculation requires large-scale vector multiplication, which is computationally and storage-intensive. Summary of the invention

[0004] The present invention provides an information retrieval method, device, electronic device and readable storage medium, which are used to solve the defects of high computational cost and storage cost in the prior art and retrieval model ignoring semantic similarity, and realize low-cost, accurate and efficient retrieval.

[0005] The present invention provides an information retrieval method, comprising:

[0006] Get the query statement to be queried;

[0007] Based on the pre-trained retrieval model, output an ID having a textual correspondence with the query sentence;

[0008] The retrieval model is obtained by training based on massive text samples and IDs, and the retrieval model stores the text correspondence between each of the massive text samples and IDs.

[0009] According to an information retrieval method provided by the present invention, the process of pre-training the retrieval model specifically includes:

[0010] Obtaining the massive text samples, and using a pre-trained dense vector model to represent all the text samples as dense vectors;

[0011] Based on the dense vector, clustering the massive text samples to obtain a path corresponding to each text sample;

[0012] Convert the paths obtained by clustering into IDs corresponding to the text samples respectively;

[0013] Based on the massive text samples and the IDs corresponding to the massive text samples, memory training is performed on the retrieval model.

[0014] According to an information retrieval method provided by the present invention, the training process of the pre-trained dense vector model specifically includes:

[0015] Determine a query statement q and a positive example text d related to the query statement q;

[0016] In the query corpus, randomly collect negative example texts

[0017] The query statement q, the positive example text d, the text Inputting into a pre-stored language model for training to obtain the dense vector model;

[0018] Wherein, n is a positive integer.

[0019] According to an information retrieval method provided by the present invention, clustering the massive text samples based on the dense vector specifically includes:

[0020] Obtaining a dense vector generated by the massive text sample;

[0021] Clustering the dense vector into x subclasses according to a preset value x;

[0022] Cluster each of the newly generated x subclasses into x subclasses;

[0023] Clustering the subclasses multiple times until the number of texts in each newly generated subclass is less than the preset value x;

[0024] Wherein, the preset value x is a positive integer.

[0025] According to an information retrieval method provided by the present invention, the paths obtained by clustering are converted into IDs corresponding to the text samples respectively, specifically comprising:

[0026] The labels of each layer of clusters are obtained according to the clustering path, and the corresponding label combination of each layer of clusters is used as the initial ID;

[0027] The initial ID is iteratively optimized based on the retrieval model to be trained to generate an ID corresponding to each of the text samples.

[0028] According to an information retrieval method provided by the present invention, the combination of labels corresponding to each layer of clustering is used as the initial ID, and then further includes:

[0029] If it is determined that the initial IDs generated by different texts are the same, the different texts are represented as dense vectors respectively using the pre-trained dense vector model;

[0030] Based on the dense vectors of different texts, cluster different texts separately to obtain the paths corresponding to each text;

[0031] The paths obtained by clustering are converted into optimized IDs corresponding to the respective texts, and the optimized IDs are used as the initial IDs of the respective texts.

[0032] According to an information retrieval method provided by the present invention, the memory training of the retrieval model based on the massive text samples and the IDs corresponding to the massive text samples specifically includes:

[0033] Inputting the massive text samples and the IDs corresponding to the massive text samples into a pre-trained language model;

[0034] The retrieval model is memory-trained by using the pre-trained language model to obtain an optimized trained retrieval model.

[0035] The present invention also provides an information retrieval device, comprising:

[0036] The acquisition module is used to obtain the query statement;

[0037] A query output module, used for outputting an ID having a textual correspondence with the query sentence based on a pre-trained retrieval model;

[0038] The retrieval model is obtained by training based on massive text samples and IDs, and the retrieval model stores the text correspondence between each of the massive text samples and IDs.

[0039] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the above-mentioned information retrieval methods is implemented.

[0040] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the information retrieval method described in any one of the above is implemented.

[0041] The present invention provides an information retrieval method, device, electronic device and readable storage medium, which outputs an ID having a textual correspondence relationship with the query sentence based on a pre-trained retrieval model after obtaining the query sentence. The retrieval model is obtained based on massive text samples and ID training, and the retrieval model stores the textual correspondence relationship between each massive text sample and the ID. Compared with the prior art, which needs to calculate the vector similarity between the query sentence and the text during retrieval, the present invention does not need to encode, store, and calculate the retrieval text during retrieval, which reduces the calculation cost and storage cost and improves the efficiency of retrieval. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0043] Figure 1 It is one of the flow charts of the information retrieval method provided by the present invention;

[0044] Figure 2 This is the second flow chart of the information retrieval method provided by the present invention;

[0045] Figure 3 It is a clustering schematic diagram in the information retrieval method provided by the present invention;

[0046] Figure 4 It is a structural schematic diagram of the information retrieval device provided by the present invention;

[0047] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0048] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0049] Combine the following Figure 1-Figure 5 An information retrieval method, device, electronic device and readable storage medium of the present invention are described.

[0050] Figure 1 This is one of the flow charts of the information retrieval method provided by the embodiment of the present invention.

[0051] like Figure 1 As shown, an information retrieval method provided by an embodiment of the present invention includes the following steps:

[0052] 110. Get the statement to be queried.

[0053] In a specific implementation process, the query statement generally refers to a field or data, and the text related to the query statement is retrieved by obtaining the query statement.

[0054] 120. Based on a pre-trained retrieval model, output an ID having a textual correspondence relationship with the query sentence, wherein the retrieval model is trained based on a large number of text samples and IDs, and the retrieval model stores the textual correspondence relationship between each of the large number of text samples and IDs.

[0055] Specifically, the retrieval model outputs the ID of the text related to the query statement according to the query statement, and the text contains the query statement, or contains fields or data similar to the query statement.

[0056] Figure 2 This is one of the flow charts of the information retrieval method provided by the embodiment of the present invention.

[0057] like Figure 2 As shown in FIG. 1 , the process of pre-training the retrieval model specifically includes the following steps:

[0058] 210. Obtain massive text samples and use a pre-trained dense vector model to represent all text samples as dense vectors.

[0059] Specifically, the training process of the pre-trained dense vector model includes the following steps: determining a query sentence q and a positive example text d related to the query sentence q, randomly collecting negative example texts in the query corpus The query statement q, the positive example text d, and the text Input the pre-stored language model for training to obtain a dense vector model. Where n is a positive integer. During the training process, the text containing the query statement q or the data related to the query statement q is defined as the positive text, and the text not containing the query statement and the data related to the query statement q is defined as the negative text. During the model training process, first collect the positive text and the negative text as the basic data for model training.

[0060] In the present invention, supervised data is used to train a dense vector model. The specific details of model training are as follows: given a query q and a positive example text d related to q, firstly, an irrelevant negative example text is randomly sampled from the query corpus. Using the pre-trained language model, the vector representation of query q, related text d, and random text is obtained. The similarity between query q and text is calculated as the dot product of the vector. The loss function is used to measure the inconsistency between the model's predicted value f(x) and the true value Y. It is a non-negative real-valued function, usually represented by L(Y, f(x)). The smaller the loss function, the better the robustness of the model. The loss function is the core part of the empirical risk function and an important part of the structural risk function. The loss function of the dense vector model of the present invention is defined as:

[0061]

[0062] The dense vector model is trained through this process.

[0063] In this step, the dense vector model is trained using a pre-trained language model, which is trained on a large-scale corpus using a self-supervised learning mechanism. The training process is: mask some words in the sentence, and require the dense vector model to be trained to restore the masked words. The pre-trained model can learn rich language knowledge from large-scale unsupervised predictions, making up for the semantic similarity training in the existing technology and helping to improve the performance of the dense vector model in downstream tasks.

[0064] In the training of the dense vector model, a sequence is given and the dense vector model is required to output a target sequence. The sequence here can be the query q mentioned above, and the target sequence is the text d related to q mentioned above. The pre-training task of the sequence-to-sequence pre-training model is to mask part of the sentence content and require the model to generate the masked content. For example, the original sentence is "I love Beijing Tiananmen, the sun rises above Tiananmen", and by masking the sentence, "I love Beijing <x>, on Tiananmen Square <y>Input the masked sentence into the model, and ask the model to restore the masked content and output " <x>Tiananmen Square <y>sun".

[0065] 220. Based on the dense vector, cluster the massive text samples to obtain the path corresponding to each text sample. Specifically, in the field of machine learning, clustering refers to dividing a data set into different classes or clusters according to a certain standard, so that the similarity of data objects in the same cluster is as large as possible, and the difference of data objects in different clusters is as large as possible. That is, after clustering, data of the same class are gathered together as much as possible, and data of different classes are separated as much as possible. In the present invention, the dense vector of the massive text samples generated in step 210 is a data set.

[0066] In a specific implementation process, based on the dense vector of the text generated in step 210, the text samples are first clustered, which specifically includes the following steps:

[0067] Obtain dense vectors generated from massive text samples;

[0068] Cluster the dense vector into x subclasses according to the preset value x;

[0069] Cluster each of the newly generated x subclasses into x subclasses;

[0070] Cluster the subclasses multiple times until the number of texts in each newly generated subclass is less than the preset value x;

[0071] Wherein, the preset value x is a positive integer.

[0072] For example, when the number of text samples is 1000, x is 5, and the dense vector initially containing 1000 text samples is clustered into 5 subclasses, one of which contains 200 texts. The subclass with 200 texts is clustered again to obtain a subclass with 40 texts. The subclass with 40 texts is clustered again to obtain a subclass with 8 texts. The subclass with 8 texts is clustered again to obtain a subclass with a maximum of 4 texts. At this time, the number of texts in all subclasses is less than 5, so clustering can be stopped.

[0073] Figure 3 It is a schematic diagram of clustering in the information retrieval method provided by an embodiment of the present invention.

[0074] like Figure 3 As shown in the figure, based on the dense vector retrieval model, vectors are generated for all the texts in the corpus. Based on the vector, hierarchical text clustering is performed. First, the text is clustered into x classes, and then each class is continuously clustered into x classes until the number of texts in each subclass is less than x. Where x is a hyperparameter. For example, if x is set to 3, the process implements 2 layers of clustering. Then the text that is classified into category 2 in the first layer of clustering is clustered again. If it is classified into category 3. Then after two clusterings, the text is in the class labeled 23.

[0075] 230. Convert the paths obtained by clustering into IDs corresponding to the text samples. Specifically, the following steps are included:

[0076] The labels of each layer of clusters are obtained according to the clustering path, and the corresponding label combination of each layer of clusters is used as the initial ID;

[0077] The initial ID is iteratively optimized based on the retrieval model to be trained to generate an ID corresponding to each text sample.

[0078] Further, in Figure 3 In the example above, after two clusterings, the text is in the class labeled 23, and the text is the third in the 23 classes, so the ID of the text is 233. Therefore, hierarchical clustering sets a unique text ID for each text.

[0079] 240. Based on massive text samples and IDs corresponding to the massive text samples, memory training is performed on the retrieval model.

[0080] Specifically, based on the massive text samples and the IDs corresponding to the massive text samples, the retrieval model is trained for memory. In step 240, this step specifically includes the following steps:

[0081] Input massive text samples and the IDs corresponding to the massive text samples into the pre-trained language model; perform memory training on the retrieval model through the pre-trained language model to obtain an optimized retrieval model. Among them, the retrieval model is trained using a pre-trained language model, and the pre-trained language model is trained on a large-scale corpus using a self-supervised learning mechanism. The training process is: mask some words in the sentence, and require the retrieval model to be trained to restore the masked words. For example, the original sentence is "I love Beijing Tiananmen, the sun rises over Tiananmen", and by masking the sentence, we get "I love Beijing <x>, on Tiananmen Square <y>Input the masked sentence into the model, and ask the model to restore the masked content and output " <x>Tiananmen Square <y>The pre-trained model can learn rich language knowledge from large-scale unsupervised predictions, making up for the semantic similarity training in existing technologies and helping to improve the performance of retrieval models in downstream tasks.

[0082] Based on the text ID obtained in step 230, the retrieval model is trained so that the retrieval model can remember all the retrieval texts. In this step, the training goal of the retrieval model is that, given a text, the retrieval model is required to output the ID of the text.

[0083] Because the text IDs obtained by initialization are not the most suitable for the model, after several rounds of training, we use the retrieval model to update the IDs of all texts, that is, to regenerate IDs for all texts.

[0084] After the text ID is regenerated using the trained retrieval model, if different texts are assigned the same text ID, different IDs are assigned to these texts through the hierarchical clustering method in steps 220 and 230 .

[0085] Specifically, in step 230, the combination of labels corresponding to each layer of clustering is used as the initial ID, and then the following steps are included:

[0086] If it is determined that the initial IDs generated by different texts are the same, the pre-trained dense vector model is used to represent the different texts as dense vectors respectively.

[0087] Based on the dense vectors of different texts, cluster different texts respectively to obtain the paths corresponding to each text. Specifically, the clustering process is: obtain the dense vectors generated by different texts in the above; cluster the dense vectors generated by different texts into x subclasses; cluster each of the newly generated x subclasses into x subclasses; cluster the subclasses multiple times until the number of texts in each newly generated subclass is less than the preset value x; where x is a positive integer. For example, when the number of different texts is 1000, x is 5, and the dense vectors initially containing 1000 texts are clustered into 5 subclasses, one of which contains 200 texts, and then cluster the subclass with 200 texts to obtain a subclass with 40 texts, and then cluster the subclass with 40 texts to obtain a subclass with 8 texts, and then cluster the subclass with 8 texts to obtain a subclass with a maximum of 4 texts. At this time, the number of texts in all subclasses is less than 5, and clustering can be stopped.

[0088] The clustered paths are converted into optimized IDs corresponding to each text, and the optimized IDs are used as the initial IDs of each text. Specifically, through the clustering operation, each text has a unique path, which is converted into a new ID for a different text, overwriting the initially assigned ID.

[0089] By re-optimizing the text ID, text clustering is made more accurate, and the accuracy of retrieval by the retrieval model is improved.

[0090] After several rounds of iterations, we get a model that memorizes all retrieval expectations.

[0091] Furthermore, after step 240, the trained retrieval model is further adjusted and optimized, specifically: the model is fine-tuned using the query statement and related texts, that is, given a query, it is required to output the related text ID, and the text and text ID with large errors are adjusted, thereby completing further adjustment and optimization of the retrieval model, so that in the actual application process, the retrieval accuracy of the retrieval model is higher.

[0092] The present invention relates to the technical fields of machine learning, deep learning, information retrieval, and large-scale pre-trained language models. The technical problem to be solved is: how to efficiently use large-scale pre-trained language models, reduce the computational and storage overhead of retrieval models in retrieval scenarios, and improve the efficiency of using large-scale language models in retrieval.

[0093] In order to solve the above technical problems, the present invention provides an end-to-end large model retrieval algorithm, wherein the process of pre-training and optimizing the retrieval model includes the following steps:

[0094] A. Use contrastive learning to train a dense vector model and represent all texts as dense vectors;

[0095] B. Cluster the text based on the dense vector and initialize the clustered path as the text ID;

[0096] C. Perform retrieval model memory training. Given a text, the retrieval model is required to output the text ID. During the training process, the text ID is adjusted iteratively;

[0097] D. After the model is memorized, the corresponding data between queries and texts in real scenarios are used to fine-tune the retrieval model.

[0098] Most traditional text retrieval algorithms calculate similarity based on word matching, which often causes the model to ignore semantic similarity. Dense vector retrieval converts all text into vectors and calculates text similarity by calculating the dot product of the vectors. This corresponding technology is called dense vector retrieval. Dense vector retrieval trains the text encoding model through contrastive learning technology.

[0099] Given a query and related text, the model obtains irrelevant text from the corpus as negative examples. The objective function of training is to maximize the vector similarity between the query and the related text. Dense vector retrieval is computationally expensive and storage expensive. All the text to be retrieved needs to be encoded and the corresponding vectors stored. The vector representation of the query needs to be calculated during retrieval, and similarity calculation requires large-scale vector multiplication, which is computationally expensive.

[0100] Compared with the prior art, the present invention realizes end-to-end retrieval in large-scale retrieval corpus, thereby improving the retrieval speed and reducing the storage overhead. In this technology, the present invention proposes to use dense retrieval to initialize the text retrieval structure, inheriting the previous model knowledge. In addition, the present invention proposes a method for iteratively updating the text ID, which can make the text index structure and the text encoding adapt to the greatest extent.

[0101] The information retrieval device provided by the present invention is described below. The information retrieval device described below and the information retrieval method described above can be referenced to each other.

[0102] Figure 4 A schematic diagram of the physical structure of an information retrieval device is shown as an example. Figure 4 As shown, the information retrieval device includes: an acquisition module 41 and a query output module 42.

[0103] The acquisition module 41 is used to acquire the sentence to be queried. The query output module 42 is used to output an ID having a textual correspondence relationship with the sentence to be queried based on a pre-trained retrieval model.

[0104] Among them, the retrieval model is obtained based on massive text samples and ID training, and the text correspondence between each text sample and ID is stored in the retrieval model.

[0105] The process of pre-training and optimizing the retrieval model specifically includes: A. Using a contrastive learning scheme to train a dense vector model for generating text representations; B. Assigning a unique document ID to each document through clustering based on the generated text representations; C. Using a large-scale pre-trained language model to memorize all retrieval corpora; D. Using supervised retrieval data to fine-tune the retrieval model so that the retrieval model can input queries and directly output the IDs of related documents.

[0106] Figure 5 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other through the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the information retrieval method, which includes: 110, obtaining the sentence to be queried; 120, based on the pre-trained retrieval model, outputting an ID having a text correspondence relationship with the sentence to be queried. The retrieval model is obtained based on massive text samples and ID training, and the text correspondence relationship between each text sample and the ID is stored in the retrieval model. Furthermore, the process of pre-training the retrieval model specifically includes: 210. Obtaining massive text samples, and using a pre-trained dense vector model to represent all text samples as dense vectors; 220. Clustering the massive text samples based on the dense vectors to obtain the path corresponding to each text sample; 230. Converting the clustered paths into IDs corresponding to each text sample; 240. Based on the massive text samples and the IDs corresponding to the massive text samples, performing memory training on the retrieval model.

[0107] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0108] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the information retrieval method provided by the above methods, which includes: 110, obtaining a sentence to be queried; 120, based on a pre-trained retrieval model, outputting an ID having a textual correspondence relationship with the sentence to be queried. Among them, the retrieval model is obtained based on massive text samples and ID training, and the retrieval model stores the textual correspondence between each text sample and the ID. Further, the process of pre-training the retrieval model specifically includes: 210, obtaining massive text samples, and using a pre-trained dense vector model to represent all text samples as dense vectors; 220, based on dense vectors, clustering massive text samples to obtain paths corresponding to each text sample; 230, converting the clustered paths into IDs corresponding to each text sample; 240, based on massive text samples and IDs corresponding to massive text samples, memory training is performed on the retrieval model.

[0109] On the other hand, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it is implemented to execute the information retrieval method provided by the above methods, the method comprising: 110, obtaining a sentence to be queried; 120, based on a pre-trained retrieval model, outputting an ID having a textual correspondence relationship with the sentence to be queried. Among them, the retrieval model is obtained based on massive text samples and ID training, and the textual correspondence relationship between each text sample and the ID is stored in the retrieval model. Further, the process of pre-training the retrieval model specifically includes: 210, obtaining massive text samples, and using a pre-trained dense vector model to represent all text samples as dense vectors; 220, based on dense vectors, clustering massive text samples to obtain paths corresponding to each text sample; 230, converting the clustered paths into IDs corresponding to each text sample; 240, based on massive text samples and IDs corresponding to massive text samples, memory training is performed on the retrieval model.

[0110] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, i.e., they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative effort.

[0111] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.

[0112] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.< / y> < / x> < / y> < / x> < / y> < / x> < / y> < / x>

Claims

1. An information retrieval method, It is characterized in that include: Get the query statement to be queried; Based on the pre-trained retrieval model, output an ID having a textual correspondence with the query sentence; The retrieval model is obtained by training based on massive text samples and IDs, and the retrieval model stores the text correspondence between each of the massive text samples and IDs; The process of pre-training the retrieval model specifically includes: Obtaining the massive text samples, and using a pre-trained dense vector model to represent all the text samples as dense vectors; Based on the dense vector, clustering the massive text samples to obtain a path corresponding to each text sample; Convert the paths obtained by clustering into IDs corresponding to the text samples respectively; Based on the massive text samples and the IDs corresponding to the massive text samples, memory training is performed on the retrieval model; The training process of the pre-trained dense vector model specifically includes: Determine a query statement q and a positive example text d related to the query statement q; In the query corpus, randomly collect negative example texts The query statement q, the positive example text d, the text Inputting into a pre-stored language model for training to obtain the dense vector model; Wherein, n is a positive integer; Based on the dense vector, clustering the massive text samples specifically includes: Obtaining a dense vector generated by the massive text sample; Clustering the dense vector into x subclasses according to a preset value x; Cluster each of the newly generated x subclasses into x subclasses; Clustering the subclasses multiple times until the number of texts in each newly generated subclass is less than the preset value x; Wherein, the preset value x is a positive integer, The paths obtained by clustering are converted into IDs corresponding to the text samples, specifically including: The labels of each layer of clusters are obtained according to the clustering path, and the corresponding label combination of each layer of clusters is used as the initial ID; The initial ID is iteratively optimized based on the retrieval model to be trained to generate an ID corresponding to each of the text samples.

2. The information retrieval method according to claim 1, It is characterized in that The combination of labels corresponding to each layer of clustering is used as the initial ID, followed by: If it is determined that the initial IDs generated by different texts are the same, the different texts are represented as dense vectors respectively using the pre-trained dense vector model; Based on the dense vectors of different texts, cluster different texts separately to obtain the paths corresponding to each text; The paths obtained by clustering are converted into optimized IDs corresponding to the respective texts, and the optimized IDs are used as the initial IDs of the respective texts.

3. The information retrieval method according to claim 1, It is characterized in that The memory training of the retrieval model based on the massive text samples and the IDs corresponding to the massive text samples specifically includes: Inputting the massive text samples and the IDs corresponding to the massive text samples into a pre-trained language model; The retrieval model is memory-trained by using the pre-trained language model to obtain an optimized trained retrieval model.

4. An information retrieval device, It is characterized in that include: The acquisition module is used to obtain the query statement; A query output module, used for outputting an ID having a textual correspondence with the query statement based on a pre-trained retrieval model; The retrieval model is obtained by training based on massive text samples and IDs, and the retrieval model stores the text correspondence between each of the massive text samples and IDs; The process of pre-training the retrieval model specifically includes: Obtaining the massive text samples, and using a pre-trained dense vector model to represent all the text samples as dense vectors; Based on the dense vector, clustering the massive text samples to obtain a path corresponding to each text sample; Convert the paths obtained by clustering into IDs corresponding to the text samples respectively; Based on the massive text samples and the IDs corresponding to the massive text samples, memory training is performed on the retrieval model; The training process of the pre-trained dense vector model specifically includes: Determine a query statement q and a positive example text d related to the query statement q; In the query corpus, randomly collect negative example texts The query statement q, the positive example text d, the text Inputting into a pre-stored language model for training to obtain the dense vector model; Wherein, n is a positive integer; Based on the dense vector, clustering the massive text samples specifically includes: Obtaining a dense vector generated by the massive text sample; Clustering the dense vector into x subclasses according to a preset value x; Cluster each of the newly generated x subclasses into x subclasses; Clustering the subclasses multiple times until the number of texts in each newly generated subclass is less than the preset value x; Wherein, the preset value x is a positive integer, The paths obtained by clustering are converted into IDs corresponding to the text samples, specifically including: The labels of each layer of clusters are obtained according to the clustering path, and the corresponding label combination of each layer of clusters is used as the initial ID; The initial ID is iteratively optimized based on the retrieval model to be trained to generate an ID corresponding to each of the text samples.

5. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the information retrieval method according to any one of claims 1 to 3 is implemented.

6. A non-transitory computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the information retrieval method according to any one of claims 1 to 3 is implemented.