Information retrieval method, device, electronic device and storage medium

By determining the first word vector and the central word vector of the target vocabulary in the information retrieval model, the correlation between the query statement and the document is calculated, and the problem of low information retrieval accuracy in the prior art is solved, and higher information retrieval accuracy is achieved.

CN114238564BActive Publication Date: 2025-05-13阳光保险集团股份有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111495205.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-09
Publication Date
2025-05-13
Estimated Expiration
2041-12-09

AI Technical Summary

Technical Problem

The information retrieval method in the prior art is based on the matching algorithm of vocabulary frequency, and fails to effectively combine the semantic environment and the word meaning environment, resulting in low matching degree and accuracy of the search results.

Method used

Through the trained target information retrieval model, the first word vector of the target vocabulary in the target query statement and the central word vector in each target document are determined, and the correlation between the query statement and the target document is calculated using these vectors.

Benefits of technology

It improves the accuracy of information retrieval, so that the target query statement corresponding to the target vocabulary is more consistent with the semantics and word meanings of the search document.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114238564B_ABST
    Figure CN114238564B_ABST
Patent Text Reader

Abstract

The present application provides an information retrieval method, device, electronic device and storage medium. The information retrieval method determines the first word vector of the target vocabulary in the target query statement based on a trained target information retrieval model, and determines the central word vector of the target vocabulary in each target document. The first relevance between the query statement and the target document is determined based on the first word vector and the central word vector. Since the central word vector of the target vocabulary in the present application is determined based on multiple sliding windows in each target document, the target query statement corresponding to the target vocabulary is more closely matched with the semantics and word meaning of the retrieved document, thereby improving the accuracy of information retrieval.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of power grid optimization, and in particular to an information retrieval method, device, electronic device and storage medium. Background Art

[0002] The information retrieval method in the prior art is mainly to search the search text in the database based on the matching algorithm of word frequency. This information retrieval method based on word frequency is still the mainstream method of today's retrieval system. However, information retrieval based on word frequency only takes into account the number of times the word appears in the database, and does not combine the semantic environment and word meaning environment, resulting in a low matching degree and accuracy of the retrieved documents. Summary of the invention

[0003] In view of this, the purpose of the present application is to provide an information retrieval method, device, electronic device and storage medium. The present application determines the first word vector of the target vocabulary in the target query statement based on a trained target information retrieval model, and determines the central word vector of the target vocabulary in each target document. The first relevance between the query statement and the target document is determined according to the first word vector and the central word vector. Since the central word vector of the target vocabulary in the present application is determined based on multiple sliding windows in each target document, the target query statement corresponding to the target vocabulary is more matched with the semantics and word meaning of the retrieved document, thereby improving the accuracy of information retrieval.

[0004] The present invention provides an information retrieval method, which includes:

[0005] Inputting a target query statement into a query layer in a trained target information retrieval model to obtain at least one target vocabulary that is common between the target query statement and each target document in the text library; wherein the target document is a document in the text library that has the same vocabulary as the target query statement;

[0006] Input each of the target words obtained into the word vector extraction network layer in the trained target information retrieval model to obtain a first word vector of each of the target words in the target query sentence, and a second word vector of each of the target words in a sliding window in each of the target documents; the sliding window is a window containing adjacent first preset number of characters in the target document, and the sliding window contains at least one character in at least one of the target words; and the overlapping part between two adjacent sliding windows contains a second preset number of characters;

[0007] For any target word in each target document, determine the central word vector of the target word based on the second word vectors of each sliding window associated with the target word;

[0008] Inputting the first word vector and the center word vector corresponding to the target vocabulary of each target document into the relevance scoring layer in the trained target information retrieval model, and calculating the first relevance between the target query statement and each of the target documents;

[0009] According to the order of relevance between the target query statement and the multiple target documents from high to low, a preset number of the target documents are selected as the retrieval document output.

[0010] Further, for any target word in each target document, based on the second word vectors of each sliding window associated with the target word, determining the central word vector of the target word includes:

[0011] For any target word in each target document, obtain the second word vector of the target word in each sliding window;

[0012] A summation is performed on each of the second word vectors, and an average value is calculated after the summation, and the average value is determined as the central word vector of the target vocabulary.

[0013] Furthermore, the first relevance between the target query statement and each of the target documents is calculated in the following manner:

[0014] Performing a dot product calculation on the first word vector corresponding to each target word and each center word vector corresponding to each target word, and determining the dot product result as a second relevance between each target word and each target document;

