Information retrieval method and device
Through entity matching and semantic sorting between the policy map knowledge base and the text to be retrieved, the problem of search engines not being able to find and incomplete searches in policy scenarios is solved, and more accurate and comprehensive search results are returned.
Patent Information
- Application Number
- CN202011004734.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-22
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2040-09-22
AI Technical Summary
Existing search engines are prone to problems such as unavailability, inaccurate search, and incomplete search in search policy scenarios. In particular, they cannot solve the dilemma of semantic search due to their reliance on keyword matching.
The policy graph knowledge base is used to match entities in the text to be retrieved, and the word frequency inverse text frequency algorithm and the transformer-based bidirectional coding representation model are combined to identify named entities and content entities, and improve the accuracy of retrieval results through semantic sorting.
It improves the comprehensiveness and accuracy of search results, solves semantic search problems, and makes search results more in line with users' search expectations.
Smart Images

Figure CN112182239B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to an information retrieval method and device. Background Art
[0002] In the scenario of searching for policies, users often face the situation of not being able to search, searching inaccurately, or searching incompletely. The main reason is that most search engines segment the words according to the user's search sentence, and then use the several words obtained after segmentation as keywords for search. If the words entered by the user do not appear in the full text, the search will not return any results. This method relies on the accuracy of the search terms, and the probability of daily life terms being written into policies as official documents is very small, which leads to search difficulties. In addition, the retrieval method using keyword matching cannot solve the dilemma of semantic search. Summary of the invention
[0003] In view of this, an embodiment of the present invention provides an information retrieval method and device, which can utilize the policy graph knowledge base to enhance the existing policy retrieval scheme, solve the problem that the existing technology cannot search or search completely, can return more comprehensive and accurate search results to users, and improve the retrieval accuracy; sort the retrieval results according to the relevance of the text to be retrieved and the retrieval results and the semantics of the text to be retrieved, which not only solves the semantic problems that cannot be solved in the existing technology, but also makes the sorting of the retrieval results more in line with the user's search expectations.
[0004] To achieve the above object, according to one aspect of an embodiment of the present invention, there is provided an information retrieval method, comprising:
[0005] Get the text to be retrieved;
[0006] Identifying entities to be retrieved in the text to be retrieved;
[0007] The entity to be searched is matched with entities in a preset policy graph knowledge base to obtain multiple search results corresponding to the text to be searched, and a first result set is obtained based on the multiple search results.
[0008] Optionally, the entities to be retrieved include named entities to be retrieved and content entities to be retrieved;
[0009] Identifying the entity to be retrieved in the text to be retrieved includes:
[0010] Using a preset recognition model to identify the named entities to be retrieved in the text to be retrieved;
[0011] The word frequency inverse text frequency algorithm is used to determine the content entity to be retrieved in the text to be retrieved.
[0012] Optionally, the method further comprises obtaining the preset recognition model according to the following process:
[0013] Acquire training data, and annotate samples in the training data to annotate named entities of the samples;
[0014] The labeled training data is input into a preset transformer-based bidirectional coding representation model to obtain word vectors of the labeled training data, and the word vectors are trained to obtain the preset recognition model.
[0015] Optionally, labeling the samples in the training data includes: labeling the samples in the training data in BIO format, wherein B represents the beginning part of the named entity, I represents the middle part of the named entity or the end part of the named entity, and O represents other parts.
[0016] Optionally, the method further comprises obtaining the policy graph knowledge base according to the following process:
[0017] Acquire policy corpus; determine named entities, content entities and the relationship between the named entities in the policy corpus; acquire a general knowledge base; merge the named entities, content entities and the relationship between the named entities in the policy corpus with the general knowledge base to obtain a policy graph knowledge base.
[0018] Optionally, the method also includes: after marking the named entities in the training data, determining the relationship between the marked named entities; inputting the marked training data into a preset transformer-based bidirectional encoding representation model to obtain sentence vectors of the marked training data, training the sentence vectors, and obtaining a relationship classification model; determining the relationship between the named entities in the policy corpus includes: using the relationship classification model to determine the relationship between the named entities.
[0019] Optionally, the named entity includes one or more of the following: time, place, organization, audience, industry and policy.
[0020] Optionally, the relationship between policies includes one or more of the following: basis, abolition, revision, mention, reply, implementation, and forwarding; the relationship between policies and time includes release; the relationship between policies and institutions includes release and effect; the relationship between policies and locations is effect; the relationship between policies and audiences includes involvement; the relationship between policies and industries includes involvement.
[0021] Optionally, after obtaining the first result set, the method further includes: sorting the multiple search results in the first result set.
[0022] Optionally, sorting the multiple search results includes: classifying the text to be searched to determine the semantics of the text to be searched; and sorting the multiple search results according to the semantics.
[0023] Optionally, the semantics include one or more of the following: definition retrieval, policy retrieval and matter retrieval.
[0024] Optionally, sorting the multiple search results according to the semantics includes: using a preset relevance algorithm to calculate the relevance of each search result with the text to be searched; determining the search result corresponding to the semantics from the multiple search results, and updating the relevance of the search result corresponding to the semantics; and sorting the multiple search results according to the relevance.
[0025] Optionally, after obtaining multiple search results corresponding to the text to be searched, the method also includes: inputting the text to be searched into a preset search engine to obtain multiple search results, and obtaining a second result set based on the multiple search results; determining the intersection of the first result set and the second result set, and taking the intersection of the first result set and the second result set as the third result set.
[0026] Optionally, after obtaining the third result set, the method further includes:
[0027] Performing knowledge expansion on the text to be searched to obtain synonymous search statements corresponding to the text to be searched;
[0028] Inputting the synonymous search statement into the preset search engine to obtain a fourth result set corresponding to the synonymous search statement;
[0029] Determine an intersection of the first result set and the fourth result set, and use the intersection of the first result set and the fourth result set as a fifth result set;
[0030] The fourth result set is merged with the fifth result set to obtain a sixth result set, and the sixth result set is output for display.
[0031] To achieve the above object, according to another aspect of an embodiment of the present invention, there is provided an information retrieval device, comprising:
[0032] An acquisition module is used to acquire the text to be retrieved;
[0033] An entity recognition module, using a preset recognition model, recognizes the entity to be retrieved in the text to be retrieved;
[0034] The retrieval module is used to match the entity to be retrieved with the named entity in the preset policy graph knowledge base, obtain multiple retrieval results corresponding to the text to be retrieved, and obtain a first result set based on the multiple searches.
[0035] Optionally, the entities to be retrieved include named entities to be retrieved and content entities to be retrieved;
[0036] The entity recognition module is also used to: use a preset recognition model to identify the named entities to be retrieved in the text to be retrieved; and use a word frequency inverse text frequency algorithm to determine the content entities to be retrieved in the text to be retrieved.
[0037] Optionally, the device also includes a training module for acquiring training data and annotating samples in the training data to mark the named entities of the samples; inputting the annotated training data into a preset transformer-based bidirectional coding representation model to obtain word vectors of the annotated training data, training the word vectors, and obtaining the preset recognition model.
[0038] Optionally, the training module is further used to: label samples in the training data in BIO format, wherein B represents the beginning part of a named entity, I represents the middle part of a named entity or the end part of a named entity, and O represents other parts.
[0039] Optionally, the device also includes a policy graph knowledge base construction module, which is used to: obtain policy corpus; determine the named entities, content entities and the relationship between the named entities in the policy corpus; obtain a general knowledge base; and merge the named entities, content entities and the relationship between the named entities in the policy corpus with the general knowledge base to obtain a policy graph knowledge base.
[0040] Optionally, the training module is further used to: after marking the named entities in the training data, determine the relationship between the marked named entities; input the marked training data into a preset transformer-based bidirectional encoding representation model to obtain sentence vectors of the marked training data, train the sentence vectors, and obtain a relationship classification model;
[0041] The policy graph knowledge base construction module is also used to determine the relationship between the named entities using the relationship classification model.
[0042] Optionally, the entity includes a named entity and a content entity, and the named entity includes one or more of the following: time, place, organization, audience, industry, and policy.
[0043] Optionally, the relationship between policies includes one or more of the following: basis, abolition, revision, mention, reply, implementation, and forwarding; the relationship between policies and time includes release; the relationship between policies and institutions includes release and effect; the relationship between policies and locations is effect; the relationship between policies and audiences includes involvement; the relationship between policies and industries includes involvement.
[0044] Optionally, the device further comprises a sorting module for sorting the multiple search results in the first result set.
[0045] Optionally, the sorting module is further used to: classify the text to be retrieved to determine the semantics of the text to be retrieved; and sort the multiple search results according to the semantics.
[0046] Optionally, the semantics include one or more of the following: definition retrieval, policy retrieval and matter retrieval.
[0047] Optionally, the sorting module is also used to: use a preset relevance algorithm to calculate the relevance of each search result with the text to be searched; determine the search result corresponding to the semantics from the multiple search results, and update the relevance of the search result corresponding to the semantics; and sort the multiple search results according to the relevance.
[0048] Optionally, the retrieval module is also used to: input the text to be searched into a preset search engine to obtain multiple search results, and obtain a second result set based on the multiple search results; determine the intersection of the first result set and the second result set, and use the intersection of the first result set and the second result set as the third result set.
[0049] Optionally, the retrieval module is also used to: perform knowledge expansion on the text to be retrieved to obtain synonymous search statements corresponding to the text to be retrieved; input the synonymous search statements into the preset search engine to obtain a fourth result set corresponding to the synonymous search statements; determine the intersection of the first result set and the fourth result set, and use the intersection of the first result set and the fourth result set as the fifth result set; merge the fourth result set with the fifth result set to obtain a sixth result set.
[0050] To achieve the above-mentioned purpose, according to another aspect of an embodiment of the present invention, there is provided an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the information retrieval method of an embodiment of the present invention.
[0051] To achieve the above objective, according to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the information retrieval method of the embodiment of the present invention is implemented.
[0052] An embodiment of the above invention has the following advantages or beneficial effects: because it adopts the method of obtaining the text to be searched; identifying the entities to be searched in the text to be searched; matching the entities to be searched with the entities in the preset graph database policy graph knowledge base, obtaining multiple search results corresponding to the text to be searched, and obtaining the technical means of the first result set based on the multiple searches, that is, enhancing the existing policy retrieval scheme by using the policy graph knowledge base, so the problem that the existing technology cannot search or search completely is solved, and more comprehensive and accurate search results can be returned to users, and the retrieval accuracy is improved; the retrieval results are sorted according to the relevance of the text to be searched and the retrieval results and the semantics of the text to be searched, which not only solves the semantic problems that cannot be solved in the existing technology, but also makes the sorting of the retrieval results more in line with the user's search expectations.
[0053] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0055] Figure 1 is a schematic diagram of the main process of the information retrieval method according to an embodiment of the present invention;
[0056] Figure 2 is an example of a policy graph knowledge base in the information retrieval method of an embodiment of the present invention;
[0057] Figure 3 is a schematic diagram of the main process of the information retrieval method according to another embodiment of the present invention;
[0058] Figure 4 is a schematic diagram of the main process of the information retrieval method of another embodiment of the present invention;
[0059] Figure 5 is a schematic diagram of main modules of the information retrieval device according to an embodiment of the present invention;
[0060] Figure 6 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0061] Figure 7 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0062] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0063] Figure 1 FIG. 1 is a flow chart of the main steps of the information retrieval method according to an embodiment of the present invention. Figure 1 As shown, the method includes:
[0064] Step S101: obtaining the text to be searched;
[0065] Step S102: identifying entities to be searched in the text to be searched;
[0066] Step S103: Match the entity to be searched with the entity in the preset policy graph knowledge base to obtain multiple search results corresponding to the text to be searched, and obtain a first result set based on the multiple search results.
[0067] For step S101, the text to be searched may be a search sentence input by a user, or a search sentence converted by voice.
[0068] For step S102, the entities to be retrieved include named entities to be retrieved and content entities to be retrieved.
[0069] Among them, a named entity refers to an entity identified by a name. In this embodiment, the named entity includes one or more of the following: time, place, organization, audience, industry, and policy. Among them, the audience refers to the recipient of information dissemination, such as small and micro enterprises. Content entities include proper nouns, such as social security card, social security card, driver's license, and motor vehicle driver's license.
[0070] In an optional embodiment, identifying the entity to be retrieved in the text to be retrieved includes:
[0071] Using a preset recognition model to identify the named entities to be retrieved in the text to be retrieved;
[0072] The word frequency inverse text frequency algorithm is used to determine the content entity to be retrieved in the text to be retrieved.
[0073] Specifically, the preset recognition model can be pre-trained. The training process may include data annotation, model training, and model verification. Among them, data annotation includes: obtaining training data and annotating samples in the training data to mark the named entities of the samples. More specifically, the samples in the training data can be annotated in the BIO format, where B represents the start part of the named entity, I represents the middle part or the end part of the named entity, and O represents other parts. For example, if the sample is "A is a fintech company", "A" is marked as the start part of the named entity, "fintech" is marked as the middle part of the named entity, "company" is marked as the end part of the named entity, and "is", "a" are marked as other parts respectively. Then the marked sequence is: [B-ORG, O, O, O, B-TARGET, I-TARGET, I-TARGET, I-TARGET, I-TARGET, I-TARGET]. For model training, in this embodiment, the TensorFlow framework is used to train the pre-trained model, and the pre-trained model is obtained by adding a fully connected layer to the bidirectional encoder representations from transformers (BERT) model. Among them, the TensorFlow framework is a symbolic mathematics system based on dataflow programming and is widely used in the programming implementation of various machine learning algorithms. The bidirectional encoder representations from transformers (BERT) model adopts a bidirectional Transformer design and has been pre-trained with a large-scale corpus. Therefore, when performing downstream natural language recognition tasks, the model can converge with only a few steps and has good generality. The input of the BERT model is a set of sequences, and the output is a set of sequences. For example, if the input statement is: [A, is, a, fintech, company], the output is: [<CLS>, s0, s1, s2, s3, s4, s5, s6, s7, s8, <SEP>], and each vector in the output sequence is a 768-dimensional vector. Among them, <CLS> represents the sentence vector of the input statement and can be used for tasks such as determining the relationship between named entities. s0 to s8 represent the word vectors corresponding to each word and can be used for named entity recognition tasks, that is, training the word vectors can obtain the preset recognition model. <SEP> represents the full stop symbol. The fully connected layer plays the role of a "classifier" in the entire convolutional neural network. For model verification, the performance of the trained recognition model can be verified through test data. In an alternative embodiment, the original data set can be split into training data and test data.
[0074] Term Frequency-Inverse Document Frequency (TF-IDF) is a commonly used weighting technique for information retrieval and text mining, which can be used to evaluate the importance of a word to a document in a document set or corpus. The importance of a word increases in direct proportion to the number of times it appears in a document, but at the same time decreases in inverse proportion to the frequency of its appearance in the corpus. In this embodiment, Wikipedia in the prior art can be used as a document set or corpus. When identifying content entities in the text to be retrieved, it is necessary to use a bigram (binary word segmentation) algorithm to group every two words in the text to be retrieved into a word, and then use the term frequency-inverse text frequency algorithm to determine the content entity.
[0075] For step S103, the entities in the preset policy graph knowledge base include named entities and content entities, and the named entities include one or more of the following: time, place, organization, audience, industry, and policy. The content entities include proper nouns.
[0076] In an optional embodiment, the policy graph knowledge base can be obtained according to the following process: obtaining policy corpus; determining named entities, content entities and the relationships between the named entities in the policy corpus; obtaining a general knowledge base; fusing the named entities, content entities and the relationships between the named entities in the policy corpus with the general knowledge base to obtain a policy graph knowledge base.
[0077] Among them, the policy text data can be obtained on the Internet, and the policy text data can be cleaned, such as deduplication, removal of HTML tags, etc., to obtain the policy corpus. HTML (HyperText Markup Language) is a standard markup language for creating web pages. The named entities in the policy corpus can be identified by a preset recognition model, the content entities in the policy corpus can be determined by using a word frequency inverse text frequency algorithm, and the relationship between the named entities can be determined by using a relationship classification model. The relationship classification model can be trained when training the preset recognition model. Specifically, after marking the named entities in the training data, the relationship between the marked named entities is determined; the marked training data is input into a preset transformer-based bidirectional encoding representation model to obtain the sentence vector of the marked training data, and the sentence vector is trained to obtain the relationship classification model. In an optional embodiment, the definition of the proper nouns in the policy expectation can be marked. For example, "small and micro enterprises refer to enterprises that meet XXXX", "small and micro enterprises" are marked as audience entities, and the content after "refers to" is used as the definition of small and micro enterprises.
[0078] In this embodiment, the relationships between named entities include: relationships between policies, relationships between policies and time, relationships between policies and institutions, relationships between policies and places, relationships between policies and audiences, and relationships between policies and industries. Among them, the relationships between policies include one or more of the following: based on, abolished, revised, mentioned, replied, implemented, forwarded; the relationship between policies and time includes release; the relationship between policies and institutions includes release and effect; the relationship between policies and places is effect; the relationship between policies and audiences includes involvement; the relationship between policies and industries includes involvement. Examples of the relationship between the above policies are as follows: (1) Based on: The scope of R&D expenses referred to in this notice shall be implemented in accordance with the provisions of the "Target Policy"; (2) Repeal: This notice shall be implemented from the date of issuance, and the "Target Policy" shall be repealed at the same time; (3) Revision: Our bureau has revised the "Target Policy"; (4) Mention: In April 2017, the Ministry of Finance and the Ministry of Agriculture jointly issued the "Target Policy" and repealed the "Other Policies"; (5) Reply: National Development and Reform Commission, Ministry of Finance: We have received your "Target Policy"; (6) Implementation: Medical institutions must strictly implement the requirements of the "Target Policy" and "Other Policies"; (7) Forward: Now The "Target Policy" (hereinafter referred to as the "Notice") is forwarded to you. It is worth noting that the relationship extraction result between policies is a one-to-many extraction, that is, all policy entities {P} appearing in a policy A are extracted and the relationship is judged. In order to accurately judge the relationship between each policy entity P and handle the situation where multiple policies appear in a sentence, the policy entity will be replaced after it is extracted. After the policy is replaced with the target policy, the relationship classification model will classify the sentence and predict the relationship result of this sentence to the target policy. Other policies in this sentence will be represented as other policies, and the results will be integrated after the prediction is completed.
[0079] In this embodiment, a general knowledge base can be formed from encyclopedia data on the Internet. After obtaining the general knowledge base, the content entities in the policy corpus are merged with the general knowledge base to determine the content entities related to the policy corpus. The above-mentioned named entities, content entities, and the relationship between the named entities are stored to obtain a preset policy map knowledge base. Figure 2 It is an example of the policy graph knowledge base of an embodiment of the present invention.
[0080] In an optional embodiment, after obtaining the first result set, the method further includes: sorting the multiple search results in the first result set.
[0081] Specifically, sorting the multiple search results includes:
[0082] Classifying the text to be retrieved to determine the semantics of the text to be retrieved;
[0083] The multiple search results are sorted according to the semantics.
[0084] Among them, the semantics include one or more of the following: definition search, policy search and matter search. In an embodiment of the present invention, the semantics of the text to be searched is determined to determine the user's search purpose. When the semantics of the text to be searched is determined to be a definition search, it means that the user needs to understand the definition of the proper noun. For example, when a policy mentions that "small and micro enterprises can temporarily postpone the payment of social security during the epidemic", the user wants to know what kind of enterprise is a small and micro enterprise. At this time, the entity and definition in the policy graph knowledge base are returned. When the semantics of the text to be searched is determined to be a policy search, it means that the user needs to query some policies under certain conditions, and the returned result is a policy, such as "return to work and production of small and micro enterprises in Beijing" or "Shandong disabled people's subsidy policy". When the semantics of the text to be searched is determined to be a matter search, it means that the user needs related matters, and the returned result is the matter process and link. After determining the semantics of the text to be searched, the search results corresponding to the text to be searched can be sorted in front, and when displayed to the user, the search results corresponding to the semantics of the text to be searched can be displayed first.
[0085] In other optional embodiments, sorting the multiple search results according to the semantics includes:
[0086] Using a preset relevance algorithm, respectively calculate the relevance of each search result with the text to be searched;
[0087] Determine a search result corresponding to the semantics from the multiple search results, and update the relevance of the search result corresponding to the semantics;
[0088] The multiple search results are sorted according to the relevance.
[0089] In this embodiment, the BM25 algorithm can be used to calculate the relevance of each search result to the text to be searched. BM25 is an information retrieval method based on the bag-of-words model. When a user enters a search statement Q, the search engine will calculate the relevance score of all documents D in the document library {D} to Q, which is recorded as:
[0090]
[0091] Among them, f(q i ,D) is word q iThe frequency, |D| is the word length of document D, avgdl is the average length of all texts in the text library {D}, and k1, b are hyperparameters determined manually. Usually, the value range is k ∈ [1.2, 2.0], b = 0.75. Generally speaking, the larger b is, the greater the penalty for long texts, that is, the less likely long texts will appear at the front of the returned results; and the larger k1 is, the greater the reward for high-frequency words. For example, when an article repeatedly mentions "social security", a larger k1 will give this article more scores. Finally, IDF(q i ) is the inverse text vector of word q i in the retrieval statement Q, and the usual calculation method is
[0092]
[0093] where N is the number of all documents in the document library {D}, and n(q i ) is the number of documents containing word q i .
[0094] The idea of the inverse document vector is that when a word is covered by many articles, although this word is very frequent, it is more likely not to be a key word. For example, common words such as "is" and "I". Therefore, we penalize the relevant scores of documents containing many such words.
[0095] After calculating the relevance between each retrieval result and the text to be retrieved, the relevance of the retrieval result corresponding to the semantics of the text to be retrieved is updated. In this embodiment, updating the relevance of the retrieval result corresponding to the semantics of the text to be retrieved is to increase the relevance of the retrieval result corresponding to the semantics of the text to be retrieved. For example, multiply the relevance by a preset multiple, and then sort the retrieval results in descending order of relevance. Therefore, the order of the retrieval results corresponding to the semantics of the text to be retrieved is靠前, and when presenting to the user, the retrieval results with higher relevance are presented first.
[0096] The information retrieval method of the embodiment of the present invention, by obtaining the text to be retrieved; identifying the entity to be retrieved in the text to be retrieved; matching the entity to be retrieved with the entities in the preset graph database policy graph knowledge base to obtain multiple retrieval results corresponding to the text to be retrieved, and based on the multiple retrievals, obtaining the technical means of the first result set, that is, using the policy graph knowledge base to enhance the existing policy retrieval scheme, so it solves the problems of not being able to search and not being able to search comprehensively in the prior art, and can return more comprehensive and accurate search results to users, improving the recall accuracy of the retrieval results and improving the retrieval accuracy; sorting the retrieval results according to the relevance between the text to be retrieved and the retrieval results and the semantics of the text to be retrieved not only solves the semantic problems that cannot be solved in the prior art, but also makes the sorting of the retrieval results more in line with the user's search expectations.
[0097] Figure 3 FIG. 1 is a flow chart of the main steps of the information retrieval method according to another embodiment of the present invention. Figure 3 As shown, the method includes:
[0098] Step S301: Obtain the text to be searched;
[0099] Step S302: identifying entities to be searched in the text to be searched;
[0100] Step S303: matching the entity to be searched with entities in a preset policy graph knowledge base to obtain multiple search results corresponding to the text to be searched, and obtaining a first result set based on the multiple searches;
[0101] Step S304: inputting the text to be searched into a preset search engine to obtain multiple search results, and obtaining a second result set based on the multiple search results;
[0102] Step S305: determine the intersection of the first result set and the second result set, and use the intersection of the first result set and the second result set as the third result set.
[0103] Steps S301-S303 and Figure 1 The embodiments shown are the same, and the present invention will not be described in detail here.
[0104] The algorithm is not 100% accurate. In some cases, all policies related to the text to be searched cannot be obtained through steps S301-S303, or there are unidentified objects. Therefore, in this embodiment, a multi-way recall method is adopted to ensure that users can search for corresponding information as much as possible. Specifically, as shown in steps S304-S304, the text to be searched is input into a preset search engine to obtain multiple search results, and a second result set is obtained based on the multiple search results. Then, the intersection of the first result set and the second result set is obtained to obtain a third result set. When displaying the search results to the user, the search results in the third result set are displayed first, and then the remaining search results in the first result set and the second result set are displayed. That is, when displaying the search results, the search results in the third result set are sorted first, and the remaining search results in the first result set and the second result set are sorted later. Among them, as an example, the preset search engine can be an Elasticsearch engine. Elasticsearch (ES for short) is a highly available distributed open source search engine built on Apache Lucene. The Elasticsearch engine provides a BM25 search module, so the multiple search results of the second result set are already sorted.
[0105] The information retrieval method of the embodiment of the present invention obtains a text to be retrieved; identifies entities to be retrieved in the text to be retrieved; matches the entities to be retrieved with entities in a preset graph database policy graph knowledge base to obtain multiple search results corresponding to the text to be retrieved, and obtains a technical means of a first result set based on the multiple searches, i.e., utilizing the policy graph knowledge base to enhance the existing policy retrieval scheme, thereby solving the problem that the prior art cannot search or cannot search completely, and can return more comprehensive and accurate search results to users, and improves the retrieval accuracy; sorts the retrieval results according to the relevance of the text to be retrieved and the retrieval results and the semantics of the text to be retrieved, which not only solves the semantic problem that cannot be solved in the prior art, but also makes the sorting of the retrieval results more in line with the user's search expectations.
[0106] Figure 4 FIG. 1 is a flow chart of the main steps of the information retrieval method according to another embodiment of the present invention. Figure 4 As shown, the method includes:
[0107] Step S401: obtaining the text to be searched;
[0108] Step S402: identifying entities to be searched in the text to be searched;
[0109] Step S403: matching the entity to be searched with entities in a preset policy graph knowledge base to obtain multiple search results corresponding to the text to be searched, and obtaining a first result set based on the multiple searches;
[0110] Step S404: inputting the text to be searched into a preset search engine to obtain multiple search results, and obtaining a second result set based on the multiple search results;
[0111] Step S405: determining the intersection of the first result set and the second result set, and taking the intersection of the first result set and the second result set as the third result set;
[0112] Step S406: performing knowledge expansion on the text to be searched to obtain a synonymous search statement corresponding to the text to be searched;
[0113] Step S407: inputting the synonymous search statement into the preset search engine to obtain a fourth result set corresponding to the synonymous search statement;
[0114] Step S408: determining the intersection of the first result set and the fourth result set, and taking the intersection of the first result set and the fourth result set as the fifth result set;
[0115] Step S409: merge the fourth result set with the fifth result set to obtain a sixth result set.
[0116] Steps S401-S405 and Figure 3 The embodiments shown are the same, and the present invention will not be described in detail here.
[0117] For step S406, the preset policy graph knowledge base can be used for knowledge expansion. Match the content entity of the text to be retrieved with the entity in the policy graph knowledge base, determine the synonym of the content entity, and form a synonym search statement with the synonym and the named entity in the text to be retrieved. For example, the text to be retrieved is "Beijing Social Security Card", "Beijing" is identified as a location entity, and "Social Security Card" is identified as a content entity. Match "Social Security Card" with the entity in the policy graph knowledge base to obtain the synonym "Social Security Card" of the social security card. The synonym and the location entity "Beijing" form a synonym search statement "Beijing Social Security Card", and enter the synonym search statement into the Elasticsearch engine to obtain the fifth result set. The fourth result set is merged with the fifth result set to obtain a sixth result set. When displaying the search results to the user, the search results in the sixth result set are preferentially displayed as the final search results, and then the remaining search results in the first result set, the second result set and the fourth result set are displayed. That is, when displaying the search results, the search results in the sixth result set are sorted first, and the remaining search results in the first result set, the second result set and the fourth result set are sorted later.
[0118] The information retrieval method of the embodiment of the present invention obtains a text to be retrieved; identifies entities to be retrieved in the text to be retrieved; matches the entities to be retrieved with entities in a preset graph database policy graph knowledge base to obtain multiple search results corresponding to the text to be retrieved, and obtains a technical means of a first result set based on the multiple searches, i.e., utilizing the policy graph knowledge base to enhance the existing policy retrieval scheme, thereby solving the problem that the prior art cannot search or cannot search completely, and can return more comprehensive and accurate search results to users, and improves the retrieval accuracy; sorts the retrieval results according to the relevance of the text to be retrieved and the retrieval results and the semantics of the text to be retrieved, which not only solves the semantic problem that cannot be solved in the prior art, but also makes the sorting of the retrieval results more in line with the user's search expectations.
[0119] Figure 5 is a schematic diagram of the main modules of the information retrieval device 500 according to an embodiment of the present invention. Figure 5 As shown, the information retrieval device 500 includes:
[0120] The acquisition module 501 is used to acquire the text to be searched;
[0121] The entity recognition module 502 uses a preset recognition model to recognize the entity to be retrieved in the text to be retrieved;
[0122] The retrieval module 503 is used to match the entity to be retrieved with the named entity in the preset policy graph knowledge base, obtain multiple retrieval results corresponding to the text to be retrieved, and obtain a first result set based on the multiple retrieval results.
[0123] Optionally, the entities to be retrieved include named entities to be retrieved and content entities to be retrieved;
[0124] The entity recognition module 502 is further used to: identify the named entities to be retrieved in the text to be retrieved by using a preset recognition model; and determine the content entities to be retrieved in the text to be retrieved by using a word frequency inverse text frequency algorithm.
[0125] Optionally, the device also includes a training module for acquiring training data and annotating samples in the training data to mark the named entities of the samples; inputting the annotated training data into a preset transformer-based bidirectional coding representation model to obtain word vectors of the annotated training data, training the word vectors, and obtaining the preset recognition model.
[0126] Optionally, the training module is further used to: label samples in the training data in BIO format, wherein B represents the beginning part of a named entity, I represents the middle part of a named entity or the end part of a named entity, and O represents other parts.
[0127] Optionally, the device also includes a policy graph knowledge base construction module, which is used to: obtain policy corpus; determine the named entities, content entities and the relationship between the named entities in the policy corpus; obtain a general knowledge base; and merge the named entities, content entities and the relationship between the named entities in the policy corpus with the general knowledge base to obtain a policy graph knowledge base.
[0128] Optionally, the training module is further used to: after marking the named entities in the training data, determine the relationship between the marked named entities; input the marked training data into a preset transformer-based bidirectional encoding representation model to obtain sentence vectors of the marked training data, train the sentence vectors, and obtain a relationship classification model;
[0129] The policy graph knowledge base construction module is also used to determine the relationship between the named entities using the relationship classification model.
[0130] Optionally, the named entity includes one or more of the following: time, place, organization, audience, industry and policy.
[0131] Optionally, the relationship between policies includes one or more of the following: basis, abolition, revision, mention, reply, implementation, and forwarding; the relationship between policies and time includes release; the relationship between policies and institutions includes release and effect; the relationship between policies and locations is effect; the relationship between policies and audiences includes involvement; the relationship between policies and industries includes involvement.
[0132] Optionally, the device further comprises a sorting module for sorting the multiple search results in the first result set.
[0133] Optionally, the sorting module is further used to: classify the text to be retrieved to determine the semantics of the text to be retrieved; and sort the multiple search results according to the semantics.
[0134] Optionally, the semantics include one or more of the following: definition retrieval, policy retrieval and matter retrieval.
[0135] Optionally, the sorting module is further used to: use a preset relevance algorithm to respectively calculate the relevance of each search result with the text to be searched; and sort the multiple search results according to the relevance.
[0136] Optionally, the retrieval module is also used to: input the text to be searched into a preset search engine to obtain multiple search results, and obtain a second result set based on the multiple search results; determine the intersection of the first result set and the second result set, and use the intersection of the first result set and the second result set as the third result set.
[0137] Optionally, the retrieval module is also used to: perform knowledge expansion on the text to be retrieved to obtain synonymous search statements corresponding to the text to be retrieved; input the synonymous search statements into the preset search engine to obtain a fourth result set corresponding to the synonymous search statements; determine the intersection of the first result set and the fourth result set, and use the intersection of the first result set and the fourth result set as the fifth result set; merge the fourth result set with the fifth result set to obtain a sixth result set.
[0138] The information retrieval device of the embodiment of the present invention obtains a text to be retrieved; identifies entities to be retrieved in the text to be retrieved; matches the entities to be retrieved with entities in a preset graph database policy graph knowledge base to obtain multiple search results corresponding to the text to be retrieved, and obtains a technical means of a first result set based on the multiple searches, i.e., utilizing the policy graph knowledge base to enhance the existing policy retrieval scheme, thereby solving the problem that the prior art cannot search or cannot search completely, and can return more comprehensive and accurate search results to users, and improves the retrieval accuracy; sorts the retrieval results according to the relevance of the text to be retrieved and the retrieval results and the semantics of the text to be retrieved, which not only solves the semantic problem that cannot be solved in the prior art, but also makes the sorting of the retrieval results more in line with the user's search expectations.
[0139] The above device can execute the method provided by the embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not described in detail in this embodiment, please refer to the method provided by the embodiment of the present invention.
[0140] Figure 6 An exemplary system architecture 600 is shown to which the information retrieval method or information retrieval device according to the embodiment of the present invention can be applied.
[0141] like Figure 6 As shown, system architecture 600 may include terminal devices 601, 602, 603, network 604 and server 605. Network 604 is used to provide a medium for communication links between terminal devices 601, 602, 603 and server 605. Network 604 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0142] The user can use the terminal devices 601, 602, 603 to interact with the server 605 through the network 604 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 601, 602, 603, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0143] The terminal devices 601 , 602 , and 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.
[0144] The server 605 may be a server that provides various services, such as a backend management server that provides support for shopping websites browsed by users using the terminal devices 601, 602, and 603. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information and product information) to the terminal device.
[0145] It should be noted that the information retrieval method provided in the embodiment of the present invention is generally executed by the server 605 , and accordingly, the information retrieval device is generally disposed in the server 605 .
[0146] It should be understood that Figure 6 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0147] Reference below Figure 7 , which shows a schematic diagram of the structure of a computer system 700 of a terminal device suitable for implementing an embodiment of the present invention. Figure 7 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0148] like Figure 7 As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0149] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.
[0150] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present invention are executed.
[0151] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0152] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0153] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor. For example, they may be described as: a processor includes a sending module, an acquisition module, a determination module, and a first processing module. The names of these modules do not, in some cases, constitute a limitation on the unit itself. For example, the sending module may also be described as a "module for sending a picture acquisition request to the connected server."
[0154] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes:
[0155] Get the text to be retrieved;
[0156] Identifying entities to be retrieved in the text to be retrieved;
[0157] The entity to be searched is matched with entities in a preset policy graph knowledge base to obtain multiple search results corresponding to the text to be searched, and a first result set is obtained based on the multiple search results.
[0158] The technical solution of the embodiment of the present invention obtains the text to be searched; identifies the entities to be searched in the text to be searched; matches the entities to be searched with the entities in the preset graph database policy graph knowledge base to obtain multiple search results corresponding to the text to be searched, and obtains the technical means of the first result set based on the multiple searches, that is, using the policy graph knowledge base to enhance the existing policy search scheme, so as to solve the problem that the prior art cannot search or search completely, and can return more comprehensive and accurate search results to users, and improve the search accuracy; sorts the search results according to the relevance of the text to be searched and the search results and the semantics of the text to be searched, which not only solves the semantic problems that cannot be solved in the prior art, but also makes the sorting of the search results more in line with the user's search expectations.
[0159] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. An information retrieval method, characterized in that: include: Get the text to be retrieved; Identifying entities to be retrieved in the text to be retrieved; Matching the entity to be searched with entities in a preset policy graph knowledge base to obtain multiple search results corresponding to the text to be searched, and obtaining a first result set based on the multiple search results; Classifying the text to be retrieved to determine the semantics of the text to be retrieved; Using a preset relevance algorithm, respectively calculate the relevance of each search result with the text to be searched; Determine, from the plurality of search results, a search result corresponding to the semantics of the text to be searched, and update the relevance of the search result corresponding to the semantics; The multiple search results are sorted according to the relevance.
2. The method according to claim 1, characterized in that The entities to be retrieved include named entities to be retrieved and content entities to be retrieved; Identifying the entity to be retrieved in the text to be retrieved includes: Using a preset recognition model to identify the named entities to be retrieved in the text to be retrieved; The word frequency inverse text frequency algorithm is used to determine the content entity to be retrieved in the text to be retrieved.
3. The method according to claim 2, characterized in that The method further comprises obtaining the preset recognition model according to the following process: Acquire training data, and annotate samples in the training data to annotate named entities of the samples; The labeled training data is input into a preset transformer-based bidirectional coding representation model to obtain word vectors of the labeled training data, and the word vectors are trained to obtain the preset recognition model.
4. The method according to claim 3, characterized in that Labeling the samples in the training data includes: labeling the samples in the training data in BIO format, wherein B represents the beginning part of the named entity, I represents the middle part of the named entity or the end part of the named entity, and O represents other parts.
5. The method according to claim 4, characterized in that The method further comprises obtaining the policy graph knowledge base according to the following process: Obtain policy corpus; Determining named entities, content entities, and relationships between the named entities in the policy corpus; Access to a common knowledge base; The named entities and content entities in the policy corpus and the relationships between the named entities are integrated with the general knowledge base to obtain a policy graph knowledge base.
6. The method according to claim 5, characterized in that The method further comprises: After marking the named entities in the training data, determining the relationship between the marked named entities; Inputting the labeled training data into a preset transformer-based bidirectional encoding representation model to obtain sentence vectors of the labeled training data, training the sentence vectors, and obtaining a relation classification model; Determining the relationship between the named entities in the policy corpus includes: using the relationship classification model to determine the relationship between the named entities.
7. The method according to claim 6, characterized in that The named entity includes one or more of the following: time, place, organization, audience, industry, and policy.
8. The method according to claim 7, characterized in that The relationship between policies includes one or more of the following: basis, repeal, revision, mention, reply, implementation, forwarding; the relationship between policies and time includes release; the relationship between policies and institutions includes release and effect; the relationship between policies and places includes effect; The relationship between policy and audience includes involvement; the relationship between policy and industry includes involvement.
9. The method according to any one of claims 1 to 8, characterized in that: After obtaining the first result set, the method further includes: The multiple search results in the first result set are sorted.
10. The method according to claim 1, characterized in that The semantics include one or more of the following: definition retrieval, policy retrieval and matter retrieval.
11. The method according to claim 1, characterized in that: After obtaining a plurality of search results corresponding to the text to be searched, the method further includes: Inputting the text to be searched into a preset search engine to obtain multiple search results, and obtaining a second result set based on the multiple search results; An intersection of the first result set and the second result set is determined, and the intersection of the first result set and the second result set is used as a third result set.
12. The method according to claim 11, characterized in that After obtaining the third result set, the method further includes: Performing knowledge expansion on the text to be searched to obtain synonymous search statements corresponding to the text to be searched; Inputting the synonymous search statement into the preset search engine to obtain a fourth result set corresponding to the synonymous search statement; Determine an intersection of the first result set and the fourth result set, and use the intersection of the first result set and the fourth result set as a fifth result set; The fourth result set is merged with the fifth result set to obtain a sixth result set.
13. An information retrieval device, characterized in that: include: An acquisition module is used to acquire the text to be retrieved; An entity recognition module, using a preset recognition model, recognizes the entity to be retrieved in the text to be retrieved; A retrieval module, used to match the entity to be retrieved with a named entity in a preset policy graph knowledge base, obtain a plurality of retrieval results corresponding to the text to be retrieved, and obtain a first result set based on the plurality of retrievals; Classifying the text to be searched to determine the semantics of the text to be searched; using a preset relevance algorithm, respectively calculating the relevance of each search result to the text to be searched; From the multiple search results, determine the search results corresponding to the semantics of the text to be searched, update the relevance of the search results corresponding to the semantics; and sort the multiple search results according to the relevance.
14. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 12.
15. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 12 is implemented.
