Nuclear power knowledge base retrieval method and system fusing semantic features and keywords
Through the fusion of semantic features and keyword features through the neural network model, combined with the large language model, the problem of low recall and precision caused by representation deviation in nuclear power knowledge base retrieval is solved, and more efficient information retrieval and computing performance are achieved.
Patent Information
- Application Number
- CN202410802857.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2024-09-10
AI Technical Summary
Among the existing nuclear power knowledge base retrieval technologies, full-text retrieval has a low recall rate due to deviations in expressions, pure semantic retrieval cannot accurately retrieve specific content, and the relevance evaluation indicators are different when integrating semantic retrieval and full-text retrieval results, making it impossible to effectively rank.
The neural network model is used to fuse semantic features and keyword features, and dense vectors and sparse weight vectors are extracted by segmenting text fragments. The semantic features and keyword weights of query statements are calculated based on the large language model, and a hierarchical index is established to achieve sorting and sorting of retrieval results. Integrate.
It improves the effective information density of retrieval results, improves calculation speed, reduces hardware requirements, realizes the complementary advantages of semantic and full-text retrieval, and enhances retrieval recall and accuracy.
Smart Images

Figure CN118626591A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of information retrieval, and in particular to a nuclear power knowledge base retrieval method and system integrating semantic features and keywords. Background Art
[0002] The statements in this section merely provide background information related to the present invention and do not necessarily constitute prior art.
[0003] The efficiency of the knowledge base retrieval algorithm is the core of realizing the effective implementation of the nuclear power knowledge base. The current nuclear power knowledge base retrieval technology is mainly divided into two categories: semantic retrieval and full-text retrieval. Semantic retrieval technology can retrieve semantically related texts by understanding the user's query intent and the semantic connection between the query content, and can find relevant information even if the user's wording is not accurate enough. This is crucial to improving the flexibility of retrieval and user experience. However, its disadvantage is that it is difficult to accurately locate specific data points, which is particularly prominent in situations where accurate information is required. On the other hand, full-text retrieval, with its ability to accurately lock keywords, performs well in ensuring retrieval accuracy. However, the limitation of this method is that once the user's expression deviates from the keywords in the data, the retrieval effect will be greatly reduced, which may lead to missed information in practical applications. Summary of the invention
[0004] In order to solve the problems that the full-text search has a low recall rate due to the deviation between the expression of the target text and the search statement; the pure semantic search can only be based on semantic fuzzy search and cannot accurately search for a specific content; when the full-text search results and the semantic search results are integrated, due to the different relevance evaluation indicators, they cannot be integrated to obtain an effective ranking, etc., the present invention provides a nuclear power knowledge base retrieval method and system that integrates semantic features and keywords. The present invention integrates semantic features and keyword features to achieve complementary advantages of the two methods.
[0005] In order to achieve the above object, the present invention adopts the following technical solution:
[0006] The first aspect of the present invention provides a nuclear power knowledge base retrieval method integrating semantic features and keywords.
[0007] A nuclear power knowledge base retrieval method integrating semantic features and keywords, comprising:
[0008] The input document related to nuclear power is obtained, and the document is divided into a plurality of text segments whose length is less than a first set value; based on the text segment, a neural network is used to extract text features, and based on the text features, a feedforward neural network is used to obtain a hidden state; a state vector at a specified position in the hidden state is extracted as a dense vector of the semantic features of the text segment; based on the state vectors of all positions in the hidden state, a sparse weight vector of a keyword in the text segment is calculated; a hierarchical index is established between the text segment and the dense vector and the sparse weight vector, so as to construct a nuclear power knowledge base;
[0009] Based on the user input content, a large language model is used to reassemble several query statements, and the dense vectors of the semantic features of all query statements and the sparse weight vectors of keywords are calculated. Based on the similarity calculation, the corresponding search results in the nuclear power knowledge base are found; the search results are spliced with the user input content to calculate the hidden state vector; based on the hidden state vector, the relevance score is calculated; the search results are sorted according to the relevance score to obtain the final search results.
[0010] Furthermore, before using the neural network, the method includes: using a word segmenter to convert the text fragment into a character list, and converting the character list into a token list according to the token_id mapping relationship of the word segmenter. If there is no mapping relationship, using <unk>Flag replacement; insert at the front of the token list <cls>Signs and use <pad>Flag to pad the token list to length N.
[0011] Furthermore, the process of obtaining a hidden state by using a feedforward neural network based on text features; extracting a state vector at a specified position in the hidden state as a dense vector of semantic features of a text segment; and calculating a sparse weight vector of keywords of a text segment based on the state vectors of all positions in the hidden state includes: extracting text features by using a neural network based on a token list, obtaining a hidden state by using a feedforward neural network based on the text features, and extracting the hidden state. <cls>The state vector of the flag bit is used as a dense vector of the semantic features of the text fragment; based on the state vectors of all positions in the hidden state, the weight of each token list is calculated and the flag is deleted. <cls> 、 <pad> 、 <unk>The weight of is used as the sparse weight vector of the text segment keywords.
[0012] Furthermore, the process of reassembling several query statements based on user input content using a large language model includes: using a large language model to decompose the user input content, extracting the user's intention, the resources that need to be accessed, and the restrictions, and using the decomposed information to reassemble into Q query statements, each question covering different intentions, resources, and conditions.
[0013] Furthermore, after obtaining the search results, the method further includes: sorting the search results in descending order according to the scores, and eliminating the search results with scores lower than the screening threshold p; obtaining the original text fragment corresponding to the construction of the search results as the search results based on the vector index; if the number of remaining search results is lower than the search number limit S, directly returning the results; if the number of remaining search results is higher than the search number limit, using the large language model in combination with the user input content to extract relevant information from each search result as the final result.
[0014] Furthermore, the process of concatenating the search results with the user input content and calculating the hidden state vector; and calculating the relevance score based on the hidden state vector includes: converting the search results and the user input content into a token list using a tokenizer; concatenating the search results with the token list of the user input content, and using <sep>Identifiers are separated, and the specific concatenation format is <bos>[Search results] <sep>[User input] <eos>and use <pad>The flag fills the token list to a length of N; the token list is input into the neural network to obtain the hidden state vector; the hidden state vector is input into the fully connected layer, the output of the fully connected layer is connected to the sigmoid function to obtain the result, and the first value of the output is taken as the relevance score.
[0015] Furthermore, the process of obtaining an input document related to nuclear power and segmenting it into multiple text segments whose lengths are less than a set value includes: segmenting the input document related to nuclear power into several sentences according to a segmentation identifier; splitting a complete table into multiple sub-tables, and the length of the table content does not exceed a second set value; and synthesizing adjacent sentences into text segments.
[0016] The second aspect of the present invention provides a nuclear power knowledge base retrieval system integrating semantic features and keywords.
[0017] A nuclear power knowledge base retrieval system integrating semantic features and keywords, comprising:
[0018] A knowledge base construction module is configured to: obtain input documents related to nuclear power and divide them into multiple text segments with lengths less than a first set value; extract text features based on the text segments using a neural network, and obtain hidden states based on the text features using a feedforward neural network; extract state vectors at specified positions in the hidden states as dense vectors of semantic features of the text segments; calculate sparse weight vectors of keywords in the text segments based on the state vectors at all positions in the hidden states; establish hierarchical indexes between text segments and dense vectors and sparse weight vectors, thereby constructing a nuclear power knowledge base;
[0019] The retrieval module is configured as follows: based on the user input content, using a large language model, reassembling several query statements, calculating the dense vectors of the semantic features of all query statements and the sparse weight vectors of keywords, and finding the corresponding retrieval results in the nuclear power knowledge base based on the similarity calculation; splicing the retrieval results with the user input content and calculating the hidden state vector; calculating the relevance score based on the hidden state vector; sorting the retrieval results according to the relevance score to obtain the final retrieval result.
[0020] A third aspect of the present invention provides a computer-readable storage medium.
[0021] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps in the nuclear power knowledge base retrieval method integrating semantic features and keywords as described in the first aspect above.
[0022] A fourth aspect of the present invention provides a computer device.
[0023] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in the nuclear power knowledge base retrieval method integrating semantic features and keywords as described in the first aspect above are implemented.
[0024] Compared with the prior art, the present invention has the following beneficial effects:
[0025] In order to solve the problems that full-text retrieval has a low retrieval recall rate due to the deviation between the expression of the target text and the retrieval statement; pure semantic retrieval can only be based on semantic fuzzy retrieval and cannot accurately retrieve a specific content; when the full-text retrieval results and the semantic retrieval results are integrated, they cannot be integrated to obtain an effective ranking due to different relevance evaluation indicators, the present invention provides a nuclear power knowledge base retrieval method and system that integrates semantic features and keywords. The present invention integrates semantic features and keyword features to achieve complementary advantages of the two methods.
[0026] The present invention uses a neural network model to fuse and reorder dense vector and sparse vector search results. Compared with algorithms based on numerical values and distributions, it can achieve reordering based on the semantic relevance between texts, and the results are more reasonable.
[0027] The present invention uses a large model to simplify the search results, improves the effective information density of the search results, reduces the amount of calculation for subsequent re-ranking using a neural network model, improves the calculation speed, and reduces the hardware requirements for algorithm calculations. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0029] Figure 1 It is a flow chart of a nuclear power knowledge base retrieval method integrating semantic features and keywords shown in the present invention. DETAILED DESCRIPTION
[0030] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0031] It should be noted that the following detailed descriptions are all illustrative and intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.
[0032] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0033] It should be noted that the flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the methods and systems according to various embodiments of the present disclosure. It should be noted that each box in the flowchart or block diagram can represent a module, a program segment, or a part of a code, and the module, program segment, or a part of a code may include one or more executable instructions for implementing the logical functions specified in each embodiment. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, or they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the flowchart and / or block diagram, and the combination of boxes in the flowchart and / or block diagram can be implemented using a dedicated hardware-based system that performs a specified function or operation, or can be implemented using a combination of dedicated hardware and computer instructions.
[0034] Embodiment 1
[0035] The present embodiment provides a nuclear power knowledge base retrieval method that integrates semantic features and keywords. The present embodiment uses the method applied to a server as an example for illustration. It is understandable that the method can also be applied to a terminal, and can also be applied to a terminal, a server, and a system, and is implemented through the interaction between the terminal and the server. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network servers, cloud communications, middleware services, domain name services, security services CDN, and big data and artificial intelligence platforms. The terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected via wired or wireless communication, which is not limited in this application. In the present embodiment, the method includes the following steps:
[0036] The input document related to nuclear power is obtained, and the document is divided into a plurality of text segments whose length is less than a first set value; based on the text segment, a neural network is used to extract text features, and based on the text features, a feedforward neural network is used to obtain a hidden state; a state vector at a specified position in the hidden state is extracted as a dense vector of the semantic features of the text segment; based on the state vectors of all positions in the hidden state, a sparse weight vector of a keyword in the text segment is calculated; a hierarchical index is established between the text segment and the dense vector and the sparse weight vector, so as to construct a nuclear power knowledge base;
[0037] Based on the user input content, a large language model is used to reassemble several query statements, and the dense vectors of the semantic features of all query statements and the sparse weight vectors of keywords are calculated. Based on the similarity calculation, the corresponding search results in the nuclear power knowledge base are found; the search results are spliced with the user input content to calculate the hidden state vector; based on the hidden state vector, the relevance score is calculated; the search results are sorted according to the relevance score to obtain the final search results.
[0038] The present embodiment is described in detail below. The method described in the present embodiment includes the following steps: Figure 1 As shown:
[0039] Step S1: Segment a long input document into multiple text segments whose lengths are less than a set value N. The specific steps are as follows:
[0040] Step S11: Split the text into several sentences according to the segmentation identifier, where the identifier includes half-width punctuation marks, full-width punctuation marks, line breaks, and tabs. If a table is encountered, the entire table is retained intact;
[0041] Step S12: split the complete table into multiple sub-tables, the length of the table content does not exceed the set value N, and copy the header of the complete table to the truncated part to obtain multiple table fragments;
[0042] Step S13: merge adjacent sentences into segments, and control the number of words in the segment not to exceed the set value N. If it exceeds, the exceeding paragraph is used as the beginning of a new paragraph. If a page break is encountered, the current segment is forcibly terminated and a new segment is started to continue merging. Repeat this operation until all sentences are merged to obtain multiple text segments.
[0043] Compared with the prior art, the present invention can maintain the semantic integrity of text segments and table structure as much as possible, and will not lose the semantic information of the text and the structural information of the table during the search. At the same time, slicing the text helps to speed up the subsequent neural network calculation, and is also conducive to making the dense vector of the semantic features of the text segments more concentrated, thereby improving the retrieval recall rate.
[0044] Step S2: Use the neural network model to calculate the dense vector of the semantic features of the text segment and the sparse weight vector of the keyword. The specific steps are as follows:
[0045] Step S21: Use a tokenizer to convert the text segment into a character list, and convert the character list into a token list according to the token_id mapping relationship of the tokenizer. If there is no mapping relationship, use <unk>Flag bit replacement.
[0046] Step S22: Insert at the front of the token list <cls>Sign token, used to extract text semantic features; and use <pad>Flag to pad the token list to length N.
[0047] Step S23: Input the token list into the neural network model, extract text features with the help of the multi-head self-attention mechanism, and input the output of the attention mechanism into the feedforward neural network to obtain the hidden state H (l) The feedforward neural network formula is as follows:
[0048] H (l) =FFN(O multi-head )=ReLU(O multi-head W 1 +b 1 )W 2 +b 2
[0049] in, are trainable weights and biases. tsf After the layer Transformer encoder, the final hidden state vector H is obtained:
[0050] Where H = [h 1 ,h 2 ,...,h n ], Represents the hidden state vector of the i-th token.
[0051] Step S24: Get the hidden state vector <cls>The state vector of the mark bit, i.e. h 1 Dense vectors that serve as semantic features of text snippets;
[0052] Step S25: Use the state vectors of all positions of the hidden state vector to calculate the weight of each token and remove the markers <cls> 、 <pad> 、 <unk>The weight of is used as the sparse weight vector of the text keyword. The calculation formula is as follows:
[0053] w i =sigmod(h i W w +b w )
[0054] in, is the weight matrix, w i represents the weight of the i-th token, b w is bias.
[0055] Compared with the prior art, the present invention uses a neural network model to calculate the hidden state of the text, and then obtains the dense vector and sparse vector of the text through different post-processing calculation methods. Compared with using two independent models for calculation, it saves the amount of calculation, improves the calculation speed, and reduces the hardware requirements for running the algorithm.
[0056] Step S3: Establish a hierarchical index of text segments, dense vectors, and sparse weight vectors. The specific steps are as follows:
[0057] Step S31: Calculate the semantic feature weight of the dense vector. Take the dense vectors of all text segments in the document, calculate the center point of the vector, and use the cosine similarity between the vector and the center point as the semantic feature weight of the text segment. The calculation formula of the center point is as follows:
[0058]
[0059] Among them, v i =[v i1 ,v i2 ,...,v id ] is each vector. The formula for calculating cosine similarity is as follows:
[0060]
[0061] Step S32: Randomly determine the level at which the vector to be inserted is located. The higher the level, the lower the frequency of occurrence of the node in the graph. The present invention introduces the weight W of the semantic feature so that semantically closer nodes are more likely to be at the same level, thereby improving the retrieval speed. The calculation formula for the level is:
[0062]
[0063] Among them, uniform(0,1) represents a random number uniformly drawn in the interval (0,1), M is the parameter controlling the hierarchical distribution, and W is the semantic feature weight;
[0064] Step S33: Starting from the highest level, use the greedy algorithm to search for the node closest to the new node in each level until the target level of the new node is reached. The calculation formula for the distance between nodes is:
[0065]
[0066] Among them, a and b are two vectors whose distance needs to be calculated;
[0067] Step S34: Starting from the target level, insert the new node layer by layer downward. At each level, use the greedy algorithm to find the k nodes closest to the new node in that level, and connect the new node to these nodes; the specific steps are as follows:
[0068] Step S341: Initialize an empty set to store the found nodes closest to the new node;
[0069] Step S342: traverse all nodes of the current level, calculate the distance between each node and the new node, and store the distance between each node and the new node as the key and the node identifier as the value in a priority queue;
[0070] Step S343: Take the node with the smallest distance from the priority queue. If the node is already in the set, skip it; otherwise, add it to the set.
[0071] Step S344: Repeat step S343 until the number of nodes in the set reaches k, or the priority queue is empty;
[0072] Step S345: Connect the new node to all nodes in the set.
[0073] Step S35: In order to maintain the density of the graph, it may be necessary to prune the connections at each layer to ensure that the number of neighbors of each node does not exceed the preset maximum value e f The specific pruning steps are: starting from the highest layer, perform the following steps on each layer:
[0074] Step S351: traverse all nodes in the current layer, and for each node, count the number of its neighbor nodes;
[0075] Step S352: If the number of neighbors of a node exceeds the preset maximum value e f , then delete the redundant neighbor nodes in order of distance from the node, from far to near.
[0076] Text fragments have unique IDs and are stored separately without stratification. Vector-ID is stored in a graph structure in a hierarchical manner as KV key-value pairs. The steps for indexing text fragments and dense vectors are described above. The logic of sparse vector operations is similar to the above method.
[0077] Compared with the existing technology, this operation can ensure that the number of neighbors of each node does not exceed the preset maximum value while maintaining the density of the graph, reducing the space required for storage, improving the retrieval speed, and reducing the retrieval complexity.
[0078] Step S4: Analyze the user input content using the large language model and reassemble it into Q query statements. The specific steps are as follows:
[0079] Step S41: Use the large language model to decompose the user input intention and extract the user intention, the resources to be accessed, and the restriction conditions;
[0080] Step S42: Use the decomposed information to reassemble into Q query statements, each question covering different intentions, resources, and conditions.
[0081] Compared with the prior art, the present invention solves the problem of incomplete query results caused by multiple intents contained in a single query statement of a user by decomposing the query statement, thereby improving the recall rate of the retrieval.
[0082] Step S5: Use the neural network model to calculate the dense vectors of the semantic features of all query statements and the sparse weight vectors of the keywords. The calculation operation is the same as step S2, with the following differences:
[0083] When calculating dense vectors, query instructions are concatenated before the text to improve the s2p retrieval recall rate.
[0084] Step S6: Calculate the cosine distance between the dense vector and the sparse vector and the corresponding vector in the knowledge base as the score. The specific steps are as follows:
[0085] Step S61: Starting from the highest layer, select an entry point of the layer as the starting point;
[0086] Step S62: Use a greedy algorithm to search for the node closest to the target node in each layer. When the nearest node is found in the current layer, move to the next layer and use this node as the new starting point to continue searching;
[0087] Step S63: At the bottom layer (layer 0) of the graph, a final greedy search is performed until the k nodes closest to the target node are found.
[0088] Step S7: Eliminate the results with scores lower than the threshold p and simplify the search result content. The specific steps are as follows:
[0089] Step S71: sort the search results in descending order of scores, and remove the search results with scores lower than the screening threshold p;
[0090] Step S72: according to the vector index, obtaining the original text segment corresponding to the search result construction as the search result;
[0091] Step S73: If the number of remaining search results is less than the search limit S, the results are returned directly; if the number of remaining search results is greater than the search limit, the large language model is used in combination with the original user input to extract relevant information from each search result as the final result. The calculation formula for the search limit is as follows:
[0092] S=Q×k
[0093] Among them, Q is the number of expansion questions, and k is the number of nodes closest to the vector retrieval.
[0094] Compared with the prior art, the present invention uses a large model to streamline the search results, improves the effective information density of the search results, reduces the amount of calculation for subsequent re-ranking using a neural network model, improves the calculation speed, and reduces the hardware requirements for algorithm calculations.
[0095] Step S8: Calculate the relevance of the simplified results using a neural network model and re-rank them. The specific steps are as follows:
[0096] Step S81: convert the search results and user input into a token list using a tokenizer, which is the same as step S21 of step S2;
[0097] Step S82: Join the search results with the token list entered by the user, using <sep>Identifiers are separated, and the specific concatenation format is <bos>[Search results] <sep>[User input] <eos>and use <pad>The flag fills the token list to length N;
[0098] Step S83: Input the token list into the neural network model to obtain the hidden state vector H, which is the same as step S23 of step S2;
[0099] Step S84: Input the hidden state vector H into a fully connected layer with a length of 2, connect the output to the sigmoid function to obtain the result, and take the first value of the output as the relevance score.
[0100] Step S85: Sort the search results according to the relevance scores as the final search results.
[0101] Compared with the prior art, the present invention uses a neural network model to fuse and reorder the dense vector and sparse vector search results. Compared with algorithms based on numerical values and distributions, it can achieve reordering based on the semantic relevance between texts, and the results are more reasonable.
[0102] Taking a device manual as an example, set the document segmentation length setting value N = 500, the encoder layer number L tsf =5 Insert hierarchical distribution parameter M = 32, the number of nearest nodes k = 16, the maximum number of neighbors of a node e f =100, number of reorganization questions Q=3, and relevance score screening threshold p=0.5.
[0103] The document has a total of 3719 words and contains a table. After segmentation, the lengths of the text segments are 496, 482, 439, 208, 463, and 487 respectively. The table is segmented into three sub-tables with lengths of 423, 479, and 242.
[0104] The experiment set up two categories of 10 questions, corresponding to 5 different retrieval targets, to test the precise retrieval ability and semantic retrieval ability of different algorithms. For example, retrieval target 1 is:
[0105] DISTRIB_ID=Ubuntu
[0106] DISTRIB_RELEASE=22.04
[0107] DISTRIB_CODENAME=jammy
[0108] DISTRIB_DESCRIPTION="Ubuntu22.04.3LTS"
[0109] Question 1 is "What is the value of DISTRIB_DESCRIPTION?" Question 2 is "What is the description of the distribution?". Question 1 gives the same keywords in the retrieval target to test the precise retrieval ability of the retrieval algorithm; Question 2 uses Chinese keywords to search for English targets to test the semantic retrieval ability of the retrieval algorithm. The complete test results are shown in Table 1.
[0110] Table 1 Complete test results
[0111]
[0112]
[0113] Compared with the existing technical projects, the present invention can well integrate the capabilities of semantic and full-text retrieval and has a good retrieval hit rate.
[0114] Embodiment 2
[0115] This embodiment provides a nuclear power knowledge base retrieval system that integrates semantic features and keywords.
[0116] A nuclear power knowledge base retrieval system integrating semantic features and keywords, comprising:
[0117] A knowledge base construction module is configured to: obtain input documents related to nuclear power and divide them into multiple text segments with lengths less than a first set value; extract text features based on the text segments using a neural network, and obtain hidden states based on the text features using a feedforward neural network; extract state vectors at specified positions in the hidden states as dense vectors of semantic features of the text segments; calculate sparse weight vectors of keywords in the text segments based on the state vectors at all positions in the hidden states; establish hierarchical indexes between text segments and dense vectors and sparse weight vectors, thereby constructing a nuclear power knowledge base;
[0118] The retrieval module is configured as follows: based on the user input content, using a large language model, reassembling several query statements, calculating the dense vectors of the semantic features of all query statements and the sparse weight vectors of keywords, and finding the corresponding retrieval results in the nuclear power knowledge base based on the similarity calculation; splicing the retrieval results with the user input content and calculating the hidden state vector; calculating the relevance score based on the hidden state vector; sorting the retrieval results according to the relevance score to obtain the final retrieval result.
[0119] It should be noted that the above-mentioned knowledge base construction module and retrieval module are the same as the examples and application scenarios implemented by the steps in Embodiment 1, but are not limited to the contents disclosed in Embodiment 1. It should be noted that the above-mentioned modules as part of the system can be executed in a computer system such as a set of computer executable instructions.
[0120] Embodiment 3
[0121] This embodiment provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the nuclear power knowledge base retrieval method integrating semantic features and keywords as described in the first embodiment above are implemented.
[0122] Embodiment 4
[0123] This embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps in the nuclear power knowledge base retrieval method integrating semantic features and keywords as described in the first embodiment above are implemented.
[0124] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.
[0125] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0126] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0127] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0128] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0129] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.< / pad> < / eos> < / sep> < / bos> < / sep> < / unk> < / pad> < / cls> < / cls> < / pad> < / cls> < / unk> < / pad> < / eos> < / sep> < / bos> < / sep> < / unk> < / pad> < / cls> < / cls> < / pad> < / cls> < / unk>
Claims
1. A nuclear power knowledge base retrieval method integrating semantic features and keywords, characterized in that: include: The input document related to nuclear power is obtained, and the document is divided into a plurality of text segments whose length is less than a first set value; based on the text segment, a neural network is used to extract text features, and based on the text features, a feedforward neural network is used to obtain a hidden state; a state vector at a specified position in the hidden state is extracted as a dense vector of the semantic features of the text segment; based on the state vectors of all positions in the hidden state, a sparse weight vector of a keyword in the text segment is calculated; a hierarchical index is established between the text segment and the dense vector and the sparse weight vector, so as to construct a nuclear power knowledge base; Based on the user input content, a large language model is used to reassemble several query statements, and the dense vectors of the semantic features of all query statements and the sparse weight vectors of keywords are calculated. Based on the similarity calculation, the corresponding search results in the nuclear power knowledge base are found; the search results are spliced with the user input content to calculate the hidden state vector; based on the hidden state vector, the relevance score is calculated; the search results are sorted according to the relevance score to obtain the final search results.
2. The nuclear power knowledge base retrieval method integrating semantic features and keywords according to claim 1 is characterized in that: Before using the neural network, the method includes: using a word segmenter to convert the text fragment into a character list, and converting the character list into a token list according to the token_id mapping relationship of the word segmenter. If there is no mapping relationship, use <unk>Flag replacement; insert at the front of the token list <cls>Signs and use <pad> Flag to pad the token list to length N.< / pad> < / cls> < / unk> 3. The nuclear power knowledge base retrieval method integrating semantic features and keywords according to claim 2 is characterized in that: Based on the text features, a feedforward neural network is used to obtain a hidden state; a state vector at a specified position in the hidden state is extracted as a dense vector of the semantic features of the text segment; The process of calculating the sparse weight vector of the keywords of the text segment based on the state vectors of all positions in the hidden state includes: extracting text features based on the token list by using a neural network, and obtaining the hidden state by using a feedforward neural network based on the text features; Extracting hidden states <cls>The state vector of the flag bit is used as a dense vector of the semantic features of the text fragment; based on the state vectors of all positions in the hidden state, the weight of each token list is calculated and the flag is deleted. <cls> 、 <pad> 、 <unk> The weight of is used as the sparse weight vector of text keywords.< / unk> < / pad> < / cls> < / cls> 4. The nuclear power knowledge base retrieval method integrating semantic features and keywords according to claim 1 is characterized in that: The process of reassembling several query statements based on user input content using a large language model includes: using a large language model to decompose the user input content, extracting the user's intention, the resources that need to be accessed, and the restrictions, and using the decomposed information to reassemble into Q query statements, each question covering different intentions, resources, and conditions.
5. The nuclear power knowledge base retrieval method integrating semantic features and keywords according to claim 1 is characterized in that: After obtaining the search results, the process also includes: sorting the search results in descending order according to the scores, and eliminating the search results with scores lower than the screening threshold p; obtaining the original text fragment corresponding to the construction of the search results as the search results based on the vector index; if the number of remaining search results is lower than the search number limit S, directly returning the results; if the number of remaining search results is higher than the search number limit, using the large language model combined with the user input content to extract relevant information from each search result as the final result.
6. The nuclear power knowledge base retrieval method integrating semantic features and keywords according to claim 1 is characterized in that: The search results are concatenated with the user input content to calculate the hidden state vector; Based on the hidden state vector, the process of calculating the relevance score includes: converting the search results and user input content into a token list using a tokenizer; Concatenate the search results with the token list of the user input content, using <sep>Identifiers are separated, and the specific concatenation format is <bos>[Search results] <sep>[User input] <eos>and use <pad> The flag fills the token list to a length of N; the token list is input into the neural network to obtain the hidden state vector; the hidden state vector is input into the fully connected layer, the output of the fully connected layer is connected to the sigmoid function to obtain the result, and the first value of the output is taken as the relevance score.< / pad> < / eos> < / sep> < / bos> < / sep> 7. The nuclear power knowledge base retrieval method integrating semantic features and keywords according to claim 1 is characterized in that: The process of obtaining an input document related to nuclear power and dividing it into multiple text segments with a length less than a set value includes: dividing the input document related to nuclear power into several sentences according to a segmentation identifier; splitting a complete table into multiple sub-tables, and the length of the table content does not exceed a second set value; and synthesizing adjacent sentences into text segments.
8. A nuclear power knowledge base retrieval system integrating semantic features and keywords, characterized in that: include: A knowledge base construction module is configured to: obtain input documents related to nuclear power and divide them into multiple text segments with lengths less than a first set value; extract text features based on the text segments using a neural network, and obtain hidden states based on the text features using a feedforward neural network; extract state vectors at specified positions in the hidden states as dense vectors of semantic features of the text segments; calculate sparse weight vectors of keywords in the text segments based on the state vectors at all positions in the hidden states; establish hierarchical indexes between text segments and dense vectors and sparse weight vectors, thereby constructing a nuclear power knowledge base; The retrieval module is configured as follows: based on the user input content, using a large language model, reassembling several query statements, calculating the dense vectors of the semantic features of all query statements and the sparse weight vectors of keywords, and finding the corresponding retrieval results in the nuclear power knowledge base based on the similarity calculation; splicing the retrieval results with the user input content and calculating the hidden state vector; calculating the relevance score based on the hidden state vector; sorting the retrieval results according to the relevance score to obtain the final retrieval result.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps in the nuclear power knowledge base retrieval method integrating semantic features and keywords as described in any one of claims 1 to 7 are implemented.
10. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps in the nuclear power knowledge base retrieval method integrating semantic features and keywords as described in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Text-to-video cross-modal retrieval method based on multistage coding
CN111309971A
Medical question-and-answer method and system based on context language model and knowledge embedding
CN111524593A
Sentence relevancy obtaining method and system combining loop network and BERT and medium
CN112163429A
Question and answer model training method, question and answer model training device, question and answer method, and question and answer device
CN113961686A
Automatic question answering method and device based on multi-semantic matching, equipment and medium
CN114090747A
Cited By
Life cycle stream data mixed retrieval method and device based on large language model
CN118820407A
Legal provision retrieval method for legal data embedding optimization and retrieval effect evaluation
CN119377384A
Multi-modal document retrieval method and device, electronic equipment and storage medium
CN120030102A
Data search enhanced rearrangement method, system and equipment
CN120067311A
Data search enhancement and rearrangement method, system and device
CN120067311B