[0015] A sum calculation is performed on each of the second relevances corresponding to each of the target words in each target document, and the sum result is determined as the first relevance between the target query statement and each of the target documents.

[0016] Further, performing a dot product calculation on the first word vector corresponding to each target word and each center word vector corresponding to each target word, and determining the dot product result as the second relevance between each target word and each target document, includes:

[0017] Perform a dot product calculation on the first word vector corresponding to each target word and each center word vector corresponding to each target word, and select the maximum dot product value as the result relevance;

[0018] The result relevance is determined as a second relevance between each of the target words and each of the target documents.

[0019] Further, the trained target information retrieval model is determined by the following method;

[0020] Obtaining a sample query statement and a sample document corresponding to the sample query statement;

[0021] The sample query statement and the sample document are divided according to a preset relevance, and the sample query statement and the sample document whose relevance is greater than or equal to the preset relevance are determined as sample-related texts, and the sample query statement and the sample document whose relevance is less than the preset relevance are determined as sample-irrelevant texts;

[0022] The initial information retrieval model is trained according to the sample-related text and the sample-irrelevant text, and a trained target information retrieval model is determined.

[0023] The present application also provides an information retrieval device, the information retrieval device comprising:

[0024] A first determination module is used to input a target query statement into a query layer in a trained target information retrieval model to obtain at least one target vocabulary that is common between the target query statement and each target document in the text library; wherein the target document is a document in the text library that has the same vocabulary as the target query statement;

[0025] The second determination module is used to input each of the target words obtained into the word vector extraction network layer in the trained target information retrieval model to obtain the first word vector of each of the target words in the target query sentence, and the second word vector of each of the target words in the sliding window in each of the target documents; the sliding window is a window containing adjacent first preset number of characters in the target document, and the sliding window contains at least one character in at least one of the target words; the overlapping part between two adjacent sliding windows contains a second preset number of characters;

[0026] A third determination module is used to determine, for any target word in each target document, a central word vector of the target word based on the second word vectors of each sliding window associated with the target word;

[0027] A calculation module, used for inputting the first word vector and the center word vector corresponding to the target vocabulary of each target document into the relevance scoring layer in the trained target information retrieval model, and calculating the first relevance between the target query statement and each of the target documents;

[0028] The fourth determination module is used to select a preset number of the target documents as retrieval document outputs according to the order of relevance between the target query statement and the multiple target documents from high to low.

[0029] Furthermore, the third determination module determines, for any target word in each target document, a central word vector of the target word based on the second word vectors of each sliding window associated with the target word, including:

[0030] For any target word in each target document, obtain the second word vector of the target word in each sliding window;

[0031] A summation is performed on each of the second word vectors, and an average value is calculated after the summation, and the average value is determined as the central word vector of the target vocabulary.

[0032] Furthermore, the calculation module calculates the first relevance between the target query statement and each of the target documents in the following manner:

[0033] Performing a dot product calculation on the first word vector corresponding to each target word and each center word vector corresponding to each target word, and determining the dot product result as a second relevance between each target word and each target document;

[0034] A sum calculation is performed on each of the second relevances corresponding to each of the target words in each target document, and the sum result is determined as the first relevance between the target query statement and each of the target documents.

[0035] An embodiment of the present application also provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the above-mentioned information retrieval method are performed.

[0036] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned information retrieval method are executed.

[0037] The information retrieval method, device, electronic device and storage medium provided in the embodiments of the present application, compared with the prior art, determine the first word vector of the target vocabulary in the target query statement based on a trained target information retrieval model, and determine the central word vector of the target vocabulary in each target document, and determine the first relevance between the query statement and the target document according to the first word vector and the central word vector. Since the central word vector of the target vocabulary in the present application is determined based on multiple sliding windows in each target document, the target query statement corresponding to the target vocabulary is more closely matched with the semantics and word meaning of the retrieved document, thereby improving the accuracy of information retrieval.

[0038] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0040] Figure 1 A flowchart of an information retrieval method provided by an embodiment of the present application is shown;

[0041] Figure 2 A structural diagram showing the relationship between a sliding window and a target document in an information retrieval method provided in an embodiment of the present application;

[0042] Figure 3 A flowchart of another information retrieval method provided by an embodiment of the present application is shown;

[0043] Figure 4 A schematic diagram of the structure of an information retrieval device provided in an embodiment of the present application is shown;

[0044] Figure 5 A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown.

[0045] In the figure:

