A knowledge base retrieval method and system based on large model
By text splitting and semantic analytical graph construction of query statements entered by the user, expanding statements are generated and search attention is calculated, and the problem of low retrieval accuracy caused by different entity positions in query statements in the prior art is solved, and more efficient knowledge base retrieval is achieved.
Patent Information
- Application Number
- CN202411748776.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2044-12-02
AI Technical Summary
The existing knowledge base question and answer methods fail to effectively consider the richness and diversity of text expressions caused by the different positions of entities in the query statement, resulting in low retrieval accuracy.
By splitting the query statements entered by the user, a semantic analysis diagram is constructed, and the entity character text is sorted and combined according to the semantic analysis diagram is generated to generate an extension statement, and the search attention is calculated based on the distribution position information of the entity character text in the extension statement, and then the knowledge base is searched.
It improves the accuracy of knowledge base retrieval and fully considers the richness and diversity of text expressions caused by the different entity positions in the query statement.
Smart Images

Figure CN119202215B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a knowledge base retrieval method and system based on a large model. Background Art
[0002] Knowledge Base Question Answering (KBQA) refers to the use of computer programs to answer questions raised by users. In order to retrieve answers in a knowledge base, it is often necessary to generate query statements through entities and their related attributes.
[0003] In the existing method, in response to a query statement input by a user, a search is performed based on the text similarity of entities between the query statement and the content stored in the knowledge base to obtain a search result of the query statement.
[0004] However, existing methods do not take into account the richness and diversity of query text expressions caused by the different entity positions in the query, resulting in low retrieval accuracy. Summary of the invention
[0005] The embodiment of the present invention provides a knowledge base retrieval method and system based on a large model, which can improve the accuracy of retrieval.
[0006] A first aspect of an embodiment of the present invention provides a knowledge base retrieval method based on a large model, comprising:
[0007] Perform text splitting on the query sentence input by the user, and construct a semantic parsing graph corresponding to the query sentence, which is used to represent the corresponding semantic relationship between each character text in the query sentence;
[0008] According to the semantic parsing graph, the entity character texts in the query statement are sorted and combined to obtain at least one extended statement corresponding to the query statement;
[0009] For each extended sentence, the distribution position information of each entity character text in the extended sentence is used to calculate the retrieval attention of each entity character text in the extended sentence. The retrieval attention is used to represent the importance of the entity character text in the retrieval process.
[0010] According to the retrieval attention of each entity character text in each extended sentence, the knowledge base is searched to obtain the retrieval result corresponding to the query sentence.
[0011] A second aspect of an embodiment of the present invention provides a knowledge base retrieval system based on a large model, comprising:
[0012] A parsing graph construction module is used to perform text splitting on the query statement input by the user and construct a semantic parsing graph corresponding to the query statement. The semantic parsing graph is used to represent the corresponding semantic relationship between each character text in the query statement;
[0013] A sentence expansion module is used to sort and combine entity character texts in the query sentence according to the semantic analysis graph to obtain at least one expansion sentence corresponding to the query sentence;
[0014] An attention calculation module is used to calculate the retrieval attention of each entity character text in each extended sentence by using the distribution position information of each entity character text in the extended sentence. The retrieval attention is used to represent the importance of the entity character text in the retrieval process;
[0015] The knowledge base retrieval module is used to search the knowledge base according to the retrieval attention of each entity character text in each expansion sentence to obtain the retrieval result corresponding to the query sentence.
[0016] In the large model-based knowledge base retrieval method provided by the embodiment of the present invention, the query statement input by the user is firstly split into texts, and a semantic parsing graph representing the corresponding semantic relationships between the character texts in the query statement is constructed. Thus, according to the semantic parsing graph, the query statement is expanded to obtain multiple expanded statements. Then, according to the distribution position information of each entity character text in the expanded statement, the retrieval attention of each entity character text in the expanded statement is calculated. Thus, according to the retrieval attention of each entity character text in the expanded statement, the knowledge base can be searched to obtain the retrieval result corresponding to the query statement. In this way, the embodiment of the present invention expands the query statement to obtain multiple expanded statements, and according to the distribution position information of each entity character text in the expanded statement, the corresponding retrieval attention is set for each entity character text. The richness and diversity of the query statement text expression caused by the different entity positions in the query statement are fully considered, so as to improve the accuracy of the retrieval. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 A schematic flow chart of a first large model-based knowledge base retrieval method provided by an embodiment of the present invention;
[0019] Figure 2A schematic flow chart of a second large model-based knowledge base retrieval method provided by an embodiment of the present invention;
[0020] Figure 3 A schematic diagram of a semantic parsing graph provided by an embodiment of the present invention;
[0021] Figure 4 A schematic diagram of a flow chart of a third large model-based knowledge base retrieval method provided by an embodiment of the present invention;
[0022] Figure 5 A schematic flow chart of a fourth large model-based knowledge base retrieval method provided by an embodiment of the present invention;
[0023] Figure 6 A schematic flow chart of a fifth large model-based knowledge base retrieval method provided by an embodiment of the present invention;
[0024] Figure 7 A schematic diagram of the structure of a large model-based knowledge base retrieval system provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0025] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of the knowledge base retrieval method and system based on a large model proposed by the present invention, its specific implementation method, structure, features and effects, in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.
[0026] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0027] It should be noted that the acquisition, storage, use, and processing of data in the technical solution of the present invention are in compliance with the relevant provisions of laws and regulations.
[0028] It should be noted that in the embodiments of the present invention, certain software, components, models and other existing solutions in the industry may be mentioned, which should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present invention, but it does not mean that the applicant has or will necessarily use the solution.
[0029] In the existing methods, in response to the query statement input by the user, the search is performed based on the text similarity of the entities between the query statement and the content stored in the knowledge base to obtain the search results of the query statement. However, the existing methods do not take into account the richness and diversity of the query statement text expression caused by the different positions of the entities in the query statement, resulting in low retrieval accuracy.
[0030] The object of the present invention is to provide a knowledge base retrieval method and system based on a large model. In the knowledge base retrieval method based on a large model provided by an embodiment of the present invention, the query statement input by the user is firstly text-splitting, and a semantic parsing graph representing the corresponding semantic relationship between each character text in the query statement is constructed. Thus, according to the semantic parsing graph, the query statement is expanded to obtain multiple expanded statements. Then, according to the distribution position information of each entity character text in the expanded statement, the retrieval attention of each entity character text in the expanded statement is calculated. Thus, according to the retrieval attention of each entity character text in the expanded statement, the knowledge base can be searched to obtain the retrieval result corresponding to the query statement. In this way, the embodiment of the present invention expands the query statement to obtain multiple expanded statements, and according to the distribution position information of each entity character text in the expanded statement, the corresponding retrieval attention is set for each entity character text. The richness and diversity of the query statement text expression caused by the different entity positions in the query statement are fully considered, so as to improve the accuracy of the retrieval.
[0031] The following describes a specific embodiment of a large model-based knowledge base retrieval method and system provided by an embodiment of the present invention.
[0032] Figure 1 A flow chart of a knowledge base retrieval method based on a large model is provided. The knowledge base retrieval method based on a large model can be applied to a server. The knowledge base retrieval method based on a large model can include the following S101 to S104.
[0033] S101, performing text segmentation on the query statement input by the user, and constructing a semantic parsing graph corresponding to the query statement, wherein the semantic parsing graph is used to represent the corresponding semantic relationship between each character text in the query statement.
[0034] In this embodiment, the semantic parsing graph is used to represent the corresponding semantic relationship between each character text in the query statement. Specifically, the semantic parsing graph usually includes nodes and edges, wherein the nodes represent the character text of the query statement, and the edges represent the semantic relationship between the character texts. Specifically, the semantic relationship may include a synonym relationship, a hyponym relationship, and an attribute relationship.
[0035] As an example, the server first performs word segmentation on the query statement input by the user and splits it into independent character texts. The character texts can be words or phrases. Specifically, the query statement can be segmented using a word segmentation algorithm in natural language processing, such as rule-based word segmentation, statistical-based word segmentation, or a deep learning model. Finally, the semantic parsing graph is constructed using the character texts obtained after word segmentation.
[0036] S102: Sort and combine entity character texts in the query statement according to the semantic parsing graph to obtain at least one extended statement corresponding to the query statement.
[0037] In this embodiment, the entity character text is used to represent the sentence body in the query sentence, which may specifically include the actor, the patient, the tool, and the attribute. For example, the query sentence is "the energy system flexible direct current control method in the new energy network system", and its corresponding entity character text includes "new energy", "energy" and "control". Specifically, the entity character text can be automatically identified by the Abstract Meaning Representation (AMR) tool.
[0038] As an example, the server uses the AMR tool to identify entity character texts from the semantic parsing graph, and then sorts and combines the entity character texts to obtain at least one extended sentence corresponding to the query sentence. Specifically, a heuristic search algorithm (such as depth-first search and breadth-first search, etc.) can be used to generate possible combinations, and each possible combination constitutes an extended sentence.
[0039] For example, if the query statement is "the flexible direct current control method of energy system in the new energy grid system", the corresponding entity character text includes "new energy", "energy" and "control", which are numbered as arg0, arg1 and arg2 respectively, and the order of the entity character texts is [arg0, arg1, arg2]. The corresponding extended statements may include: "the method of implementing the flexible direct current control of new energy in the energy grid system", the order of the entity character texts is [arg1, arg0, arg2]; "the flexible direct current control method of energy output applicable to the new energy grid system", the order of the entity character texts is [arg0, arg1, arg2]; "the application of the flexible direct current control method related to energy in the new energy grid system", the order of the entity character texts is [arg1, arg2, arg0]; "the method of optimizing the allocation of energy system based on flexible direct current control in the new energy grid system", the order of the entity character texts is [arg0, arg2, arg1].
[0040] S103, for each extended sentence, using the distribution position information of each entity character text in the extended sentence, calculate the retrieval attention of each entity character text in the extended sentence, and the retrieval attention is used to represent the importance of the entity character text in the retrieval process.
[0041] In this embodiment, the distribution position information is used to characterize the distribution position of the entity character text in the extended sentence, which may specifically include their position in the sentence and the non-entity character text around them, etc. Among them, the non-entity character text is used to characterize other character texts except the entity character text.
[0042] Retrieval attention is a numerical indicator used to characterize the importance of entity character text in the retrieval process. Generally, entity character text with more important position and closer relationship with non-entity character text has higher retrieval attention.
[0043] As an example, the server uses a machine learning algorithm (such as a support vector machine, a neural network, etc.) or a rule-based method to calculate the retrieval attention of each entity character text according to the distribution position information of the entity character text.
[0044] S104: Search the knowledge base according to the search attention of each entity character text in each expanded sentence to obtain the search result corresponding to the query sentence.
[0045] In this embodiment, the knowledge base is a database containing a large amount of information, which may be structured data (such as a relational database) or unstructured data (such as a text file).
[0046] As an example, the server searches the knowledge base according to the search attention of each entity character text in the extended sentence. When searching, the entity character text with higher search attention in the extended sentence is prioritized as the search condition to improve the accuracy and efficiency of the search.
[0047] In the knowledge base retrieval method based on a large model provided in this embodiment, the query statement input by the user is firstly split into texts, and a semantic parsing graph is constructed to characterize the corresponding semantic relationships between the character texts in the query statement. Thus, according to the semantic parsing graph, the query statement is expanded to obtain multiple expanded statements. Then, according to the distribution position information of each entity character text in the expanded statement, the retrieval attention of each entity character text in the expanded statement is calculated. Thus, according to the retrieval attention of each entity character text in the expanded statement, the knowledge base can be searched to obtain the retrieval result corresponding to the query statement. In this way, the embodiment of the present invention expands the query statement to obtain multiple expanded statements, and according to the distribution position information of each entity character text in the expanded statement, the corresponding retrieval attention is set for each entity character text. The richness and diversity of the query statement text expression caused by the different entity positions in the query statement are fully considered, so as to improve the accuracy of the retrieval.
[0048] As an optional embodiment, Figure 2 As shown, S101 may specifically include the following S201 to S203.
[0049] S201, obtaining a query statement input by a user;
[0050] S202, using a long short-term memory network, performing text segmentation on the query statement to obtain character texts corresponding to the query statement;
[0051] S203: construct a semantic parsing graph corresponding to the query statement according to the semantic relationship between the character texts corresponding to the query statement.
[0052] In this embodiment, the long short-term memory network (LSTM) is a type of recurrent neural network that is good at processing sequence data (such as text). It can capture long-term dependencies in a sequence and is suitable for text segmentation tasks.
[0053] As an example, the server first provides a user interface (such as a search box, command line interface, etc.) to allow users to enter query statements. At the same time, the server captures the query statements entered by the user through a programming interface or event monitoring mechanism and stores them in memory for subsequent processing.
[0054] Then, the server converts the query statement of natural language text into a character sequence and inputs it into the LSTM network. The LSTM network processes the query statement character by character, and determines whether each character belongs to an independent text unit (such as a word, phrase, etc.) based on the contextual relationship between the characters, thereby obtaining the character text corresponding to the query statement.
[0055] Finally, after obtaining the character text of the query statement, the server uses the AMR tool to construct a semantic parsing graph corresponding to the query statement.
[0056] For example, Figure 3 As shown, a schematic diagram of a semantic parsing graph is provided. Among them, the query statement is "flexible direct current control method of energy system in new energy network system". arg is used to represent the entity character text. For example, "control" is an attribute of "system", so "control" belongs to the entity character text. Domain is used to represent the definition domain. For example, "flexible direct current" restricts the scope of "method", that is, "flexible direct current" belongs to the definition domain of "method". Range is used to represent the value range. For example, "flexible direct current method" belongs to a value in "system", that is, "flexible direct current method" belongs to the value range of "system".
[0057] Through this embodiment, the query statement is text-segmented using a long short-term memory network, and a semantic analysis technology is used to construct a semantic parsing graph, thereby achieving an in-depth understanding and processing of the query statement input by the user, thereby improving the accuracy and efficiency of query processing.
[0058] As an optional embodiment, S202 may specifically include:
[0059] Input the query sentence into the encoder of the long short-term memory network for encoding, and obtain the sentence vector corresponding to the query sentence;
[0060] The sentence vector is input into the decoder of the long short-term memory network for decoding to obtain the character text corresponding to the query sentence.
[0061] In this embodiment, the LSTM network includes two parts: an encoder and a decoder.
[0062] The server first converts the query statement into a machine-readable vector form. Specifically, each character text in the query statement is converted into a corresponding word vector.
[0063] Then, the LSTM encoder uses multiple layers of LSTM layers to process the original input word vector sequence. The LSTM encoder can capture the temporal dependencies in the sequence and encode the input word vector sequence into a fixed-length vector (i.e., sentence vector). The output of each LSTM layer will be used as the input of the next layer, and the output of the last LSTM layer will be used as the initial state of the decoder.
[0064] Finally, the LSTM decoder uses multiple LSTM layers to process the output of the encoder (i.e., the sentence vector). The LSTM layer of the decoder reads information from the fixed-size output of the encoder and decodes the sentence vector output by the encoder into individual character texts. The output of each LSTM layer is used as the input of the next layer, and the output of the last LSTM layer is used to predict the next character text.
[0065] Through this embodiment, the encoder-decoder architecture of LSTM is used. Through reasonable input processing, encoding processing and decoding processing of the LSTM layer, the function of splitting the query statement into corresponding character texts is realized, which is helpful for the subsequent generation of the expansion statement corresponding to the query statement and the calculation of the retrieval attention of each entity character text in the expansion statement, thereby improving the accuracy of the retrieval.
[0066] As an optional embodiment, Figure 4 As shown, S103 may specifically include the following S401 to S404.
[0067] S401, obtaining a first entity sequence of an extended sentence, where the first entity sequence is used to represent the order of entity character texts in the extended sentence;
[0068] S402, merging entity character texts located at adjacent positions of the extended sentence in the first entity sequence to form a second entity sequence of the extended sentence;
[0069] S403, for each entity character text in the second entity sequence, sequentially obtain non-entity character texts on both sides of the entity character text until reaching other entity character texts, thereby obtaining an attention window of the entity character text;
[0070] S404: Calculate the retrieval attention of each entity character text in the expanded sentence according to the attention window of each entity character text in the expanded sentence.
[0071] In this embodiment, the first entity sequence is a sequence that represents the order of entity character texts in the extended sentence. For example, the extended sentence is "a method for implementing new energy flexible direct current control in an energy grid system", and the order of entity character texts is [arg1, arg0, arg2], that is, the corresponding first entity sequence is [arg1, arg0, arg2].
[0072] The second entity sequence is used to represent the new entity sequence obtained by merging the entity character texts located at adjacent positions in the extended sentence. For example, the first entity sequence of the extended sentence is [arg1, arg0, arg2]. Assuming that arg1 and arg0 are located at adjacent positions in the extended sentence, arg1 and arg0 are merged into arg3, that is, the second entity sequence corresponding to the extended sentence is [arg3, arg2].
[0073] The attention window includes entity character text and non-entity character text on both sides of the entity character text. For example, the extended sentence is "Method for implementing flexible direct current control of new energy in energy grid system", and its corresponding first entity sequence is [arg1, arg0, arg2]. Among them, arg1 is "energy", arg0 is "new energy", arg2 is "control", then the attention window corresponding to arg2 should be "flexible direct current control method".
[0074] As an example, the server uses the AMR tool to identify entity character texts in the extended sentence, and arranges the identified entity character texts in the order of their positions in the sentence to form an ordered list, namely, the first entity sequence.
[0075] Then, the first entity sequence is traversed to determine whether there are entity character texts located adjacent to the extended sentence, and adjacent entity character texts that can be merged are merged into a new entity unit to form a second entity sequence.
[0076] Then, for each entity character text in the second entity sequence, start from its position in the extended sentence and expand to both sides until another entity character text is encountered. Collect all character texts in the range to form an attention window for the entity character text.
[0077] Finally, an attention mechanism or algorithm (such as the self-attention mechanism in the Transformer model) is used to process the character text in the attention window to obtain the retrieval attention of the entity character text corresponding to the attention window. The calculation of the retrieval attention can involve multiple factors, such as the position of the entity character text in the attention window, its interaction with the surrounding non-entity character text, etc.
[0078] Through this embodiment, the entity character texts in the extended sentence are analyzed and processed, and their retrieval attention is finally calculated, which helps to search the knowledge base according to the retrieval attention of each entity character text in the extended sentence to obtain the retrieval result corresponding to the query sentence, and can improve the accuracy of the retrieval.
[0079] As an optional embodiment, Figure 5 As shown, S404 may specifically include the following S501 to S503.
[0080] S501, dividing the attention window of the entity character text into a first window and a second window according to the position of the entity character text in the attention window;
[0081] S502, obtaining a non-entity character text ratio of the attention window according to the amount of non-entity character text in the first window and the second window;
[0082] S503, based on the target similarity of each non-entity character text in the attention window and the non-entity character text ratio, the retrieval attention of the entity character text is calculated, the target similarity is used to represent the maximum value of the similarity between the non-entity character text and each similar non-entity character text, and the similar non-entity character text is used to represent each non-entity character text included in the attention window corresponding to the entity character text in each other extended sentence.
[0083] In this embodiment, the first window and the second window respectively include all non-entity character texts located on one side of the entity character text in the attention window. For example, the first window may be non-entity character text located in front of the entity character text in the attention window, and the second window may be non-entity character text located behind the entity character text in the attention window.
[0084] The target similarity is the maximum value of the similarity between the non-entity character text in the first window or the second window and each non-entity character text included in the attention window corresponding to the entity character text in each other extended sentence. For example, there are four extended sentences a, b, c, and d. The target similarity of the non-entity character text x in the attention window of the entity character text a1 corresponding to the extended sentence a is the maximum value of the similarity between the non-entity character text x and each non-entity character text y in the attention window of the entity character text a1 in the extended sentences b, c, and d. Among them, the similarity between texts can be calculated by the word frequency-inverse document frequency statistical method, the cosine similarity calculation method of the word embedding vector, etc.
[0085] The non-entity character text ratio is used to characterize the distribution of the non-entity character text in the first window and the second window, so as to evaluate the distribution stability of the non-entity character text around the entity character text.
[0086] As an example, the server first determines the specific position of the entity character text in the attention window, and then divides the attention window into two parts, a first window and a second window, according to the position.
[0087] Then, the number of non-entity character texts in the first window and the second window is counted respectively. And according to the number of non-entity character texts in the first window and the second window, the non-entity character text ratio of the attention window is calculated. Specifically, the non-entity character text ratio of the attention window can be calculated by the following formula 1:
[0088] Formula 1
[0089] In the formula, It is used to characterize the non-entity character text ratio of the attention window corresponding to the entity character text j, It is used to represent the number of non-entity character texts located in front of the entity character text j. Used to represent the number of non-entity character texts following the entity character text j.
[0090] Among them, when the number of non-entity character texts in front of the entity character text j The number of non-entity characters following entity character j The larger the difference between the two, the larger the ratio of the non-entity character text in the attention window corresponding to the entity character text j. The bigger.
[0091] Then, the target similarity of each non-entity character text in the attention window is calculated, and combined with the non-entity character text ratio of the attention window, the retrieval attention of the entity character text is calculated using a preset algorithm or model. The preset algorithm or model may need to consider multiple factors, such as the distribution of non-entity character text (reflected by the non-entity character text ratio), the similarity between non-entity character text and similar non-entity character text (reflected by target similarity), etc. The specific calculation method may include weighted summation, product operation, and exponential operation.
[0092] Through this embodiment, the retrieval attention of each entity character text in the extended sentence is accurately calculated according to the target similarity of each non-entity character text in the attention window and the non-entity character text ratio of the attention window. This helps to search the knowledge base according to the retrieval attention of each entity character text in the extended sentence to obtain the retrieval result corresponding to the query sentence, which can improve the accuracy of the retrieval.
[0093] As an optional embodiment, S503 may specifically include:
[0094] Using the target similarity of each non-entity character text in the attention window, determine the similarity average and similarity standard deviation;
[0095] For each non-entity character text in the attention window, the difference between the target similarity of the non-entity character text and the similarity average value is divided by the similarity standard deviation and then raised to the fourth power to obtain the similarity calculation value of the non-entity character text;
[0096] The accumulated value of the similarity calculation value of each non-entity character text is multiplied by the non-entity character text ratio, and then divided by the number of non-entity character texts in the attention window to obtain the retrieval attention of the entity character text.
[0097] In this embodiment, the retrieval attention of the entity character text can be calculated by the following formula 2:
[0098] Formula 2
[0099] In the formula, The retrieval attention used to characterize the entity character text j, It is used to characterize the non-entity character text ratio of the attention window corresponding to the entity character text j, The total number of non-entity character texts in the attention window Y corresponding to the entity character text j is used to represent, It is used to characterize the target similarity of the rth non-entity character text in the attention window corresponding to the entity character text j. The average similarity of the attention window Y corresponding to the entity character text j is used to represent, Used to characterize the similarity standard deviation of the attention window Y corresponding to the entity character text j.
[0100] in, It is used to represent the first non-entity character text in the attention window Y corresponding to the entity character text j, and accumulates to the last non-entity character text in the attention window Y corresponding to the entity character text j. The larger the non-entity character text ratio, the more stable the distribution of the non-entity character text and the greater the retrieval attention; the greater the target similarity of the non-entity character text, the more similar the non-entity character text is to other similar non-entity character texts, and the greater the retrieval attention.
[0101] Through this embodiment, the retrieval attention of each entity character text in the extended sentence is accurately calculated according to the target similarity of each non-entity character text in the attention window and the non-entity character text ratio of the attention window. This helps to subsequently search the knowledge base according to the retrieval attention of each entity character text in the extended sentence to obtain the retrieval result corresponding to the query sentence, which can improve the accuracy of the retrieval.
[0102] As an optional embodiment, Figure 6 As shown, before S103, the large model-based knowledge base retrieval method may also include the following S601 to S603.
[0103] S601, determining the language ambiguity weight of each extended sentence by using the first entity sequence corresponding to each extended sentence and the third entity sequence corresponding to the query sentence;
[0104] S602, performing linear normalization processing on the language ambiguity weight of each extended sentence to obtain the normalized language ambiguity weight of each extended sentence;
[0105] S603, filtering out the extended sentences whose normalized language ambiguity weight is greater than a preset weight threshold to obtain optimized extended sentences;
[0106] S103 may specifically include:
[0107] For each optimized and extended sentence, the retrieval attention of each entity character text in the optimized and extended sentence is calculated using the distribution position information of each entity character text in the optimized and extended sentence.
[0108] In this embodiment, the third entity sequence is a sequence representing the order of entity character texts in the query sentence, and the language ambiguity weight is used to represent the possibility of semantic retrieval errors caused by the expanded sentence.
[0109] The optimized extended sentences are used to represent the extended sentences remaining after removing the extended sentences that are prone to semantic retrieval errors.
[0110] As an example, the server assigns a language ambiguity weight to each extended statement by comparing the similarity, relevance or semantic matching degree between the first entity sequence of each extended statement and the third entity sequence of the query statement. This language ambiguity weight reflects the semantic matching degree of the extended statement with the query statement and the possible degree of ambiguity.
[0111] Then, the language ambiguity weights of all extended sentences are linearly normalized so that all weight values fall within the range of 0 to 1. This facilitates subsequent comparison and screening operations.
[0112] Then, according to the needs of the application scenario and the characteristics of the data, a preset weight threshold is set. For example, the preset weight threshold can be set to 0.85. The normalized language ambiguity weight is compared with the preset weight threshold. If the normalized weight of an extended statement is greater than this threshold, it is considered that its language ambiguity is high and does not meet the optimization requirements and should be screened out. Finally, those extended statements whose normalized weight is less than or equal to the preset weight threshold are retained as the optimized extended statement set.
[0113] Through this embodiment, the language ambiguity weight of each extended sentence is calculated according to the first entity sequence corresponding to the extended sentence and the third entity sequence corresponding to the query sentence, so that the extended sentence that may cause semantic retrieval error is screened out through the language ambiguity weight. The influence of language ambiguity on the query result can be effectively reduced, and the efficiency and accuracy of information retrieval and processing can be improved.
[0114] As an optional embodiment, S601 may specifically include:
[0115] Compare the first entity sequence corresponding to the extended sentence with the third entity sequence corresponding to the query sentence to obtain the target number of characters whose order of entity character texts in the first entity sequence and the third entity sequence is different;
[0116] Divide the target number of characters by the total number of entity character texts of the expanded sentence to obtain a first quantity ratio;
[0117] Divide the number of character texts in the expanded sentence by the number of character texts in the query sentence to obtain a second quantity ratio;
[0118] The first quantitative ratio is multiplied by the second quantitative ratio to obtain the language ambiguity weight of the expanded sentence.
[0119] In this embodiment, the language ambiguity weight of the extended sentence can be calculated by the following formula 3:
[0120] Formula 3
[0121] In the formula, The linguistic ambiguity weight used to characterize the extended sentence p, Used to indicate that the extended statement p and the corresponding entity character text in the query statement are in different positions The number of Used to represent the number of all entity character texts in the expanded statement p. Used to represent the number of all character texts in the extended statement p. Used to represent the number of all character texts in the query statement Q.
[0122] in, Used to indicate that the extended statement p and the corresponding entity character text in the query statement are in different positions The first quantity ratio of the number of entity character texts in the expanded sentence p to the total number of entity character texts in the expanded sentence p. The larger the first quantity ratio, the more obvious the difference in the entity structure in the expanded sentence. At this time, the expanded sentence is more likely to produce a semantic result different from the semantic information of the query sentence input by the user, that is, the greater the language ambiguity weight of the expanded sentence.
[0123] in, The second quantity ratio used to characterize the total number of character texts in the extended sentence p and the total number of character texts in the query sentence Q. The larger the second quantity ratio, the more likely it is that the entity character text order of the extended sentence p cannot reduce the description of the vocabulary, and it is more likely to produce semantic retrieval errors, that is, the greater the language ambiguity weight of the extended sentence.
[0124] Through this embodiment, according to the target number of characters with different positions of entity character texts in the first entity sequence corresponding to the extended sentence and the third entity sequence corresponding to the query sentence, the total number of entity character texts in the extended sentence, the number of character texts in the extended sentence, and the number of character texts in the query sentence, the language ambiguity weight of each extended sentence is calculated, so that the extended sentence that may cause semantic retrieval errors can be screened out through the language ambiguity weight. The influence of language ambiguity on query results can be effectively reduced, and the efficiency and accuracy of information retrieval and processing can be improved.
[0125] As an optional embodiment, S104 may specifically include:
[0126] According to the retrieval attention of each entity character text in the expanded sentence, the character weight of each entity character text in the expanded sentence is set respectively;
[0127] Calculate the relevance score of each initial search record obtained by searching the knowledge base through the expanded sentence according to the character weight of each entity character text in the expanded sentence;
[0128] Each of the initial search records in each expanded statement whose relevance score is greater than a preset relevance threshold is determined as a search result corresponding to the query statement.
[0129] In this embodiment, the server assigns a character weight to each entity character text according to the search attention of each entity character text in the expanded sentence. The larger the character weight, the higher the importance of the entity character text in the search process.
[0130] Then, the extended sentence with character weights is input into the knowledge base for retrieval to obtain a series of initial retrieval records. For each initial retrieval record, the relevance score is determined based on the matching of the entity character text contained therein with the entity character text in the extended sentence, as well as the character weights of these entity character texts. Specifically, the scoring algorithm may involve weighted summation, cosine similarity calculation, etc.
[0131] Then, a relevance threshold is preset to filter out highly relevant search records. The calculated initial search records are sorted from high to low according to the relevance score, and the records with relevance scores greater than the preset relevance threshold are filtered out as the search results corresponding to the final query statement. The filtered search results are displayed to the user in a list, summary or other form, providing a visualization and interactive interface for the query results.
[0132] At the same time, we can further collect user feedback on the search results, such as click-through rate, dwell time, satisfaction score, etc., to evaluate the search effect and optimize the algorithm. Based on user feedback and new data, we continuously adjust and optimize the attention mechanism, weight allocation strategy, relevance scoring algorithm, etc. to improve the accuracy of search and user satisfaction.
[0133] Through this embodiment, a retrieval method based on entity character text retrieval attention and character weight is provided, which can more accurately capture the user's query intention, thereby improving the accuracy and efficiency of information retrieval.
[0134] According to the knowledge base retrieval method based on a large model provided by the present invention, the present invention also provides a specific embodiment of a knowledge base retrieval system based on a large model.
[0135] Figure 7 A structural diagram of a large model-based knowledge base retrieval system provided in an embodiment of the present invention is shown. The large model-based knowledge base retrieval system 700 may include a parsing graph construction module 710, a sentence expansion module 720, an attention calculation module 730 and a knowledge base retrieval module 740.
[0136] A parsing graph building module 710 is used to perform text segmentation on the query sentence input by the user, and to build a semantic parsing graph corresponding to the query sentence, wherein the semantic parsing graph is used to represent the corresponding semantic relationship between each character text in the query sentence;
[0137] A statement expansion module 720 is used to sort and combine entity character texts in the query statement according to the semantic analysis graph to obtain at least one expanded statement corresponding to the query statement;
[0138] The attention calculation module 730 is used to calculate the retrieval attention of each entity character text in each expanded sentence by using the distribution position information of each entity character text in the expanded sentence. The retrieval attention is used to represent the importance of the entity character text in the retrieval process;
[0139] The knowledge base search module 740 is used to search the knowledge base according to the search attention of each entity character text in each expansion sentence to obtain the search result corresponding to the query sentence.
[0140] In the knowledge base retrieval system based on the large model provided by the embodiment of the present invention, the query statement input by the user is firstly text-splitting, and a semantic parsing graph representing the corresponding semantic relationship between each character text in the query statement is constructed. Thus, according to the semantic parsing graph, the query statement is expanded to obtain multiple expanded statements. Then, according to the distribution position information of each entity character text in the expanded statement, the retrieval attention of each entity character text in the expanded statement is calculated. Thus, according to the retrieval attention of each entity character text in the expanded statement, the knowledge base can be searched to obtain the retrieval result corresponding to the query statement. In this way, the embodiment of the present invention expands the query statement to obtain multiple expanded statements, and according to the distribution position information of each entity character text in the expanded statement, the corresponding retrieval attention is set for each entity character text. The richness and diversity of the query statement text expression caused by the different entity positions in the query statement are fully considered, so as to improve the accuracy of the retrieval.
[0141] It should be clear that the present invention is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present invention.
[0142] It should also be noted that the exemplary embodiments mentioned in the present invention describe some methods or systems based on a series of steps or devices. However, the present invention is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiments, or in a different order from the embodiments, or several steps can be performed simultaneously.
[0143] The above is only a specific implementation of the present invention. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the system, module and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. It should be understood that the protection scope of the present invention is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be covered within the protection scope of the present invention.
Claims
1. A knowledge base retrieval method based on a large model, characterized in that: include: Performing text splitting on the query statement input by the user to construct a semantic parsing graph corresponding to the query statement, wherein the semantic parsing graph is used to represent the corresponding semantic relationship between each character text in the query statement; According to the semantic parsing graph, the entity character texts in the query statement are sorted and combined to obtain at least one extended statement corresponding to the query statement; For each of the extended sentences, the target similarity of each non-entity character text in the attention window of the entity character text is calculated, and the retrieval attention of the entity character text is calculated in combination with the non-entity character text ratio in the attention window, and the retrieval attention is used to characterize the importance of the entity character text in the retrieval process; The method for obtaining the retrieval attention is as follows: obtaining a first entity sequence of the extended sentence, wherein the first entity sequence is used to represent the order between entity character texts in the extended sentence; The entity character texts in the first entity sequence that are located at adjacent positions of the extended sentence are merged to form a second entity sequence of the extended sentence; for each entity character text in the second entity sequence, non-entity character texts on both sides of the entity character text are sequentially obtained until other entity character texts are reached to obtain an attention window of the entity character text; according to the attention window of each entity character text in the extended sentence, the retrieval attention of each entity character text in the extended sentence is calculated; According to the retrieval attention of each entity character text in each of the expanded sentences, the knowledge base is searched to obtain the retrieval result corresponding to the query sentence.
2. The knowledge base retrieval method based on a large model according to claim 1 is characterized in that: The text splitting of the query statement input by the user to construct a semantic parsing graph corresponding to the query statement includes: Obtaining a query statement input by the user; By using a long short-term memory network, the query statement is subjected to text segmentation to obtain character texts corresponding to the query statement; According to the semantic relationship between the character texts corresponding to the query statement, a semantic parsing graph corresponding to the query statement is constructed.
3. The knowledge base retrieval method based on a large model according to claim 2 is characterized in that: The query statement is subjected to text splitting by the long short-term memory network to obtain character texts corresponding to the query statement, including: Inputting the query sentence into the encoder of the long short-term memory network for encoding to obtain a sentence vector corresponding to the query sentence; The sentence vector is input into the decoder of the long short-term memory network for decoding to obtain the character texts corresponding to the query sentence.
4. The knowledge base retrieval method based on a large model according to claim 1 is characterized in that: The step of calculating the retrieval attention of each entity character text in the extended sentence according to the attention window of each entity character text in the extended sentence includes: Dividing the attention window of the entity character text into a first window and a second window according to the position of the entity character text in the attention window; According to the amount of the non-entity character texts in the first window and the second window, a non-entity character text ratio of the attention window is obtained; The retrieval attention of the entity character text is calculated based on the target similarity of each non-entity character text in the attention window and the ratio of the non-entity character text. The target similarity is used to represent the maximum value of the similarity between the non-entity character text and each similar non-entity character text. The similar non-entity character text is used to represent each non-entity character text included in the attention window corresponding to the entity character text in each other extended sentence.
5. The knowledge base retrieval method based on a large model according to claim 4 is characterized in that: The step of calculating the retrieval attention of the entity character text according to the target similarity of each of the non-entity character texts in the attention window and the non-entity character text ratio includes: Determine a similarity average and a similarity standard deviation by using the target similarities of each of the non-entity character texts in the attention window; For each of the non-entity character texts in the attention window, the difference between the target similarity of the non-entity character text and the similarity average value is divided by the similarity standard deviation and then the result is squared to obtain a similarity calculation value of the non-entity character text; The accumulated value of the similarity calculation values of each non-entity character text is multiplied by the non-entity character text ratio, and then divided by the number of the non-entity character texts in the attention window to obtain the retrieval attention of the entity character text.
6. The knowledge base retrieval method based on a large model according to claim 1 is characterized in that: Before calculating the retrieval attention of each entity character text in the expanded sentence by using the distribution position information of each entity character text in the expanded sentence, the method further includes: Determine the language ambiguity weight of each of the extended sentences by using the first entity sequence corresponding to each of the extended sentences and the third entity sequence corresponding to the query sentence; Performing linear normalization processing on the language ambiguity weight of each of the extended sentences to obtain the normalized language ambiguity weight of each of the extended sentences; Screening out the extended sentences whose normalized language ambiguity weight is greater than a preset weight threshold to obtain an optimized extended sentence; The step of calculating the retrieval attention of each entity character text in the expanded sentence by using the distribution position information of each entity character text in the expanded sentence for each expanded sentence includes: For each of the optimized and extended sentences, the retrieval attention of each of the entity character texts in the optimized and extended sentences is calculated using the distribution position information of each of the entity character texts in the optimized and extended sentences.
7. The knowledge base retrieval method based on a large model according to claim 6 is characterized in that: The determining the language ambiguity weight of each of the extended sentences by using the first entity sequence corresponding to each of the extended sentences and the third entity sequence corresponding to the query sentence includes: Compare the first entity sequence corresponding to the extended sentence with the third entity sequence corresponding to the query sentence to obtain the target number of characters whose positions of the entity character texts in the first entity sequence and the third entity sequence are different; Dividing the target number of characters by the total number of entity character texts of the extended sentence to obtain a first quantity ratio; Dividing the number of character texts in the expanded sentence by the number of character texts in the query sentence to obtain a second number ratio; The first quantity ratio is multiplied by the second quantity ratio to obtain the language ambiguity weight of the extended sentence.
8. The knowledge base retrieval method based on a large model according to claim 1 is characterized in that: The step of searching the knowledge base according to the search attention of each entity character text in each of the expanded sentences to obtain the search result corresponding to the query sentence includes: According to the retrieval attention of each entity character text in the extended sentence, the character weight of each entity character text in the extended sentence is set respectively; Calculating, according to the character weights of the entity character texts in the extended sentence, the relevance scores of the initial search records obtained by searching the knowledge base by the extended sentence; Each of the initial search records in the expanded statements whose relevance score is greater than a preset relevance threshold is determined as a search result corresponding to the query statement.
9. A knowledge base retrieval system based on a large model, characterized in that: include: A parsing graph construction module is used to perform text splitting on a query statement input by a user, and construct a semantic parsing graph corresponding to the query statement, wherein the semantic parsing graph is used to represent the corresponding semantic relationship between each character text in the query statement; A statement expansion module, used for sorting and combining entity character texts in the query statement according to the semantic parsing graph to obtain at least one expansion statement corresponding to the query statement; An attention calculation module is used to calculate the target similarity of each non-entity character text in the attention window of the entity character text for each of the extended sentences, and calculate the retrieval attention of the entity character text in combination with the non-entity character text ratio in the attention window, wherein the retrieval attention is used to characterize the importance of the entity character text in the retrieval process; The method for obtaining the retrieval attention is as follows: obtaining a first entity sequence of the extended sentence, wherein the first entity sequence is used to represent the order between entity character texts in the extended sentence; The entity character texts in the first entity sequence that are located at adjacent positions of the extended sentence are merged to form a second entity sequence of the extended sentence; for each entity character text in the second entity sequence, non-entity character texts on both sides of the entity character text are sequentially obtained until other entity character texts are reached to obtain an attention window of the entity character text; according to the attention window of each entity character text in the extended sentence, the retrieval attention of each entity character text in the extended sentence is calculated; The knowledge base search module is used to search the knowledge base according to the search attention of each entity character text in each of the expanded sentences to obtain the search results corresponding to the query sentence.
Citation Information
Patent Citations
Intelligent semantic retrieval method based on cultural relic knowledge graph
CN111522910A
Intelligent question and answer method and system based on tourism knowledge graph
CN113535917A