A method, system, device and medium for full-text search enhancement of hydroelectric plant knowledge
By constructing a triple structure encoding model and a target semantic recognition model, combined with an enhanced contrastive learning algorithm, the vocabulary gap and semantic gap problems of traditional full-text retrieval technology in hydropower plant knowledge retrieval are solved, achieving more efficient and accurate knowledge retrieval.
Patent Information
- Application Number
- CN202510592715.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-09
- Publication Date
- 2025-10-14
- Estimated Expiration
- 2045-05-09
AI Technical Summary
Traditional full-text retrieval technology is unable to meet the needs of high-quality and high-precision knowledge retrieval when processing the complex knowledge system of hydropower plants. In particular, when facing users' colloquial or diversified queries, the retrieval is inaccurate and the recall range is limited.
A triple structure encoding model and a target semantic recognition model are constructed, and an enhanced contrastive learning algorithm is introduced. By decomposing query requests, synonym expansion and edit distance calculation, semantic vector encoding and similarity calculation are performed in combination with a vector database, and a momentum update mechanism and a dictionary maintenance strategy are used for secondary sorting.
It improves the accuracy and recall range of search results, ensures that search results better match user needs, and improves the efficiency and accuracy of hydropower plant knowledge management and retrieval.
Smart Images

Figure CN120104777B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of full-text retrieval of hydropower plant knowledge, and in particular to a full-text retrieval enhancement method, system, device and medium for hydropower plant knowledge. BACKGROUND
[0002] In the production management and operation process of a hydropower plant, a large amount of unstructured data such as professional equipment knowledge, operation and maintenance experience, production logs, laws and regulations, and expert experience has been accumulated. Effectively preserving and utilizing these knowledge is of vital importance to improving the production efficiency of the hydropower plant, ensuring stable operation of the equipment, and promoting technological innovation. At present, the traditional full-text retrieval technology has many shortcomings in dealing with such complex knowledge systems, and it is difficult to meet the demand of modern hydropower plants for high-quality and high-precision knowledge retrieval.
[0003] Traditional retrieval methods, such as TF-IDF and BM25 algorithms based on statistics and their derivative tools Elasticsearch and Lucene, mainly rely on the frequency and distribution of words for matching. The core defect of these methods is that they rely too much on the overlap of words between user queries and documents. This mechanism often leads to inaccurate retrieval and limited recall range when facing queries with colloquial, diverse, or different words. For example, when a user queries a knowledge base with informal or colloquial expressions, traditional methods may not be able to effectively match documents that are semantically related but not completely consistent in words, resulting in the omission of important information.
[0004] With the accelerated development of China's energy internet, the knowledge system in the field of electric power is increasingly showing an open, flat, and fuzzy development trend, and the complexity and professionalism of hydropower plant knowledge are further enhanced. Under this background, the limitations of traditional retrieval technology have become more prominent, and it has been unable to meet the needs of modern hydropower plant knowledge management and retrieval. SUMMARY
[0005] To solve the above technical problems, the present application provides the following technical solutions:
[0006] In a first aspect, the present application provides a full-text retrieval enhancement method for hydropower plant knowledge, which includes constructing a triple-structure encoding model and a target semantic recognition model, wherein the target semantic recognition model is trained by introducing an enhanced contrastive learning algorithm into the triple-structure encoding model;
[0007] The obtained query request is decomposed into at least two query keywords, and the decomposed query keywords are expanded to obtain an expanded query request;
[0008] The extended query request is converted into a target semantic vector through a triple structure coding model, and a first similarity calculation is performed on the target semantic vector and the semantic vectors in the vector database to obtain the similarity between the target semantic vector and the semantic vectors in the vector database, relevant documents are recalled according to the similarity, and the recalled documents are preliminarily sorted in descending order of similarity;
[0009] A second similarity calculation is performed on the recalled documents and the extended query request through a target semantic recognition model, and the recalled documents are secondarily sorted in descending order of the calculated similarity to obtain a target retrieval sorting result, wherein the first similarity calculation and the second similarity calculation adopt different manners.
[0010] As a preferred scheme of the full-text retrieval enhancement method of the hydropower plant knowledge, wherein: the triple structure coding model comprises,
[0011] The obtained hydropower plant knowledge documents are preprocessed to obtain target document data;
[0012] An initial triple structure coding model is constructed by using three pre-training models sharing weights as a core network.
[0013] Sentences are extracted from the target document data to form training samples, and the initial triple structure coding model is trained and optimized by using a contrast learning method and combining a vector-based dense retrieval loss function to obtain the triple structure coding model.
[0014] As a preferred scheme of the full-text retrieval enhancement method of the hydropower plant knowledge, wherein: the semantic vector is obtained by coding the target document data through the triple structure coding model;
[0015] The vector database is a database for storing semantic vectors.
[0016] As a preferred scheme of the full-text retrieval enhancement method of the hydropower plant knowledge, wherein: the expansion processing comprises,
[0017] Synonyms semantically similar to the query keywords are selected according to a synonym dictionary and an edit distance calculation to generate an expanded query matrix.
[0018] As a preferred scheme of the full-text retrieval enhancement method of the hydropower plant knowledge, wherein: the extraction of sentences from the target document data to form training samples comprises extraction of multiple groups of sentences from the target document data to form training samples, wherein each group of sentences comprises: an anchored sentence, a positive example sentence and a negative example sentence.
[0019] As a preferred scheme of the full-text retrieval enhancement method of the hydropower plant knowledge, wherein: the formula of the first similarity calculation is:
[0020] ,
[0021] where Similarity is the similarity score; q is the target semantic vector; d is the semantic vector in the vector database; represents the length of the target semantic vector q; represents the length of the semantic vector d in the vector database; is the value of the i-th dimension of the target semantic vector; is the square of the value of the i-th dimension of the target semantic vector; is the value of the i-th dimension of a certain semantic vector in the vector database; is the square of the value of the i-th dimension of a certain semantic vector in the vector database; n is the dimension of the semantic vector, .
[0022] As a preferred scheme of the water power plant knowledge full-text retrieval enhancement method of the application, wherein: the enhanced contrastive learning algorithm loss function is:
[0023] ,
[0024] wherein: is the loss function of the query q; q is the target semantic vector; is the semantic vector representation positively correlated with q; is the semantic vector representation negatively correlated with q; τ is a temperature hyperparameter, and K is the total amount of negative correlation samples; is the similarity score of the positive correlation sample pair ; is the sum of the similarity scores of all negative correlation sample pairs .
[0025] In a second aspect, the application provides a water power plant knowledge full-text retrieval enhancement system, comprising: a construction module for constructing a triple structure coding model and a target semantic recognition model, wherein the target semantic recognition model is obtained by introducing an enhanced contrastive learning algorithm into the triple structure coding model for training;
[0026] A decomposition and expansion module is configured to decompose the obtained query request into at least two query keywords, and expand the decomposed query keywords to obtain an expanded query request;
[0027] The initial filtering module is configured to convert the extended query request into a target semantic vector through a triple structure coding model, and perform a first similarity calculation on the target semantic vector and semantic vectors in a vector database to obtain a similarity between the target semantic vector and the semantic vectors in the vector database, and recall relevant documents according to the similarity, and preliminarily sort the recalled documents in descending order of the similarity.
[0028] The fine filtering module is configured to perform a second similarity calculation on the recalled documents and the extended query request through a target semantic recognition model, and perform a secondary sorting on the recalled documents in descending order of the similarity calculated to obtain a target retrieval sorting result, wherein the first similarity calculation and the second similarity calculation adopt different manners.
[0029] In a third aspect, the present application provides a computer device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the steps of the method as described above when executing the computer program.
[0030] In a fourth aspect, the present application provides a computer readable storage medium storing a computer program, the computer program being executed by a processor to implement the steps of the method as described above.
[0031] Compared with the prior art, the present application has the following beneficial effects: by constructing a triple structure coding model and introducing an enhanced contrast learning algorithm, the problems of lexical gaps and semantic gaps in traditional retrieval methods are effectively solved. Further, the triple structure coding model is used to encode knowledge documents into semantic vectors and store them into a vector database, and at the same time, synonym expansion and edit distance calculation are performed on user queries to expand the recall range and ensure that more potential relevant documents can be obtained. Furthermore, the enhanced contrast learning algorithm is used to perform secondary sorting on the recalled documents, and through the momentum update mechanism and the dictionary maintenance strategy, the understanding and distinguishing ability of the model for document semantics is further improved, so that the final retrieval result can more accurately match the user's demand. BRIEF DESCRIPTION OF DRAWINGS
[0032] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0033] Figure 1 The flow chart of the full-text retrieval enhancement method for the hydropower plant knowledge.
[0034] Figure 2 The structure diagram of the triple structure coding model.
[0035] Figure 3 A target semantic model structure diagram.
[0036] Figure 4 A full-text retrieval enhancement method for hydropower plant knowledge and an evaluation result graph of the BM25 algorithm under a test set. DETAILED DESCRIPTION
[0037] In order to make the above objectives, characteristics and advantages of the present application more obvious and easy to understand, the specific embodiments of the present application will be described in detail below in conjunction with the drawings of the specification. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor should fall within the scope of protection of the present application.
[0038] Embodiment 1, reference Figures 1-3 As a first embodiment of the present application, the embodiment provides a full-text retrieval enhancement method for hydropower plant knowledge, comprising:
[0039] S1, constructing a triple structure encoding model and a target semantic recognition model, wherein the target semantic recognition model is trained by introducing an enhanced contrastive learning algorithm in the triple structure encoding model.
[0040] Further, the triple structure encoding model and the target semantic recognition model are constructed, including constructing the triple structure encoding model, and constructing the target semantic recognition model based on the constructed triple structure encoding model.
[0041] Further, the enhanced contrastive learning algorithm is an algorithm for contrastive learning based on multiple sample pairs and multiple negative examples, wherein the sample pairs are generated according to a dictionary composed of multiple batches.
[0042] Further, the triple structure encoding model is constructed, including,
[0043] The obtained hydropower plant knowledge documents are preprocessed to obtain target document data, wherein the preprocessing includes data cleaning of the hydropower plant knowledge documents, and the data cleaning specifically includes stop word removal, punctuation symbol removal, special symbol removal, and digit to uppercase conversion, etc.
[0044] An initial triple structure encoding model is constructed by using three pre-training models with shared weights as a core network, wherein the pre-training model uses a BERT pre-training model, and the BERT is an open source deep learning model based on a Transformer architecture.
[0045] The sentences are extracted from the target document data to form training samples, an initial triple structure encoding model is trained and optimized by using a contrast learning method and combining a vector-based dense retrieval loss function, and the triple structure encoding model is obtained.
[0046] Further, the extracting sentences from the target document data to form training samples includes extracting multiple groups of sentences from the target document data to form the training samples, wherein each group of sentences includes an anchor sentence, a positive sample sentence, and a negative sample sentence.
[0047] It should be noted that the expression of the vector-based dense retrieval loss function is:
[0048]
[0049]
[0050] In the formula: represents the average pooling result of the vector of the anchor sentence; represents the average pooling result of the vector of the positive sample sentence; represents the average pooling result of the vector of the negative sample sentence; represents the distance; the margin parameter represents is at least closer than to is a constant, and the value is 1, which ensures that the distance difference between the positive sample and the negative sample is not too large, and also ensures that it is not too small to effectively distinguish.
[0051] S2, decompose the obtained query request into at least two query keywords, and perform expansion processing on the decomposed query keywords to obtain an expanded query request.
[0052] It can be understood that the obtained query request is decomposed into at least two query keywords, and each query keyword in the multiple query keywords is expanded to obtain an expanded keyword corresponding to each query keyword, and an expanded query request is obtained based on the multiple query keywords and the expanded keyword corresponding to each query keyword.
[0053] Further, the expansion processing for each query keyword includes,
[0054] According to the synonym dictionary and the edit distance calculation, the synonym similar in semantics to the query keyword is selected to generate an expanded query matrix, wherein the synonym refers to a vocabulary that can be used interchangeably in a specific context, and they have the same or very similar meanings. Further, in the expansion process, the synonym is used to increase the vocabulary related to the original query request, thereby improving the recall rate of the retrieval system.
[0055] Further, the synonym similar in semantics to the query keyword is calculated according to the edit distance of each query keyword, and the s target keywords closest to each query keyword are selected as the above-mentioned synonym similar in semantics to the query keyword.
[0056] It should be noted that the synonym selection criteria are as follows:
[0057] 1. Semantic similarity: The selected synonym should be highly similar in semantics to the original query request to ensure that the expanded query request can more accurately reflect the user's intention.
[0058] 2. Context relevance: The selection of the synonym should consider the meaning of the query request in a specific context to ensure that the synonym can maintain the consistency of the context when expanding the query.
[0059] 3. Frequency and universality: Generally, the synonym with high frequency and strong universality is preferred to improve the coverage of the expanded query.
[0060] 4. Distinction: The selected synonym should have distinction and be able to effectively distinguish different query intentions.
[0061] It should be further noted that the user's query request Q is decomposed into a query request consisting of n query keywords q, i.e. Q=q1+q2+…+q n , and q1≠q2≠…≠q n (wherein: Q is the query request, q n is the nth query keyword), the edit distance of each query keyword is calculated according to the edit distance formula, and the s closest target keywords to each query keyword are selected, s=8 (wherein: s is the number of target keywords closest to the query keyword).
[0062] Further, the edit distance formula is:
[0063] ,
[0064] wherein: is the edit distance between the first i characters of string a and the first j characters of string b; represents when When one of the strings is empty, the edit distance is the length of the other string; represents a deletion operation at the i-th character of string a, and then calculates the edit distance between the first i-1 characters of string a and the first j characters of string b, plus 1 operation; represents an insertion operation at the j-th character of string b, and then calculates the edit distance between the first i characters of string a and the first j-1 characters of string b, plus 1 operation; represents a replacement operation at the i-th character of string a and the j-th character of string b (if the characters are different) or no operation (if the characters are the same), plus 1 operation if the characters are different; if the characters are the same, no operation is added. It should be noted that 1 (ai≠bj) is 0 when ai=bj, otherwise 1.
[0065] Further, let the s edit distances calculated by the i-th query keyword qi be ki1, ki2, …, kis, and the extended query matrix be:
[0066] ,
[0067] In the formula: Q-extend is the extended query matrix, the row index is i, and the column index is j, where i represents the i-th query keyword and j represents the j-th target keyword; represents the edit distance between the i-th query keyword and the s-th target keyword.
[0068] S3, convert the extended query request into a target semantic vector through a triple structure coding model, and perform a first similarity calculation on the target semantic vector and the semantic vectors in the vector database to obtain the similarity between the target semantic vector and the semantic vectors in the vector database, recall the relevant documents according to the similarity, and preliminarily sort the recalled documents according to the similarity from large to small.
[0069] Further, the semantic vectors in the vector database are obtained by coding the target document data, wherein the relevant documents are recalled according to the similarity, and the recalled documents are preliminarily sorted according to the similarity from large to small, including: sorting the semantic vectors according to the similarity from large to small, and determining the target document data corresponding to the top N semantic vectors as the relevant documents.
[0070] Further, the semantic vector is obtained by coding the target document data through a triple structure coding model;
[0071] The vector knowledge base is a database for storing semantic vectors.
[0072] It should be noted that the target document data is encoded by the triple structure encoding model to obtain a semantic vector, and the obtained semantic vector is stored in the vector knowledge base, specifically including obtaining target document data after data cleaning of the obtained hydropower plant knowledge document, dividing each target document data, the size is set to 512 characters by default, 36 characters are reserved between each block, then encoding by the triple structure encoding model in block units, the dimension is 768, that is, the output dimension of the model, and further storing the semantic vector formed after encoding in the vector knowledge base, and establishing a corresponding document index and fast index.
[0073] Further, the formula for the first similarity calculation is:
[0074]
[0075] Similarity is the similarity score; q is the target semantic vector; d is the semantic vector in the vector database; represents the length of the target semantic vector q; represents the length of the semantic vector d in the vector database; is the value of the i-th dimension of the target semantic vector; is the square of the value of the i-th dimension of the target semantic vector; is the value of the i-th dimension of a semantic vector in the vector database; is the square of the value of the i-th dimension of a semantic vector in the vector database; n is the dimension of the semantic vector, .
[0076] It should be noted that the retrieval results are sorted according to the calculation results of the similarity, and the top target number (set according to actual needs) of the retrieval results are recalled.
[0077] S4, the second similarity calculation is performed on the recalled documents and the expanded query request by the target semantic recognition model, and the recalled documents are sorted again according to the order from large to small of the calculated similarity, to obtain a target retrieval sorting result, wherein the first similarity calculation and the second similarity calculation adopt different ways.
[0078] It should be understood that in an embodiment, the above-mentioned target retrieval sorting result includes the sorting result of the recalled documents obtained after the above-mentioned secondary sorting; in another embodiment, the top M documents can be selected as target documents according to the sorting of the above-mentioned recalled documents obtained after the secondary sorting, and the sorting result of the M target documents is taken as the above-mentioned target retrieval sorting result.
[0079] It should be noted that the formula for the second similarity calculation is:
[0080]
[0081]
[0082] In the formula: W is a linear layer of a target semantic recognition model; S is a score, wherein ctxt is a semantic vector of an extended query request, cand i is a semantic vector of a recall document; first is a function for obtaining a first vector ([CLS] token) of an output of a last layer of a model; T(ctxt, cand i ) represents an output layer obtained by inputting a semantic vector ctxt of an extended query request and a semantic vector cand i of a recall document into a target semantic recognition model; represents a first vector of an output layer of a target semantic recognition model; y represents a first vector of an output layer of a target semantic recognition model.
[0083] Further, the loss function of the enhanced contrastive learning algorithm is:
[0084] Contrastive loss formula 1
[0085] In the formula: is a loss function of a query q; q is a target semantic vector; is a semantic vector representation positively correlated with q; is a semantic vector representation negatively correlated with q; τ is a temperature hyperparameter, and K is the total amount of negative correlation samples; is a similarity score of a positive correlation sample pair ; is a sum of similarity scores of all negative correlation sample pairs .
[0086] It should be noted that the design idea of the enhanced contrastive learning algorithm is to maintain a data sample queue using a dictionary (the dictionary is a data structure) alone, and the dictionary is composed of multiple batches, which is much larger than a sample pair composed of a batch, so that the model can perform contrastive learning with a large number of negative examples at a time, and the sample update in the dictionary adopts a momentum method:
[0087] ,
[0088] In the formula: θ k is a state value of a certain negative sample in the dictionary; θ q is a state value of a certain positive sample in the dictionary; m ∈ [0, 1], and m is a momentum coefficient.
[0089] Preferably, the momentum m can enable the model to perform effective contrastive learning in a large number of negative examples while maintaining a certain stability.
[0090] In summary, the beneficial effects of the full-text retrieval enhancement method for knowledge of a hydropower plant are that by constructing a triple-structure encoding model and introducing an enhanced contrastive learning algorithm, the problems of lexical gaps and semantic gaps in traditional retrieval methods are effectively solved. Further, the triple-structure encoding model is used to encode the knowledge documents into semantic vectors and store them in a vector database, while the synonym expansion and edit distance calculation are performed on the user query to expand the recall range and ensure that more potential relevant documents can be obtained. Furthermore, the enhanced contrastive learning algorithm is used to perform secondary sorting on the recalled documents, and through the momentum update mechanism and dictionary maintenance strategy, the model's understanding and distinguishing ability of document semantics are further improved, so that the final retrieval results can more accurately match the user's needs.
[0091] Embodiment 2, refer to Figure 4 For the second embodiment of the present application, a full-text retrieval enhancement method for knowledge of a hydropower plant is provided. In order to verify the beneficial effects of the present application, scientific demonstration is carried out through experiments.
[0092] About 240 documents were extracted from existing power plant knowledge documents, and data cleaning was performed on the documents, including removing stop words, removing punctuation, removing special symbols, and converting numbers to uppercase. About 20,000 sentences were extracted using code and the order was shuffled. About 2,000 sentences with similar meanings or low quality were filtered out manually, leaving about 18,000 sentences as training samples, of which 14,000 were used as training sets and 4,000 were used as test sets. The training samples were grouped into three sentences, one as an anchor sentence, one as a positive example, and one as a negative example. Using a contrastive learning approach, a sentence was randomly selected as an anchor sentence from the same training batch. The code was used to generate positive examples using synonym replacement and back-translation. Any sentence in the batch was used as a negative example. By training a triple-structure encoding model to minimize the loss function, the similarity between the anchor sentence and the positive sample sentence was close, while the similarity between the anchor sentence and the negative sample was large. Specifically, the training parameter epoch (training rounds) = 6, selection basis: the number of epochs is determined by experimental verification. Six epochs were set because in the preliminary experiment it was found that the model could achieve good performance at this number, while avoiding overfitting. If the epoch is set too large, the model will overfit the training data, resulting in a decline in generalization ability. If the epoch is too small, the model may not be able to fully learn the patterns in the training data. batchsize (batch size) = 16, selection basis: the selection of batchsize is limited by the existing computing resources. 16 is a medium-sized batchsize, and increasing it will cause memory overflow in the experiment. Reducing the batchsize will increase the training time. warmup (learning rate warmup) = 0.1, selection basis: warmup is a ratio based on experience, which is used to gradually increase the learning rate before it rises to a predetermined value. 0.1 means that the learning rate is gradually increased in the first 10% of the training steps. Warmup can help the model learn stably in the early stages of training, avoiding instability caused by an excessively large initial learning rate. LR (learning rate) = 2e-5, the learning rate is set to 2e-5 because in the experiment it was found that this learning rate could make the model converge stably during training. A large learning rate makes it difficult for the model to converge, and even diverge; a small learning rate leads to a slow training process. Optimizer: ADAM, selection basis: ADAM is a commonly used optimizer that combines the advantages of momentum (Momentum) and adaptive learning rate (Adagrad / RMSprop). ADAM is usually chosen because it can quickly converge and perform well in experiments.
[0093] Further, in the 4000 test set, the code uses synonym replacement, the synonym library uses the Harbin Institute of Technology synonym word forest extended version, by introducing the library package manager to build: from pyltp import Segmentor. (Import the Segmentor class in the pyltp library to facilitate the use of the LTP (Language Technology Platform) segmentation function in the Python program), and use back translation to generate sentence pairs, shuffle the order, randomly select 1800 as the positive example pair, and the remaining sentence pairs are manually screened to construct 1800 negative example sentence pairs. Directly use the pre-trained model, the test set accuracy is 30%; training 4 iterations, the test set accuracy is 61%; training set 5 iterations, the test set accuracy is 68%; training set, 6 iterations, the test set accuracy is 71%.
[0094] Further, the target semantic model is trained by introducing an enhanced contrastive learning algorithm into the triple structure coding model. The specific training parameters are epoch=6, batchsize=16, warmup=0.1, LR=3e-6, the actual training is adjusted to a small learning rate to obtain the performance of the model at the expense of time, the momentum parameter is 0.99, which is obtained by experimental adjustment, the value is 0.99, which can accelerate the movement of gradient descent in the relevant direction and reduce the shock, the temperature coefficient is 0.07, which is used to control the sensitivity of the model to the probability distribution, the temperature coefficient is 0.07 in this training, the purpose is to make the output probability distribution more sharp, and the model can converge faster, the optimizer is ADAM. Training and retrieval process are independent.
[0095] Further, the TF-IDF based BM25 algorithm (a traditional text retrieval algorithm) and the present method are compared and studied in the test environment. According to the self-built test set, the documents are divided and imported into ElastricSearch (elastic search), and the text embedding vector is obtained using the OpenAI (open artificial intelligence) embedding model. The corpus has a total of 380 document segments (Chunk), and each document is manually labeled with the corresponding user query (query) and the corresponding document index. Hit rate (Hit Rate) and Mean Reciprocal Rank (MRR) are used for evaluation. The higher the hit rate, the more recall text (true value) appears in the top k text in the recall result, the higher the hit rate, the better the algorithm effect; the average reciprocal rank measures the average value of the inverse number of the average ranking of the algorithm in a series of queries, the higher the value, the better the retrieval effect.
[0096] The calculation formula of hit rate is:
[0097] ,
[0098] In the formula: Hitrate@K is a hit rate index, indicating the probability that the number of hits in the search results is K; Number of Hits@K is the number of hits, and GT is the total number of searches.
[0099] The average reciprocal rank (MRR) formula is:
[0100] ,
[0101] In the formula: Q represents the total number of searches, rank i represents the position of the most relevant result in the i-th search result, and the reciprocal thereof is the quality of the returned result.
[0102] In combination with Table 1, Table 2 and Figure 4 It can be seen that, as k increases (k = 1, 2, 3, 4, 5), the hit rate Hit Rate index and the MRR index both increase, but the present method has a higher hit rate and higher accuracy than the traditional method.
[0103] Table 1 Evaluation results of the present method
[0104] ,
[0105] Table 2 Evaluation results of BM25
[0106] ,
[0107] In summary, compared with the traditional BM25 algorithm, the present method has a significant improvement in the hit rate and average reciprocal rank, etc., and exhibits higher search accuracy and efficiency, while having good semanticity and strong robustness to external interference, and can effectively meet the high-quality requirements of the knowledge search of the hydropower plant.
[0108] Embodiment 3, which is different from the first two embodiments, is a third embodiment of the present application.
[0109] If the functions are implemented in software, the functions can be stored in or implemented as one or more instructions or code on a computer-readable medium. Computer-readable media include both computer storage media and communication media including any medium that facilitates transfer of a computer program from one place to another. A storage medium can be any available medium that can be accessed by a computer. By way of example, and not limitation, such computer-readable media can comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer. Also, any connection is properly termed a computer-readable medium. For example, if the software is transmitted from a website, server, or other remote source using a coaxial cable, fiber optic cable, or twisted pair, then the coaxial cable, fiber optic cable, or twisted pair are included in the definition of medium. Disk and disc, as used herein, include compact disc (CD), laser disc, optical disc, digital versatile disc (DVD), and Blu-Ray® disc where disks usually reproduce data magnetically, while discs reproduce data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media.
[0110] In other words, like a human driver of a vehicle, the autonomous vehicle 100 can be programmed to follow traffic laws and rules of the road, and to make decisions based on its programming and the information it receives from its sensors and other sources. The autonomous vehicle 100 can also be programmed to make decisions based on its programming and the information it receives from its sensors and other sources, even if those decisions are not in accordance with traffic laws and rules of the road. For example, the autonomous vehicle 100 can be programmed to avoid a collision with another vehicle, even if doing so would violate a traffic law or rule of the road.
[0111] In other words, like a human driver of a vehicle, the autonomous vehicle 100 can be programmed to follow traffic laws and rules of the road, and to make decisions based on its programming and the information it receives from its sensors and other sources. The autonomous vehicle 100 can also be programmed to make decisions based on its programming and the information it receives from its sensors and other sources, even if those decisions are not in accordance with traffic laws and rules of the road. For example, the autonomous vehicle 100 can be programmed to avoid a collision with another vehicle, even if doing so would violate a traffic law or rule of the road.
[0112] It should be understood that various parts of the present application can be realized in hardware, software, firmware, or a combination thereof. In the above-described embodiments, a plurality of steps or methods can be realized with software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if realized in hardware, and as in another embodiment, it can be realized with any one or a combination of the following technologies known in the art: discrete logic circuitry having logic gates for implementing logic functions on data signals, application specific integrated circuits having appropriate combinational logic gates, programmable gate arrays (PGA), field programmable gate arrays (FPGA), etc.
[0113] Embodiment 4, which is a fourth embodiment of the present application, provides a full-text retrieval enhancement system for hydropower plant knowledge, comprising a construction module for constructing a triple structure coding model and a target semantic recognition model, wherein the target semantic recognition model is trained by introducing an enhanced contrastive learning algorithm in the triple structure coding model;
[0114] A decomposition and expansion module is configured to decompose the obtained query request into at least two query keywords, and expand the decomposed query keywords to obtain an expanded query request;
[0115] A preliminary sorting module is configured to convert the expanded query request into a target semantic vector through the triple structure coding model, and perform a first similarity calculation on the target semantic vector and the semantic vectors in the vector database to obtain the similarity between the target semantic vector and the semantic vectors in the vector database, recall relevant documents according to the similarity, and preliminarily sort the recalled documents according to the similarity from large to small.
[0116] A fine sorting module is configured to perform a second similarity calculation on the recalled documents and the expanded query request through the target semantic recognition model, and sort the recalled documents according to the similarity from large to small to obtain a target retrieval sorting result, wherein the first similarity calculation and the second similarity calculation adopt different ways.
[0117] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and are not limiting. Although the present application has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that the technical solutions of the present application can be modified or replaced equivalently without departing from the spirit and scope of the technical solutions of the present application, and they should be covered in the scope of the claims of the present application.
Claims
1. A full-text retrieval enhancement method for hydropower plant knowledge, characterized by: include, Constructing a triple structure encoding model and a target semantic recognition model, wherein the target semantic recognition model is trained by introducing an enhanced contrastive learning algorithm into the triple structure encoding model, wherein the enhanced contrastive learning algorithm includes a momentum update mechanism; Decomposing the obtained query request into at least two query keywords, and performing expansion processing on the decomposed query keywords to obtain an expanded query request, wherein the expansion processing includes selecting synonyms with similar semantics to the query keywords based on a synonym dictionary and edit distance calculation to generate an expanded query matrix; The expanded query request is converted into a target semantic vector through a triple structure encoding model, and a first similarity calculation is performed between the target semantic vector and the semantic vectors in the vector database to obtain the similarity between the target semantic vector and the semantic vectors in the vector database. Relevant documents are recalled based on the similarity, and the recalled documents are preliminarily sorted from large to small according to the similarity, wherein the relevant documents include the target document data corresponding to the top N semantic vectors; The target semantic recognition model is used to perform a second similarity calculation on the recalled documents and the expanded query request, and the recalled documents are sorted in descending order according to the calculated similarities to obtain the target retrieval ranking result. The first and second similarity calculations use different methods. The formula for the second similarity calculation is: y ctxt,cand =h1=first(T(ctxt,cand i )) Where: W is the linear layer of the target semantic recognition model; S is the score, where ctxt is the semantic vector of the expanded query request and candi is the semantic vector of the recalled document; first is a function used to obtain the first vector ([CLS]token) output by the last layer of the model; T(ctxt,candi) represents the output layer obtained by inputting the semantic vector ctxt of the expanded query request and the semantic vector candi of the recalled document into the target semantic recognition model; h1 represents the first vector of the output layer of the target semantic recognition model; y represents the first vector of the output layer of the target semantic recognition model.
2. The method for enhancing full-text retrieval of hydropower plant knowledge according to claim 1, characterized in that: The construction of the triple structure coding model includes: Preprocess the acquired hydropower plant knowledge documents to obtain target document data; Three pre-trained models with shared weights are used as the core network to construct the initial triple structure encoding model; Sentences are extracted from target document data to form training samples, and the initial triple structure encoding model is trained and optimized using a contrastive learning method combined with a vector-based dense retrieval loss function to obtain the triple structure encoding model.
3. The method for enhancing full-text retrieval of hydropower plant knowledge according to claim 2, characterized in that: The semantic vector is obtained by encoding the target document data through a triple structure encoding model; The vector database is a database that stores the semantic vectors.
4. The method for enhancing full-text retrieval of hydropower plant knowledge according to claim 3, characterized in that: Extracting sentences from the target document data to form training samples includes extracting multiple groups of sentences from the target document data to form the training samples, wherein each group of sentences includes: a sentence used as an anchor, a positive sample sentence, and a negative sample sentence.
5. The method for enhancing full-text retrieval of hydropower plant knowledge according to claim 4, characterized in that: The formula for the first similarity calculation is: Where: Similarity is the similarity score; q is the target semantic vector; d is the semantic vector in the vector database; ||q|| represents the modulus of the target semantic vector q; ||d|| represents the modulus of the semantic vector d in the vector database; q i is the value of the i-th dimension of the target semantic vector; is the square of the value of the i-th dimension of the target semantic vector; d i is the value of the i-th dimension of a semantic vector in the vector database; is the square of the value of the i-th dimension of a semantic vector in the vector database; n is the dimension of the semantic vector, i∈{1,2,…,n}.
6. A method for enhancing full-text retrieval of hydropower plant knowledge according to claim 5, characterized in that: The enhanced contrastive learning algorithm includes a momentum update mechanism, including: maintaining a data sample queue using a dictionary, the dictionary consisting of multiple batches; updating samples in the dictionary using momentum: i k ←mθ k +(1-m)θ q Where: θ k is a negative sample state value in the dictionary; θ q is a positive sample state value in the dictionary; m∈[0,1], m is a momentum coefficient; The loss function of the enhanced contrastive learning algorithm is: Where: is the loss function of query q; q is the target semantic vector; k + Is the semantic vector representation positively correlated with q; k i is the semantic vector representation of q negative correlation; τ is a temperature hyperparameter, K is the total number of negative correlation samples; exp(qδk + / τ) is the positive correlation sample pair (q·k + ) similarity score; are all negatively correlated sample pairs (q·k i ) is the sum of the similarity scores.
7. A full-text search enhancement system for hydropower plant knowledge, applying a full-text search enhancement method for hydropower plant knowledge according to any one of claims 1 to 6, characterized in that: include: A construction module is used to construct a triple structure encoding model and a target semantic recognition model, wherein the target semantic recognition model is obtained by introducing an enhanced contrastive learning algorithm into the triple structure encoding model, and the enhanced contrastive learning algorithm includes a momentum update mechanism; a decomposition and expansion module for decomposing the acquired query request into at least two query keywords and performing expansion processing on the decomposed query keywords to obtain an expanded query request, wherein the expansion processing includes selecting synonyms with similar semantics to the query keywords based on a synonym dictionary and edit distance calculation to generate an expanded query matrix; A preliminary sorting module is used to convert the expanded query request into a target semantic vector through a triple structure encoding model, and perform a first similarity calculation between the target semantic vector and the semantic vectors in the vector database to obtain the similarity between the target semantic vector and the semantic vectors in the vector database, recall related documents based on the similarity, and preliminarily sort the recalled documents in descending order of similarity, wherein the related documents include the target document data corresponding to the top N semantic vectors; A refined ranking module is used to perform a second similarity calculation on the recalled documents and the expanded query request using the target semantic recognition model and to perform a second sorting of the recalled documents in descending order of the calculated similarities to obtain a target retrieval sorting result, wherein the first and second similarity calculations use different methods; The formula for the second similarity calculation is: y ctxt,cand =h1=first(T(ctxt,cand i )) Where: W is the linear layer of the target semantic recognition model; S is the score, where ctxt is the semantic vector of the expanded query request and candi is the semantic vector of the recalled document; first is a function used to obtain the first vector ([CLS]token) output by the last layer of the model; T(ctxt,candi) represents the output layer obtained by inputting the semantic vector ctxt of the expanded query request and the semantic vector candi of the recalled document into the target semantic recognition model; h1 represents the first vector of the output layer of the target semantic recognition model; y represents the first vector of the output layer of the target semantic recognition model.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the processor implements the steps of a full-text retrieval enhancement method for hydropower plant knowledge according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the full-text retrieval enhancement method for hydropower plant knowledge described in any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Archive information resource intelligent sharing method and system based on AI
CN119149704A
Enterprise-level knowledge management system based on large language model
CN119476460A
Similar law judgment document matching method based on prompt engineering and judgment prediction
CN119783655A