[0046] 400 - information retrieval device; 410 - first determination module; 420 - second determination module; 430 - third determination module; 440 - calculation module; 450 - fourth determination module; 500 - electronic device; 510 - processor; 520 - memory; 530 - bus. DETAILED DESCRIPTION

[0047] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application usually described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, each other embodiment obtained by those skilled in the art without making creative work belongs to the scope of protection of the present application.

[0048] First, the application scenarios to which the present application can be applied are introduced. After research, it is found that the information retrieval method in the prior art is mainly based on the matching algorithm of word frequency to search the search text in the database. This information retrieval method based on word frequency is still the mainstream method of today's retrieval system. However, information retrieval based on word frequency only takes into account the number of times the word appears in the database, and does not combine the semantic environment and word meaning environment, resulting in a low matching degree and accuracy of the retrieved documents.

[0049] Based on this, the embodiments of the present application provide an information retrieval method, device, electronic device and storage medium. Based on a trained target information retrieval model, the first word vector of the target vocabulary in the target query statement is determined, and the central word vector of the target vocabulary in each target document is determined. The first relevance between the query statement and the target document is determined according to the first word vector and the central word vector. Since the central word vector of the target vocabulary in the present application is determined based on multiple sliding windows in each target document, the target query statement corresponding to the target vocabulary is more matched with the semantics and word meaning of the obtained retrieval document, thereby improving the accuracy of information retrieval.

[0050] See also Figure 1 , Figure 1 The following is a flow chart of an information retrieval method provided in an embodiment of the present application. Figure 1 As shown in , the information retrieval method provided by the embodiment of the present application includes:

[0051] S101. Input a target query statement into a query layer in a trained target information retrieval model to obtain at least one target vocabulary that is common between the target query statement and each target document in a text library; wherein the target document is a document in the text library that has the same vocabulary as the target query statement.

[0052] In this step, after the user generates a need to obtain a series of retrieval documents corresponding to the target query statement of the query, the target query statement is input into the query network layer of the trained target information retrieval model to obtain a target vocabulary between the target query statement and each target document in the text library. Here, the documents in the text library are screened, and those documents that have no association with the target query statement are eliminated, and documents in the text library that have the same vocabulary as the target query statement are screened out and determined as target documents.

[0053] Here, the target vocabulary is defined as the same word that exists in both the target query statement and the target document, and the number of characters of the target vocabulary is not unique. The division of the target vocabulary can be customized according to the expression characteristics of Chinese. In the embodiment provided in the present application, q is used to represent the target vocabulary, where qi represents the i-th marked target vocabulary, and the query network layer is used to represent the network structure layer used to determine the target vocabulary in the target information retrieval model.

[0054] The target information retrieval model is obtained by training the initial information retrieval model, and the trained target information retrieval model is determined by the following method;

[0055] A sample query statement and a sample document corresponding to the sample query statement are obtained.

[0056] Here, first, an initial sample query statement and an initial sample document corresponding to the initial sample query statement are obtained, the initial sample query statement is obtained from a log or other external sample database, and then the initial sample document corresponding to the initial sample query statement is manually labeled, the initial query statement and the initial sample document are denoised, and meaningless special characters such as spaces and garbled characters are deleted. Here, regular expressions are used for cleaning.

[0057] Among them, regular expression is a logical formula for string operation, which uses some pre-defined specific characters and the combination of these specific characters to form a "regular string". This "regular string" is used to express a filtering logic for the string.

[0058] The sample query statements and the sample documents are divided according to a preset relevance, and the sample query statements and the sample documents having a relevance greater than or equal to the preset relevance are determined to be sample-related texts, and the sample query statements and the sample documents having a relevance less than the preset relevance are determined to be sample-irrelevant texts.

[0059] In the above, the sample related text and the sample irrelevant text both include a sample training set and a sample verification set for training an initial information detection model, and the Python programming language is used to divide the sample query statements and sample documents according to a preset relevance, and the sample query statements and sample documents with a relevance greater than or equal to the preset relevance are taken as sample related texts, wherein the sample related texts are compared with the preset relevance by annotating the relevance of the sample query statements and the sample documents, and the sample query statements and sample documents with a relevance less than the preset relevance are taken as sample irrelevant texts, and the sample query statements and sample documents with a higher predicted relevance obtained according to the probabilistic retrieval algorithm but are actually irrelevant samples are determined as difficult irrelevant samples.

[0060] In this way, the probabilistic retrieval algorithm is an algorithm proposed based on the probabilistic retrieval model, and the probabilistic retrieval algorithm includes but is not limited to using the BM25 information retrieval algorithm.

[0061] The initial information retrieval model is trained according to the sample training set and the sample verification set to determine a trained target information retrieval model.

[0062] Here, the initial information retrieval model is trained according to the sample training set, and during the training process, the sample verification set is used to update and replace the network structure parameters in the initial information retrieval model in real time, thereby verifying the training effect of the initial information retrieval model. After the training is completed, the model documents in the trained target information retrieval model are stored accordingly to facilitate subsequent information retrieval tasks or reordering tasks of the target documents.

[0063] As mentioned above, the trained target information retrieval model can be applied to different online retrieval systems. Specifically, it is necessary to first use a document encoder to process the documents in the text library offline, implement preprocessing of the documents based on the target query statement, and delete some noise in the documents; then load the trained target information retrieval model into the retrieval system, and initialize the trained target information retrieval model. Next, input the denoised target query statement, and obtain a preset number of target documents corresponding to the target query statement as the retrieval document output.

[0064] Thirdly, the trained target information retrieval model can be used to recall other documents outside the text library and reorder other documents. The specific process is: first, load the trained target information retrieval model and initialize the trained target information retrieval model. Secondly, use the document encoder to process the documents in the text library offline. Then use the BM25 information retrieval algorithm in the search engine to recall a specified number of target documents in other text libraries outside the text library. Based on the initialized target information retrieval documents, perform relevance matching on the target documents outside the recalled text library, and output a preset number of target documents as recalled retrieval documents.

[0065] Among them, the structural diagram of the trained target information retrieval model is shown. Here, the initial information retrieval model is used to first encode the character string represented by the sample query statement and the character string represented by the sample document corresponding to the sample query statement, respectively. The initial information retrieval model in the embodiment provided in the present application can be a language model based on BERT encoding, but is not limited to the use of BERT encoding. Here, the Adam optimizer is used to fine-tune the BERT encoder to achieve the function of adjusting the parameters of the initial information retrieval model during the training process.

[0066] Among them, the negative log-likelihood function can be used to train the initial information retrieval model to determine the trained target information retrieval model. The likelihood function is a function of the parameters in the model. "Likelihood" and "probability" have similar meanings, but they have completely different meanings in statistics: probability is used to predict the next observation results when the parameters are known; likelihood is used to estimate the possible values ​​of the parameters of a given model based on some observation results.

[0067] Here, Token is used to represent a string of characters generated by sample query statements and sample documents, as a token for client requests. After the first login, the server generates a Token and returns the Token to the client. In the future, the client only needs to bring this Token to request data. Token can actually be more commonly called a code, that is, before some data is transmitted, the code must be checked first, and different codes are authorized for different data operations. In the embodiment provided in this application, Token is represented by any character or text in the sample query statement and sample document, that is, each sample query statement and each sample document contains multiple Tokens, and the number of Tokens depends on the number of characters or texts.

[0068] Here, the string Token is specifically represented as:

[0069]

[0070] here, is a matrix that maps the nlm-dimensional output of the initial information retrieval model to a low-dimensional nt vector. The trained target information retrieval model is an information retrieval model to which the [CLS] matching in the pre-trained language model (Bidirectional EncoderRepresentations from Transformers, BERT) is added. The pre-trained language model learns the deep bidirectional representation in unlabeled data through pre-training, and adding [CLS] to the pre-trained language model is to use the output character vector corresponding to the symbol as the semantic representation of the entire text or sentence.

[0071] Furthermore, the standard sample query text and the standard sample document corresponding to the standard sample query text are obtained in the following manner:

[0072] An initial sample query text and an initial standard sample document corresponding to the initial sample query text are obtained.

[0073] De-noising is performed on the initial sample query text and the initial standard sample document to determine a standard sample query text and a standard sample document.

[0074] S102. Input each of the target words obtained into the word vector extraction network layer in the trained target information retrieval model to obtain the first word vector of each of the target words in the target query sentence, and the second word vector of each of the target words in the sliding window in each of the target documents; the sliding window is a window containing adjacent first preset number of characters in the target document, and the sliding window contains at least one character of at least one of the target words; the overlapping part between two adjacent sliding windows contains a second preset number of characters.

[0075] In this step, each target word between the target query and each target document in the text library is input into the word vector extraction network layer in the trained target information retrieval model to obtain the first word vector of the target word in the target query and the second word vector of the above target word in the sliding window in each target document, wherein the first word vector is specifically expressed as follows based on the encoding of Token:

[0076]

[0077] Here, the English name of the target query statement is query, in which the abbreviation q is used to represent it. The string representing the target query statement of the i-th token, b tok is the coefficient, W tok are the coefficients in matrix form.

[0078] In addition, we need to consider the relevance of different target words in the target query sentence. We use the [CLS] matching in BERT to obtain the first word vector. The specific expression of the first word vector is:

[0079]

[0080] Here, the second word vector is specifically expressed based on the Token encoding as follows:

[0081]

[0082] Here, the English name of the target document is document, and the abbreviation d is used to represent it. The target document string for the i-th token, b tok is the coefficient.

[0083] In addition, we need to consider the relevance of different target words in the target query sentence. We use the [CLS] matching in BERT to obtain the second word vector. The specific expression of the second word vector is:

[0084]

[0085] In the above, and The correlation between them can provide high-level semantic matching information and alleviate the problem of vocabulary mismatch.

[0086] In this way, the sliding window is a window that slides in a preset direction in each target document, and the sliding window includes a first preset number of characters. Here, the setting of the first preset number is not fixed, and a custom number of characters can be set according to the expression characteristics of Chinese characters. Each sliding window includes at least one character in at least one target word, and the overlapping part of the second preset number of characters is included between two adjacent sliding windows. Here, in the embodiment part provided by the present application, the overlapping part of the second preset number of characters is set to one character. That is to say, when the sliding window slides in a preset direction in any target document, when the target word appears in a sliding window, its adjacent next sliding window is a sliding window that is one overlapping character away from the above sliding window.

[0087] like Figure 2 As shown, Figure 2 A structural diagram of the relationship between a sliding window and a target document in an information retrieval method provided in an embodiment of the present application.

[0088] Among them, it is set that the sliding window includes four characters, that is, the number of characters of the first preset number is four. For example, the target query statement provided in this embodiment is "Pride goes before a fall", and a target document in the corresponding text library is "As a Chinese, I am extremely proud of the women's volleyball team winning the Olympic championship".

[0089] Here, there is only one target word in the target query statement and the target document, and the target word is specifically "pride". At this time, all sliding windows that appear including any character "骄" or "傲" in the target word "pride" are obtained, and the encoder is used to obtain the second word vector based on semantics of the target word in each sliding window. The following is specifically represented Figure 2 The sliding windows including the target word "pride" are: "到无比骄", "无比骄傲", "比骄傲和", and "骄傲和自".

[0090] If there are multiple target words in the target document, the process of setting sliding windows for each target word is the same as the above process, and will not be elaborated here.

[0091] S103. For any target word in each target document, based on the second word vectors of each sliding window associated with the target word, determine the central word vector of the target word.

[0092] In this step, the second word vectors of each sliding window associated with any target word are summed and averaged to determine the central word vector of the target word in the target document.

[0093] In this way, the central word vector of the target word in the target document is represented by CK.

[0094] S104. Input the first word vector and the central word vector corresponding to the target word of each target document into the relevance scoring layer in the trained target information retrieval model, and calculate the first relevance between the target query statement and each target document.

[0095] In this step, after inputting the first word vector and the central word vector corresponding to the target word of each target document into the relevance calculation network layer in the trained target information retrieval model, a dot product calculation is performed for the first word vector corresponding to each target word and each central word vector corresponding to each target word, and the maximum dot product value is selected as the result relevance. The dot product result is determined as the second relevance between each target word and each target document.

[0096] Here, a summation calculation is performed for each of the second relevances corresponding to each target word in each target document, and the summation result is determined as the first relevance between the target query statement and each target document.

[0097] The expression for calculating the first relevance between the target query statement and each of the target documents is specifically:

[0098]

[0099] In the formula, q i ∈q∩d indicates that the target word of the i-th tag is the same word in the target query statement and the target document. Here, the maximum dot product value is selected, that is, the max operation is performed to capture the important semantic information of the above target word in the target document.

[0100] The above is a method for calculating the first relevance between the target query statement and each of the target documents without introducing the [CLS] matching method in BERT. The following formula is an expression for calculating the first relevance with the [CLS] matching method added:

[0101]

[0102] Where full represents the output of the relevance calculation network layer in the trained target information retrieval model with [CLS] matching added.

[0103] S105 , selecting a preset number of the target documents as retrieval document outputs in descending order of relevance between the target query statement and the multiple target documents.

[0104] In this step, when the user queries the target query statement, by inputting the target query statement into the trained target information retrieval model, a preset number of target documents sorted from high to low in terms of relevance will be output as retrieval document output. The retrieval documents here can be used as answer documents for the target query statement.

[0105] The information retrieval method provided in the embodiment of the present application is compared with the information retrieval method in the prior art. The present application determines the first word vector of the target vocabulary in the target query statement based on a trained target information retrieval model, and determines the central word vector of the target vocabulary in each target document. The first relevance between the query statement and the target document is determined according to the first word vector and the central word vector. Since the central word vector of the target vocabulary in the present application is determined based on multiple sliding windows in each target document, the target query statement corresponding to the target vocabulary is more closely matched with the semantics and word meaning of the retrieved document, thereby improving the accuracy of information retrieval.

[0106] See also Figure 3 , Figure 3 This is a flow chart of an information retrieval method provided by another embodiment of the present application. Figure 3 As shown in , the information retrieval method provided by the embodiment of the present application includes:

[0107] S201. Input a target query statement into a query layer in a trained target information retrieval model to obtain at least one target vocabulary that is common between the target query statement and each target document in a text library; wherein the target document is a document in the text library that has the same vocabulary as the target query statement.

[0108] S202. Input each of the target words obtained into the word vector extraction network layer in the trained target information retrieval model to obtain a first word vector for each of the target words in the target query statement, and a second word vector for each of the target words in a sliding window in each of the target documents; the sliding window is a window containing adjacent first preset number of characters in the target document, and the sliding window contains at least one character in at least one of the target words; and the overlapping part between two adjacent sliding windows contains a second preset number of characters.

[0109] S203: For any target word in each target document, obtain a second word vector of the target word in each sliding window.

[0110] In this step, for each target word in each target document, the second word vector of any target word in each sliding window is obtained.

[0111] Among them, in each target document, a window slides in a preset direction, and the sliding window includes a first preset number of characters. Here, the setting of the first preset number is not fixed, and a custom number of characters can be set according to the expression characteristics of Chinese characters. Each sliding window includes at least one character in at least one target word, and the overlapping part of the second preset number of characters is included between two adjacent sliding windows. Here, in the embodiment part provided by the present application, the overlapping part of the second preset number of characters is set to one character. That is to say, when the sliding window slides in a preset direction in any target document, when the target word appears in a sliding window, its adjacent next sliding window is a sliding window that is one overlapping character away from the above sliding window.

[0112] S204: performing a sum calculation on each of the second word vectors, and performing an average calculation after the sum calculation, and determining the average value as the central word vector of the target vocabulary.

[0113] In this step, the central word vector of each target word is obtained by summing and averaging the second word vectors of the sliding window.

[0114] S205, inputting the first word vector and the central word vector corresponding to the target vocabulary of each target document into the relevance scoring layer in the trained target information retrieval model, and calculating the first relevance between the target query statement and each of the target documents.

[0115] S206: Select a preset number of the target documents as retrieval document outputs in descending order of relevance between the target query statement and the multiple target documents.

[0116] Among them, the description of S201 to S202 and S205 to S206 can refer to the description of S101 to S102 and S104 to S105, and can achieve the same technical effect, which is not repeated here.

[0117] The information retrieval method provided in the embodiment of the present application is compared with the information retrieval method in the prior art. The present application determines the first word vector of the target vocabulary in the target query statement based on a trained target information retrieval model, and determines the central word vector of the target vocabulary in each target document. The first relevance between the query statement and the target document is determined according to the first word vector and the central word vector. Since the central word vector of the target vocabulary in the present application is determined based on multiple sliding windows in each target document, the target query statement corresponding to the target vocabulary is more closely matched with the semantics and word meaning of the retrieved document, thereby improving the accuracy of information retrieval.

[0118] See also Figure 4 , Figure 4 This is a schematic diagram of the structure of an information retrieval device provided in an embodiment of the present application. Figure 4 As shown in , the information retrieval device 400 includes:

[0119] The first determination module 410 is used to input the target query statement into the query layer of the trained target information retrieval model to obtain at least one target vocabulary that is the same between the target query statement and each target document in the text library; wherein the target document is a document in the text library that has the same vocabulary as the target query statement.

[0120] The second determination module 420 is used to input each of the target words obtained into the word vector extraction network layer in the trained target information retrieval model to obtain the first word vector of each of the target words in the target query sentence, and the second word vector of each of the target words in the sliding window in each of the target documents; the sliding window is a window containing adjacent first preset number of characters in the target document, and the sliding window contains at least one character of at least one of the target words; the overlapping part between two adjacent sliding windows contains a second preset number of characters.

[0121] The third determination module 430 is used to determine, for any target word in each target document, a central word vector of the target word based on the second word vectors of each sliding window associated with the target word.

[0122] Furthermore, in the third determination module, for any target word in each target document, based on the second word vectors of each sliding window associated with the target word, the central word vector of the target word is determined, including:

[0123] For any target word in each target document, obtain the second word vector of the target word in each sliding window.

[0124] A summation is performed on each of the second word vectors, and an average value is calculated after the summation, and the average value is determined as the central word vector of the target vocabulary.

[0125] The calculation module 440 is used to input the first word vector and the central word vector corresponding to the target vocabulary of each target document into the relevance scoring layer in the trained target information retrieval model, and calculate the first relevance between the target query statement and each of the target documents.

[0126] Furthermore, the calculation module 440 calculates the first relevance between the target query statement and each of the target documents in the following manner:

[0127] A dot product calculation is performed on the first word vector corresponding to each target word and each central word vector corresponding to each of the target words, and the dot product result is determined as the second relevance between each of the target words and each of the target documents.

[0128] A sum calculation is performed on each of the second relevances corresponding to each of the target words in each target document, and the sum result is determined as the first relevance between the target query statement and each of the target documents.

[0129] The fourth determination module 440 is used to select a preset number of the target documents as retrieved documents to be outputted according to the order of relevance between the target query statement and the multiple target documents from high to low.

[0130] The information retrieval device 400 provided in the embodiment of the present application is compared with that in the prior art. The information retrieval method provided in the embodiment of the present application is compared with that in the prior art. The present application determines the first word vector of the target vocabulary in the target query statement based on a trained target information retrieval model, and determines the central word vector of the target vocabulary in each target document. The first relevance between the query statement and the target document is determined according to the first word vector and the central word vector. Since the central word vector of the target vocabulary in the present application is determined based on multiple sliding windows in each target document, the target query statement corresponding to the target vocabulary is more closely matched with the semantics and word meaning of the retrieved document, thereby improving the accuracy of information retrieval.

[0131] See also Figure 5 , Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 5 As shown in , the electronic device 500 includes a processor 510 , a memory 520 and a bus 530 .

[0132] The memory 520 stores machine-readable instructions executable by the processor 510. When the electronic device 500 is running, the processor 510 communicates with the memory 520 via the bus 530. When the machine-readable instructions are executed by the processor 510, the above-mentioned Figure 1 as well as Figure 4 The specific implementation of the steps of the information retrieval method in the method embodiment shown can be found in the method embodiment, which will not be repeated here.

[0133] The present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the computer program can execute the above-mentioned Figure 1 as well as Figure 4 The specific implementation of the steps of the information retrieval method in the method embodiment shown can be found in the method embodiment, which will not be repeated here.

[0134] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0135] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0136] 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, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0137] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0138] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application can essentially be embodied in the form of a software product, or in other words, the part that contributes to the prior art or the part of the technical solution. The computer software product is stored in a storage medium, including several 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 method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0139] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-mentioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-mentioned embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. An information retrieval method, characterized in that: The information retrieval method comprises: Inputting a target query statement into a query layer in a trained target information retrieval model to obtain at least one target vocabulary that is common between the target query statement and each target document in the text library; wherein the target document is a document in the text library that has the same vocabulary as the target query statement; Input each of the target words obtained into the word vector extraction network layer in the trained target information retrieval model to obtain a first word vector of each of the target words in the target query sentence, and a second word vector of each of the target words in a sliding window in each of the target documents; the sliding window is a window containing adjacent first preset number of characters in the target document, and the sliding window contains at least one character in at least one of the target words; and the overlapping part between two adjacent sliding windows contains a second preset number of characters; For any target word in each target document, determine the central word vector of the target word based on the second word vectors of each sliding window associated with the target word; Inputting the first word vector and the center word vector corresponding to the target vocabulary of each target document into the relevance scoring layer in the trained target information retrieval model, and calculating the first relevance between the target query statement and each of the target documents; Selecting a preset number of target documents as retrieval document outputs according to the order of relevance between the target query statement and the multiple target documents from high to low; Among them, the trained target information retrieval model is determined by the following method: Obtaining a sample query statement and a sample document corresponding to the sample query statement; The sample query statement and the sample document are divided according to a preset relevance, and the sample query statement and the sample document whose relevance is greater than or equal to the preset relevance are determined as sample-related texts, and the sample query statement and the sample document whose relevance is less than the preset relevance are determined as sample-irrelevant texts; The initial information retrieval model is trained according to the sample-related text and the sample-irrelevant text, and a trained target information retrieval model is determined.

2. The information retrieval method according to claim 1, characterized in that: The step of determining, for any target word in each target document, a central word vector of the target word based on the second word vectors of each sliding window associated with the target word, comprises: For any target word in each target document, obtain the second word vector of the target word in each sliding window; A summation is performed on each of the second word vectors, and an average value is calculated after the summation, and the average value is determined as the central word vector of the target vocabulary.

3. The information retrieval method according to claim 1, characterized in that: The first relevance between the target query statement and each of the target documents is calculated in the following manner: Performing a dot product calculation on the first word vector corresponding to each target word and each center word vector corresponding to each target word, and determining the dot product result as a second relevance between each target word and each target document; A sum calculation is performed on each of the second relevances corresponding to each of the target words in each target document, and the sum result is determined as the first relevance between the target query statement and each of the target documents.

4. The information retrieval method according to claim 3, characterized in that: The step of performing a dot product calculation on the first word vector corresponding to each target word and each center word vector corresponding to each target word, and determining the dot product result as the second relevance between each target word and each target document, comprises: Perform a dot product calculation on the first word vector corresponding to each target word and each center word vector corresponding to each target word, and select the maximum dot product value as the result relevance; The result relevance is determined as a second relevance between each of the target words and each of the target documents.

5. An information retrieval device, characterized in that: The information retrieval device comprises: The first determination module is used to input the target query statement into the query layer of the trained target information retrieval model to obtain at least one target vocabulary that is the same between the target query statement and each target document in the text library; wherein the target document is a document in the text library that has the same vocabulary as the target query statement; wherein the trained target information retrieval model is determined by: Obtaining a sample query statement and a sample document corresponding to the sample query statement; The sample query statement and the sample document are divided according to a preset relevance, and the sample query statement and the sample document whose relevance is greater than or equal to the preset relevance are determined as sample-related texts, and the sample query statement and the sample document whose relevance is less than the preset relevance are determined as sample-irrelevant texts; Training an initial information retrieval model according to the sample-related text and the sample-irrelevant text, and determining a trained target information retrieval model; The second determination module is used to input each of the target words obtained into the word vector extraction network layer in the trained target information retrieval model to obtain the first word vector of each of the target words in the target query sentence, and the second word vector of each of the target words in the sliding window in each of the target documents; the sliding window is a window containing adjacent first preset number of characters in the target document, and the sliding window contains at least one character in at least one of the target words; the overlapping part between two adjacent sliding windows contains a second preset number of characters; A third determination module is used to determine, for any target word in each target document, a central word vector of the target word based on the second word vectors of each sliding window associated with the target word; A calculation module, used for inputting the first word vector and the center word vector corresponding to the target vocabulary of each target document into the relevance scoring layer in the trained target information retrieval model, and calculating the first relevance between the target query statement and each of the target documents; The fourth determination module is used to select a preset number of the target documents as retrieval document outputs according to the order of relevance between the target query statement and the multiple target documents from high to low.

6. The information retrieval device according to claim 5, characterized in that: The third determination module determines, for any target word in each target document, a central word vector of the target word based on the second word vectors of each sliding window associated with the target word, including: For any target word in each target document, obtain the second word vector of the target word in each sliding window; A summation is performed on each of the second word vectors, and an average value is calculated after the summation, and the average value is determined as the central word vector of the target vocabulary.

7. The information retrieval device according to claim 5, characterized in that: The calculation module calculates the first relevance between the target query statement and each of the target documents in the following manner: Performing a dot product calculation on the first word vector corresponding to each target word and each center word vector corresponding to each target word, and determining the dot product result as a second relevance between each target word and each target document; A sum calculation is performed on each of the second relevances corresponding to each of the target words in each target document, and the sum result is determined as the first relevance between the target query statement and each of the target documents.

8. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and the machine-readable instructions are executed by the processor to perform the steps of the information retrieval method as described in any one of claims 1 to 4 above.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the information retrieval method as described in any one of claims 1 to 4 are executed.

Citation Information

Patent Citations

  • Enhanced spurious correlation feedback model information retrieval method based on hyperspace simulation language

    CN108520033A

  • Speech-based retrieval method, server, and computer-readable storage medium

    CN109522392A