Text search method and system based on vector retrieval and large model optimization

By introducing methods based on vector search and large-model optimization in text search technology, combining cross encoder model and knowledge graph technology, the shortcomings in text semantic understanding and correlation sorting in the existing technology are solved, and more accurate and relevant search results are achieved.

CN120179890AActive Publication Date: 2025-06-20杨群鹏

Patent Information

Application Number
CN202510644939.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-20
Publication Date
2025-06-20
Estimated Expiration
2045-05-20

AI Technical Summary

Technical Problem

Existing text search technology has shortcomings in text semantic understanding and correlation sorting, and it is difficult to accurately capture the deep semantic and contextual relationships of the text, resulting in the inconsistent search results with user needs.

Method used

Text search methods based on vector search and large model optimization are adopted to generate semantic vectors through pre-trained large language models, and context information analysis and entity relationship inference of text pairs are used to optimize search results.

Benefits of technology

It improves the accuracy and relevance of text searches, can better understand user query intentions and document content, and provides search results that are more in line with user needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120179890A_ABST
    Figure CN120179890A_ABST
Patent Text Reader

Abstract

The invention provides a text search method and system based on vector retrieval and large model optimization, and relates to the technical field of text search, and the method comprises the following steps: obtaining a to-be-retrieved text and generating a semantic vector; retrieving similar texts in a vector database based on the semantic vectors; calculating the correlation of the text pairs by using a cross encoder model and sorting the text pairs; and extracting key entities by adopting a knowledge graph optimization model, analyzing an entity relationship, and reordering and filtering search results. According to the method, through semantic vector retrieval, cross coding calculation of correlation and knowledge graph optimization, the accuracy and correlation of text search are improved, user intentions can be better understood, and more accurate search results can be returned.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to text search technology, and particularly to a text search method and system based on vector retrieval and large model optimization. Background Art

[0002] With the explosive growth of Internet information, text search technology, as a key link in information retrieval, has become increasingly important. Traditional text search mainly relies on keyword matching and realizes fast retrieval through technologies such as indexing and inverted indexing. In recent years, with the development of deep learning technology, vector-based semantic retrieval methods have gradually become a research hotspot. Such methods can understand the semantic content of text, not limited to literal matching. At the same time, the emergence of pre-trained large language models provides more powerful semantic understanding capabilities for text representation, enabling search systems to better understand user query intentions and document content. Knowledge graphs, as a representation of structured knowledge, can provide relationship information between entities, further enhancing the accuracy and comprehensiveness of search.

[0003] However, the existing text search technologies still have the following defects and deficiencies: Insufficient text semantic understanding. Traditional keyword-based retrieval methods are difficult to understand the deep semantics of text, resulting in a deviation between retrieval results and the actual needs of users; even when using simple vector retrieval methods, it is difficult to accurately capture the context correlation and semantic details of text, especially for complex queries or long text content.

[0004] Limited relevance ranking accuracy. The existing ranking mechanisms mainly rely on a single similarity calculation method and cannot comprehensively consider the multi-dimensional associations between texts, resulting in the fact that highly relevant content in the retrieval results may not be displayed preferentially, affecting user experience and retrieval efficiency. Summary of the Invention

[0005] Embodiments of the present invention provide a text search method and system based on vector retrieval and large model optimization, which can solve the problems in the prior art.

[0006] In the first aspect of the embodiments of the present invention, a text search method based on vector retrieval and large model optimization is provided, including: Obtain the text to be retrieved, and input the text to be retrieved into a pre-trained large language model. Through the pre-trained large language model, generate a semantic vector of the text to be retrieved to obtain a first semantic vector of the text to be retrieved, where the large language model includes an encoder layer with a multi-layer transformer structure; Perform similarity calculation in the vector retrieval database based on the first semantic vector, and obtain a candidate text set whose similarity to the first semantic vector is greater than a preset similarity threshold; Combine the text to be retrieved with each candidate text in the candidate text set to form text pairs, input the text pairs into a cross-encoder model, the cross-encoder model calculates a relevance score based on the context information of the text pairs, and sort the candidate text set in descending order according to the relevance score to obtain an initial search result; Input the initial search result into a text optimization model based on a knowledge graph. The text optimization model based on the knowledge graph includes a knowledge entity extraction module and an entity relationship reasoning module. Identify key entities from the initial search result through the knowledge entity extraction module, analyze the association relationships between the key entities based on a preset knowledge graph through the entity relationship reasoning module, and re-rank and filter the initial search result according to the association relationships to obtain a final search result.

[0007] Generating a first semantic vector of the text to be retrieved through the pre-trained large language model includes: Input the text to be retrieved into the encoder layer of the pre-trained large language model. The encoder layer includes multiple layers of transformer structures, and each layer of transformer structure includes a self-attention sublayer and a feed-forward neural network sublayer; In the encoder layer, encode the position information of the tokens in the text to be retrieved into position vectors through position encoding, and combine the position vectors with the token embedding vectors corresponding to the tokens to obtain an input vector sequence; the self-attention sublayer calculates an attention weight matrix based on the input vector sequence, and performs weighted fusion on the input vector sequence according to the attention weight matrix to obtain a context representation vector; the feed-forward neural network sublayer performs a non-linear transformation on the context representation vector to obtain a feature vector; A pooling layer is arranged at the output end of the encoder layer. The pooling layer adopts an attention pooling mechanism to perform weighted averaging on the feature vectors through learned attention weights to obtain a global semantic representation of the text; input the global semantic representation into a dimension mapping layer, and map the global semantic representation to a first semantic vector with a fixed dimension through the dimension mapping layer.

[0008] Combine the text to be retrieved with each candidate text in the candidate text set to form text pairs, input the text pairs into a cross-encoder model, the cross-encoder model calculates a relevance score based on the context information of the text pairs, and sort the candidate text set in descending order according to the relevance score to obtain an initial search result, including: Concatenate and combine the text to be retrieved with each candidate text in the candidate text set according to a preset delimiter to generate a text pair sequence; Input the text pair sequence into the cross-encoder model, and encode the text to be retrieved and the candidate text respectively through the bidirectional Transformer structure of the cross-encoder model to generate the first feature sequence of the text to be retrieved and the second feature sequence of the candidate text; calculate the interaction features between the first feature sequence and the second feature sequence based on the multi-head cross-attention mechanism; Extract the local semantic features in the interaction features through a one-dimensional convolutional neural network; calculate the long-range dependence relationship in the interaction features through a self-attention layer to obtain the global semantic features; perform adaptive weighted summation on the local semantic features and the global semantic features to obtain a unified representation vector of the text pair; Input the unified representation vector into the fully connected neural network of the cross-encoder model, and perform a non-linear transformation on the unified representation vector through the fully connected neural network to output the relevance score of the text pair; Sort the candidate text set in descending order according to the relevance score to generate a sorted candidate text list, and output the sorted candidate text list as the initial search result.

[0009] The text optimization model based on the knowledge graph includes a knowledge entity extraction module and an entity relationship reasoning module. Identify key entities from the initial search results through the knowledge entity extraction module, and analyze the association relationships between the key entities based on the preset knowledge graph through the entity relationship reasoning module, including: Perform sentence splitting and named entity recognition on each text content in the initial search results to obtain an entity annotation sequence; Perform entity linking on the entity annotation sequence, and match the identified entities with the standard entities in the knowledge graph; calculate the occurrence frequency and position importance score of the entity in the text; calculate the relevance score between the entity and the text theme in combination with the word vector; generate an entity importance score through weighted calculation of the entity frequency, position importance score, and relevance score; select entities with entity importance scores greater than the preset scoring threshold as the key entity set; Use the entities in the key entity set as the starting nodes, perform multi-hop relationship path search in the knowledge graph, filter the relationship paths with credibility higher than the preset credibility threshold, extract the entity relationship triples included in the relationship paths, and calculate the relationship strength based on the occurrence frequencies of the head entity, tail entity, and relationship type in the entity relationship triples; Construct an entity relationship graph based on the relationship strength and the entity relationship triples, and perform node importance propagation in the entity relationship graph to obtain the final importance score of each entity.

[0010] Using the entities in the key entity set as the starting nodes, perform multi-hop relationship path search in the knowledge graph. Screening relationship paths with a credibility higher than the preset credibility threshold includes: Taking the starting node as the current search node, obtaining the adjacent node set and corresponding relationship types of the current search node; calculating the credibility of each node in the adjacent node set, where the credibility is determined by the product of the node importance score, relationship type weight, and path attenuation factor. Among them, the node importance score is obtained by weighted summation of the in-degree, out-degree, and node attribute values of the node; the relationship type weight is determined by the ratio of the number of occurrences of the relationship corresponding to the node to the maximum relationship frequency; the path attenuation factor is determined based on the exponential relationship between the preset attenuation base and the current hop count; Selecting nodes with a credibility exceeding the preset credibility threshold as candidate nodes; recording the path information from the current search node to the candidate nodes; Recursively performing path search on each candidate node until the preset maximum hop count is reached or the search queue is empty, specifically including: Adding the candidate nodes to the node search queue; updating the node access status to mark the visited nodes; calculating the cumulative credibility of the current path information, where the cumulative credibility is the sum of the credibilities of all nodes on the path; when the search depth reaches the preset maximum hop count, storing the current path information and the cumulative credibility into the path result set.

[0011] Re-ranking and filtering the initial search results according to the association relationship to obtain the final search results, including: Establishing an entity association matrix according to the association relationship, where the rows and columns of the entity association matrix represent entities, and the matrix element value is the association strength value of the corresponding entity pair; calculating the first-order associated entity set of each entity, where the first-order associated entity set contains all entities directly connected to the entity; counting the network centrality of each entity, where the network centrality is the size of the first-order associated entity set of the entity; Re-ranking the initial search results according to the size of the network centrality; and deleting the initial search results with a network centrality less than the preset screening threshold to obtain the final search results.

[0012] In the second aspect of the embodiments of the present invention, a text search system based on vector retrieval and large model optimization is provided, including: A first unit for obtaining the text to be retrieved and inputting the text to be retrieved into a pre-trained large language model, generating a first semantic vector of the text to be retrieved through the pre-trained large language model, where the large language model includes an encoder layer with a multi-layer transformer structure; A second unit, configured to calculate a similarity in the vector retrieval database based on the first semantic vector, and obtain a set of candidate texts whose similarity to the first semantic vector is greater than a preset similarity threshold; A third unit, configured to combine the text to be retrieved with each candidate text in the set of candidate texts into text pairs, input the text pairs into a cross-encoder model, the cross-encoder model calculates a relevance score based on the context information of the text pairs, and sorts the set of candidate texts in descending order according to the relevance score to obtain an initial search result; A fourth unit, configured to input the initial search result into a text optimization model based on a knowledge graph, the text optimization model based on the knowledge graph includes a knowledge entity extraction module and an entity relationship reasoning module, identify key entities from the initial search result through the knowledge entity extraction module, analyze the association relationships between the key entities based on a preset knowledge graph through the entity relationship reasoning module, and re-sort and filter the initial search result according to the association relationships to obtain a final search result.

[0013] In a third aspect of the embodiments of the present invention, There is provided an electronic device, including: A processor; A memory for storing instructions executable by the processor; Wherein, the processor is configured to call the instructions stored in the memory to execute the method described above.

[0014] In a fourth aspect of the embodiments of the present invention, There is provided a computer-readable storage medium, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the method described above is implemented.

[0015] The beneficial effects of the present application are as follows: The present invention generates a semantic vector for the text to be retrieved through a large language model, realizes the accurate capture of the deep semantic features of the text, effectively solves the problem that the traditional keyword matching method cannot understand the semantic background of the text, and greatly improves the accuracy of retrieval.

[0016] The present invention introduces a cross-encoder model to finely sort candidate texts. This model can fully consider the context association information of text pairs, accurately evaluate the text relevance through deep learning algorithms, and significantly improve the relevance of search results and user satisfaction.

[0017] The present invention optimizes search results by combining knowledge graph technology. Through entity recognition and relationship reasoning, structured knowledge is integrated into the search process. It can not only identify key entities in the text but also analyze the semantic associations between entities, making the final search results more in line with user intentions. At the same time, it reduces the consumption of computing resources and improves the overall efficiency of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 is a schematic flow chart of the text search method based on vector retrieval and large model optimization according to an embodiment of the present invention; Figure 2 is a schematic architecture diagram of the text optimization model based on the knowledge graph according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0019] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0020] The technical solutions of the present invention will be described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.

[0021] Refer to Figure 1 and Figure 2 , the method of the present application includes: Obtain the text to be retrieved, and input the text to be retrieved into a pre-trained large language model. Through the pre-trained large language model, generate a first semantic vector of the text to be retrieved, where the large language model includes an encoder layer with a multi-layer transformer structure; Based on the first semantic vector, perform similarity calculation in the vector retrieval database to obtain a candidate text set whose similarity to the first semantic vector is greater than a preset similarity threshold; Combine the text to be retrieved with each candidate text in the candidate text set to form text pairs, input the text pairs into a cross-encoder model, the cross-encoder model calculates a relevance score based on the context information of the text pairs, and sort the candidate text set in descending order according to the relevance score to obtain an initial search result; Input the initial search results into a text optimization model based on a knowledge graph. The text optimization model based on the knowledge graph includes a knowledge entity extraction module and an entity relationship reasoning module. Identify key entities from the initial search results through the knowledge entity extraction module, analyze the association relationships between the key entities based on a preset knowledge graph through the entity relationship reasoning module, and reorder and filter the initial search results according to the association relationships to obtain the final search results.

[0022] In an alternative embodiment, generating a first semantic vector of the text to be retrieved through the pre-trained large language model includes: Input the text to be retrieved into the encoder layer of the pre-trained large language model. The encoder layer includes multiple layers of transformer structures, and each layer of transformer structure includes a self-attention sublayer and a feed-forward neural network sublayer; In the encoder layer, encode the position information of the tokens in the text to be retrieved into position vectors through position encoding, and combine the position vectors with the token- corresponding word embedding vectors to obtain an input vector sequence; the self-attention sublayer calculates an attention weight matrix based on the input vector sequence, and performs weighted fusion on the input vector sequence according to the attention weight matrix to obtain a context representation vector; the feed-forward neural network sublayer performs a non-linear transformation on the context representation vector to obtain a feature vector; A pooling layer is arranged at the output end of the encoder layer. The pooling layer adopts an attention pooling mechanism, performs weighted averaging on the feature vectors through learned attention weights to obtain a global semantic representation of the text; input the global semantic representation into a dimension mapping layer, and map the global semantic representation to a first semantic vector with a fixed dimension through the dimension mapping layer.

[0023] For example, the text to be retrieved can be "Artificial intelligence technology is changing our way of life".

[0024] Input the text to be retrieved into the encoder layer of the pre-trained large language model for processing. The encoder layer includes multiple layers of transformer structures, and in this embodiment, 12 layers of transformer structures can be adopted. Each layer of transformer structure includes a self-attention sublayer and a feed-forward neural network sublayer.

[0025] During the processing of the encoder layer, the position information of the tokens in the text to be retrieved is encoded into position vectors through positional encoding. Specifically, for the above example text, it is first tokenized into ["Artificial Intelligence", "technology", "is", "changing", "our", "way", "of", "life"]. Assuming that the dimension of the word embedding for each token is 768, corresponding positional encodings are generated for each token. For example, the token "Artificial Intelligence" is in the first position of the sequence, and its corresponding position vector can be calculated through sine and cosine functions, and this position vector is also 768-dimensional.

[0026] The position vectors are combined with the word embedding vectors corresponding to the tokens to obtain an input vector sequence. In this embodiment, the combination method is direct addition. For example, for the token "Artificial Intelligence", calculate its attention scores with all tokens. For example, the attention score with "technology" is 0.15, and the attention score with "changing" is 0.08, etc. After softmax normalization, attention weights are obtained. For example, the weight with "technology" is 0.2, and the weight with "changing" is 0.1, etc.

[0027] The input vector sequence is weighted and fused according to the attention weight matrix to obtain context representation vectors. For example, the context representation vector of the token "Artificial Intelligence" is the result of weighted summation of the value vectors of all tokens according to the corresponding attention weights. The same operation is performed on all tokens to obtain a context representation vector sequence with a shape of [8, 768].

[0028] The feed-forward neural network sub-layer performs a non-linear transformation on the context representation vectors to obtain feature vectors. This feed-forward neural network consists of two linear transformation layers with a ReLU activation function in the middle. The first linear transformation expands the dimension from 768 to 3072. After ReLU activation, the second linear transformation compresses the dimension from 3072 back to 768. For each context representation vector, the corresponding feature vector is obtained through this feed-forward network, and finally a feature vector sequence with a shape of [8, 768] is generated.

[0029] In the 12-layer transformer structure of the entire encoder, the output of each layer is used as the input of the next layer and is processed layer by layer. On the feature vector sequence output by the last layer of the transformer structure, a pooling layer is set for processing. This pooling layer adopts an attention pooling mechanism to perform weighted averaging on the feature vectors through learned attention weights to obtain the global semantic representation of the text.

[0030] Specifically, a learnable query vector (with a dimension of 768) is introduced, and the correlation scores between the query vector and each feature vector are calculated. For example, the correlation score between the query vector and the "artificial intelligence" feature vector is 0.25, and the correlation score with "technology" is 0.20, etc. These scores are normalized by softmax to obtain attention weights, such as the weight of "artificial intelligence" is 0.28, the weight of "technology" is 0.22, etc. All feature vectors are weighted and averaged according to these weights to obtain a 768-dimensional global semantic representation vector.

[0031] The global semantic representation is input into a dimension mapping layer, and through this dimension mapping layer, the global semantic representation is mapped into a first semantic vector with a fixed dimension. In this embodiment, the dimension mapping layer is a linear transformation layer that maps the 768-dimensional global semantic representation into a 256-dimensional semantic vector. For example, the first semantic vector obtained after mapping may be a 256-dimensional vector such as [-0.056, 0.127, 0.234, ..., 0.089].

[0032] Through the above processing, the original text to be retrieved, "Artificial intelligence technology is changing our way of life", is successfully converted into a 256-dimensional semantic vector representation. This semantic vector captures the semantic information of the text and can be used for subsequent text retrieval, matching and other tasks. For example, calculate the cosine similarity between this vector and the document vectors in the corpus to find the document with the most similar semantics.

[0033] In practical applications, various parameters can be adjusted according to specific task requirements, such as the number of transformer layers, the number of attention heads, the word embedding dimension, the dimension of the mapped vector, etc., to obtain the best performance.

[0034] In an alternative embodiment, the text to be retrieved is combined with each candidate text in the candidate text set to form text pairs, and the text pairs are input into a cross-encoder model. The cross-encoder model calculates the correlation scores based on the context information of the text pairs, and sorts the candidate text set in descending order according to the correlation scores. The initial search results include: The text to be retrieved is concatenated with each candidate text in the candidate text set according to a preset delimiter to generate a sequence of text pairs; The sequence of text pairs is input into the cross-encoder model. The bidirectional transformer structure of the cross-encoder model encodes the text to be retrieved and the candidate text respectively to generate a first feature sequence of the text to be retrieved and a second feature sequence of the candidate text; the interaction features between the first feature sequence and the second feature sequence are calculated based on the multi-head cross-attention mechanism; Extract the local semantic features in the interaction features through a one-dimensional convolutional neural network; calculate the long-range dependence relationship in the interaction features through a self-attention layer to obtain global semantic features; perform adaptive weighted summation on the local semantic features and the global semantic features to obtain a unified representation vector of the text pair; Input the unified representation vector into the fully-connected neural network of the cross-encoder model, and perform a non-linear transformation on the unified representation vector through the fully-connected neural network to output the correlation score of the text pair; Sort the candidate text set in descending order according to the correlation score, generate a sorted candidate text list, and output the sorted candidate text list as the initial search result.

[0035] This embodiment provides a text retrieval method based on a cross-encoder model. This method first combines the text to be retrieved with each candidate text in the candidate text set to form a text pair, then uses the cross-encoder model to calculate the correlation score of the text pair, and finally sorts the candidate texts according to the correlation score to obtain the initial search result. The specific implementation steps are as follows: Concatenate and combine the text to be retrieved with each candidate text in the candidate text set according to a preset delimiter to generate a text pair sequence. For example, "[SEP]" can be used as the delimiter to concatenate the text to be retrieved "How's the weather today" with the candidate text "It's sunny today" as "How's the weather today[SEP]It's sunny today". Similar operations are performed on each candidate text in the candidate text set to generate multiple text pair sequences.

[0036] Input the text pair sequence into the cross-encoder model. This model adopts a bidirectional transformer structure to encode the text to be retrieved and the candidate text respectively, generating a first feature sequence of the text to be retrieved and a second feature sequence of the candidate text. Specifically, the model first tokenizes the input text pair sequence, and then converts the tokenization result into word vectors. Then, the word vector sequence is processed through multiple layers of transformer encoders to obtain the context-related representation of the text. In this process, the model can capture the long-range dependence relationship and context information in the text.

[0037] Calculate the interaction features between the first feature sequence and the second feature sequence based on the multi-head cross-attention mechanism. The multi-head cross-attention mechanism allows the model to learn the alignment relationship between texts from multiple different representation subspaces. Specifically, 8 attention heads can be used, and the dimension of each head is 64. In this way, the model can comprehensively capture the correlation between the text to be retrieved and the candidate text.

[0038] Extract local semantic features from interaction features through a one-dimensional convolutional neural network. Convolution kernels of different sizes (such as 3, 4, 5) can be used to capture local features in different ranges. For example, use 128 3x1 convolutional kernels, 128 4x1 convolutional kernels, and 128 5x1 convolutional kernels to perform convolution operations on the interaction features respectively, and then concatenate the results to obtain local semantic features.

[0039] At the same time, calculate the long-range dependencies in the interaction features through the self-attention layer to obtain global semantic features. The self-attention layer can capture the relationships between any positions in the sequence and effectively model long-range dependencies. 8 attention heads with a dimension of 64 for each head can be used to fully capture global semantic information.

[0040] Perform adaptive weighted summation on the local semantic features and the global semantic features to obtain a unified representation vector for the text pair. Adaptive weighting can be achieved through a learnable parameter α, enabling the model to automatically adjust the importance of local features and global features according to different inputs. The calculation formula for the unified representation vector can be expressed as: the local semantic features multiplied by α plus the global semantic features multiplied by (1 - α). Here, α is a learnable parameter with a value range between 0 and 1.

[0041] Input the unified representation vector into the fully-connected neural network of the cross-encoder model. This network performs a non-linear transformation on the unified representation vector and outputs the correlation score of the text pair. The fully-connected neural network can contain multiple hidden layers, and each hidden layer uses the ReLU activation function. For example, two hidden layers can be used, with 512 neurons in the first layer, 256 neurons in the second layer, and the last layer outputs a scalar value as the correlation score.

[0042] According to the calculated correlation scores, sort the candidate text set in descending order to generate a sorted list of candidate texts, and output this list as the initial search result. Sorting can be implemented using the quicksort algorithm with a time complexity of O(nlogn), where n is the number of candidate texts.

[0043] To better illustrate the implementation process of this method, a specific data case is given below: Suppose the text to be retrieved is "How to prevent colds", and the candidate text set contains the following texts: 1. "Drinking more hot water helps prevent colds"; 2. "Regular work and rest can enhance immunity"; 3. "The symptoms of a cold include fever and cough"; 4. "Maintaining good personal hygiene habits can prevent colds"; 5. "Exercise can improve the body's resistance"; First, combine the text to be retrieved with each candidate text to form text pairs: 1. "How to prevent colds [SEP] Drinking more hot water helps prevent colds"; 2. "How to prevent colds [SEP] Regular work and rest can enhance immunity"; 3. "How to prevent colds [SEP] Symptoms of a cold include fever and cough"; 4. "How to prevent colds [SEP] Maintaining good personal hygiene habits can prevent colds"; 5. "How to prevent colds [SEP] Exercise can improve the body's resistance"; Input these text pairs into the cross-encoder model. After the above processing steps, obtain the relevance scores of each text pair (hypothetical): 1. 0.85; 2. 0.72; 3. 0.45; 4. 0.93; 5. 0.78; Sort the candidate texts in descending order according to the relevance scores to obtain the final initial search results: 1. "Maintaining good personal hygiene habits can prevent colds" (Score: 0.93); 2. "Drinking more hot water helps prevent colds" (Score: 0.85); 3. "Exercise can improve the body's resistance" (Score: 0.78); 4. "Regular work and rest can enhance immunity" (Score: 0.72); 5. "Symptoms of a cold include fever and cough" (Score: 0.45); Through this method, we can effectively sort the candidate texts, rank the most relevant texts at the front, and provide more accurate search results for users. This method makes full use of the advantages of the cross-encoder model, can deeply understand the semantic information and context relationship of the text, and thus realizes high-quality text retrieval.

[0044] In an alternative implementation, the text optimization model based on the knowledge graph includes a knowledge entity extraction module and an entity relationship reasoning module. Identify key entities from the initial search results through the knowledge entity extraction module, and analyze the association relationships between the key entities based on a preset knowledge graph through the entity relationship reasoning module, including: Perform sentence splitting and named entity recognition on each text content in the initial search results to obtain an entity annotation sequence; Perform entity linking on the entity annotation sequence, and match the identified entities with the standard entities in the knowledge graph; calculate the occurrence frequency and position importance score of the entities in the text; calculate the relevance score of the entities to the text theme in combination with word vectors; generate entity importance scores based on the weighted calculation of entity frequency, position importance score, and relevance score; select the entities with entity importance scores greater than the preset scoring threshold as the key entity set; Using the entities in the key entity set as the starting nodes, perform multi-hop relationship path search in the knowledge graph, filter the relationship paths with credibility higher than the preset credibility threshold, extract the entity relationship triples included in the relationship paths, and calculate the relationship strength based on the occurrence frequencies of the head entity, tail entity, and relationship type in the entity relationship triples; Construct an entity relationship graph based on the relationship strength and the entity relationship triples, and perform node importance propagation in the entity relationship graph to obtain the final importance score of each entity.

[0045] The knowledge entity extraction module is used to identify key entities from the initial search results, and the entity relationship reasoning module analyzes the association relationships between key entities based on the preset knowledge graph.

[0046] Perform sentence splitting on each piece of text content in the initial search results. Taking "Today the weather is sunny and suitable for going out to play. There are many scenic spots in Beijing, such as the Forbidden City, the Great Wall, etc." as an example, it can be divided into two sentences: "Today the weather is sunny and suitable for going out to play." and "There are many scenic spots in Beijing, such as the Forbidden City, the Great Wall, etc.". Then perform named entity recognition on the text after sentence splitting to obtain the entity annotation sequence. For example, entities such as "Beijing", "the Forbidden City", and "the Great Wall" can be recognized and their types can be annotated. For example, "Beijing" is annotated as a location, and "the Forbidden City" and "the Great Wall" are annotated as scenic spots.

[0047] Next, perform entity linking on the entity annotation sequence, and match the identified entities with the standard entities in the knowledge graph. For example, "the Forbidden City" may be matched to the "Palace Museum" entity in the knowledge graph.

[0048] Calculate the occurrence frequency and position importance score of the entities in the text. For example, "Beijing" appears 1 time, at the beginning of the sentence, and has a higher score; "the Forbidden City" and "the Great Wall" each appear 1 time, at the end of the sentence, and have lower scores.

[0049] Calculate the relevance score of the entities to the text theme in combination with word vectors. For example, if the text theme is "Beijing tourism", then the relevance scores of "Beijing", "the Forbidden City", and "the Great Wall" are all relatively high.

[0050] Generate entity importance scores based on the weighted calculation of entity frequency, location importance scores, and relevance scores. The weights can be set to 0.3, 0.3, and 0.4 respectively. Suppose the three scores of "Beijing" are 1, 0.9, and 0.95 respectively, then its importance score is 1 * 0.3 + 0.9 * 0.3 + 0.95 * 0.4 = 0.95.

[0051] Select entities with entity importance scores greater than the preset scoring threshold as the key entity set. For example, set the threshold to 0.8, then "Beijing", "The Forbidden City", and "The Great Wall" may all be selected as key entities.

[0052] Use the entities in the key entity set as the starting nodes to perform multi-hop relationship path search in the knowledge graph. Filter the relationship paths with credibility higher than the preset credibility threshold. For example, set the threshold to 0.9, then only retain the relationship paths with credibility greater than 0.9.

[0053] Extract the entity relationship triples contained in the relationship paths. Calculate the relationship strength based on the occurrence frequencies of the head entity, tail entity, and relationship type in the entity relationship triples.

[0054] Construct an entity relationship graph based on the relationship strength and entity relationship triples; perform node importance propagation in the entity relationship graph to obtain the final importance scores of each entity. The PageRank algorithm can be used for importance propagation and iterate until convergence.

[0055] Through the above steps, key entities can be extracted from the initial search results, and the association relationships between entities can be analyzed, providing a basis for subsequent text optimization. This method can effectively utilize the structured information in the knowledge graph and improve the accuracy of entity recognition and relationship reasoning.

[0056] In practical applications, various thresholds and parameters can be adjusted according to specific scenarios. For example, for shorter texts, the threshold of entity importance scores can be lowered to retain more entities; for texts in professional fields, the credibility threshold of relationship paths can be increased to ensure the accuracy of reasoning results.

[0057] In addition, different weights and calculation methods can be adopted for different types of entities and relationships. For example, for news texts, higher weights can be assigned to entities of time and location types; for scientific and technological texts, higher weights can be assigned to entities of technical terms and company name types.

[0058] In the process of constructing the entity relationship graph, the time dimension can be considered to handle the situation where entity relationships change over time. For example, for the relationship of "company - CEO - person name", the effective time period of the relationship can be marked to more accurately reflect the dynamic relationship between entities.

[0059] When propagating node importance, the directionality and semantics of the relationships can be considered. For example, for a relationship like "A is subordinate to B", when propagating importance, more importance can be passed from node B to node A, while less importance is passed from node A to node B.

[0060] Finally, to improve the interpretability of the system, the decision-making basis can be recorded at each step. For example, when performing entity linking, the specific matching features can be recorded; when filtering relationship paths, the calculation process of the credibility can be recorded. This information can help understand and optimize the behavior of the system.

[0061] Through the above detailed implementation manners, those skilled in the art can implement a text optimization model based on a knowledge graph according to the disclosed content, including two key modules: knowledge entity extraction and entity relationship reasoning. This model can effectively extract key information from text and perform relationship reasoning using the knowledge graph, providing strong support for subsequent text optimization tasks.

[0062] In an alternative implementation manner, using the entities in the key entity set as the starting nodes, performing multi-hop relationship path search in the knowledge graph, and filtering relationship paths with credibility higher than a preset credibility threshold includes: Taking the starting node as the current search node, obtaining the adjacent node set of the current search node and the corresponding relationship types; calculating the credibility of each node in the adjacent node set, where the credibility is determined by the product of the node importance score, the relationship type weight, and the path attenuation factor. Among them, the node importance score is obtained by weighted summation of the in-degree, out-degree, and node attribute values of the node; the relationship type weight is determined by the ratio of the number of occurrences of the relationship corresponding to the node to the maximum relationship frequency; the path attenuation factor is determined based on the exponential relationship between a preset attenuation base and the current hop count; Selecting nodes with credibility exceeding the preset credibility threshold as candidate nodes; recording the path information from the current search node to the candidate nodes; Recursively performing path search on each candidate node until the preset maximum hop count is reached or the search queue is empty, specifically including: Adding the candidate nodes to the node search queue; updating the node access status to mark the visited nodes; calculating the cumulative credibility of the current path information, where the cumulative credibility is the sum of the credibilities of all nodes on the path; when the search depth reaches the preset maximum hop count, storing the current path information and the cumulative credibility into the path result set.

[0063] Using the entities in the key entity set as the starting nodes, perform multi-hop relationship path search in the knowledge graph. Specifically, take the starting node as the current search node, and obtain the adjacent node set and the corresponding relationship types of the current search node. For example, assume the starting node is "a certain mobile phone company", and the adjacent nodes may include "Tim Cook" (relationship type: CEO), "iPhone" (relationship type: product), "California" (relationship type: location of headquarters), etc.

[0064] Next, calculate the credibility of each node in the adjacent node set. The credibility is determined by the product of the node importance score, the relationship type weight, and the path attenuation factor.

[0065] The node importance score is obtained by the weighted sum of the in-degree, out-degree, and node attribute values of the node. The in-degree represents the number of edges pointing to the node, and the out-degree represents the number of edges starting from the node. The node attribute value can be the PageRank value of the node, the centrality of the node in the graph, etc. For example, for the node "Tim Cook", assume its in-degree is 50, out-degree is 30, and PageRank value is 0.8. Then, weights can be set as 0.3, 0.3, and 0.4 respectively, and the calculated node importance score is: 0.3×50 + 0.3×30 + 0.4×0.8 = 24.32.

[0066] The relationship type weight is determined by the ratio of the number of occurrences of the relationship corresponding to the node to the maximum relationship frequency. For example, if the "CEO" relationship appears 500 times in the knowledge graph, and the maximum relationship frequency (such as the "located in" relationship) appears 2000 times, then the weight of the "CEO" relationship is 500 / 2000 = 0.25.

[0067] The path attenuation factor is determined based on the exponential relationship between the preset attenuation base and the current hop count. Assume the attenuation base is 0.8 and the current hop count is 1, then the path attenuation factor is the 1st power of 0.8, which is 0.8; when the hop count is 2, the attenuation factor is the 2nd power of 0.8, which is 0.64. This design is to reduce the credibility of long paths because generally, the longer the path, the less direct the relationship may be and the lower the credibility.

[0068] Combining the above three factors, assume the node importance score of the node "Tim Cook" is 24.32, the weight of the relationship type "CEO" is 0.25, and the path attenuation factor corresponding to the current hop count of 1 is 0.8. Then the credibility of this node is 24.32×0.25×0.8 = 4.864.

[0069] Select nodes with credibility exceeding the preset credibility threshold as candidate nodes. Assume the preset credibility threshold is 3.0. Then, the credibility of the "Tim Cook" node, which is 4.864, is greater than the threshold, and it is selected as a candidate node. Record the path information from the current search node "Apple Inc." to the candidate node "Tim Cook", including node ID, relationship type, credibility, etc.

[0070] Recursively perform path search for each candidate node until the preset maximum number of hops is reached or the search queue is empty. The specific steps are as follows: Add the candidate node to the node search queue. For example, add "Tim Cook" to the search queue.

[0071] Update the node access status, mark the visited nodes to avoid repeated visits and forming loops. A hash table can be used to record the visited nodes, with the node ID as the key and a boolean value indicating whether it has been visited as the value. For example, mark "Apple Inc." and "Tim Cook" as visited status.

[0072] Calculate the cumulative credibility of the current path information, which is the sum of the credibility of all nodes on the path. For example, the cumulative credibility of the path "Apple Inc. → Tim Cook" is the initial credibility of the starting node (assumed to be 5.0) plus the credibility of "Tim Cook", which is 4.864, equal to 9.864.

[0073] When the search depth reaches the preset maximum number of hops, store the current path information and the cumulative credibility in the path result set. For example, if the preset maximum number of hops is 2, and currently, it has jumped from "Apple Inc." to "Tim Cook" and then to "Stanford University" (relationship type: alma mater), then store the path "Apple Inc. → Tim Cook → Stanford University" and its cumulative credibility in the result set.

[0074] Continue using "Tim Cook" as the current search node, repeat the above steps, obtain its adjacent nodes such as "Stanford University", "Auburn University", etc., calculate the credibility of these nodes, and select the nodes exceeding the threshold for continued search.

[0075] Assume the node importance score of "Stanford University" is 30.5, the weight of the relationship type "alma mater" is 0.15, and the path attenuation factor corresponding to the current hop count of 2 is 0.64. Then, the credibility of this node is 30.5 × 0.15 × 0.64 = 2.928. If the threshold is still 3.0, then "Stanford University" will not be selected as a candidate node, and the search stops at this node.

[0076] If the search queue is empty or all paths reach the maximum number of hops, the search ends. Finally, the path result set contains all paths that meet the conditions and their cumulative credibility. The paths can be sorted according to the cumulative credibility, and the path with the highest credibility can be selected as the final result.

[0077] Through the above method, multi-hop relationship paths between key entities can be efficiently discovered in the knowledge graph, and the most relevant and reliable paths can be filtered out through credibility calculation, providing support for knowledge discovery and reasoning.

[0078] In an alternative embodiment, the initial search results are re-sorted and filtered according to the association relationship, and the final search results include: An entity association matrix is established according to the association relationship, where the rows and columns of the entity association matrix represent entities, and the matrix element values are the association strength values of the corresponding entity pairs; calculate the first-order associated entity set of each entity, and the first-order associated entity set contains all entities directly connected to the entity; count the network centrality of each entity, and the network centrality is the size of the first-order associated entity set of the entity; The initial search results are re-sorted according to the size of the network centrality; and the initial search results with a network centrality less than a preset screening threshold are deleted to obtain the final search results.

[0079] The specific implementation of re-sorting and filtering the initial search results according to the association relationship to obtain the final search results is as follows: An entity association matrix is established. The rows and columns of this matrix both represent entities, and each element value in the matrix represents the association strength between the corresponding row and column entities. For example, suppose there are entities A, B, C, and D, and their association strengths can be represented by a 4x4 matrix. The value at the position (A, B) in the matrix represents the association strength between entities A and B.

[0080] The first-order associated entity set contains all entities directly connected to the entity. The specific approach is to traverse the row corresponding to the entity in the entity association matrix, and add the entities corresponding to the columns with an association strength greater than 0 to the first-order associated entity set. For example, for entity A, if the values of columns B and C in row A of the matrix are greater than 0, while the value of column D is 0, then the first-order associated entity set of A is {B, C}.

[0081] The network centrality is defined as the size of the first-order associated entity set of the entity. Continuing with the above example, the network centrality of entity A is 2 because the size of its first-order associated entity set {B, C} is 2.

[0082] Based on the calculated network centrality, the initial search results are re-sorted. The sorting rule is that the larger the network centrality, the higher the ranking. For example, suppose the initial search results are [E1, E2, E3, E4], and their network centralities are [3, 5, 2, 4] respectively, then the re-sorted result is [E2, E4, E1, E3].

[0083] Finally, set a preset screening threshold and delete the search results with a network centrality less than this threshold. For example, if the threshold is set to 3, then E3 in the above sorting results will be deleted because its network centrality is 2, which is less than the threshold 3. The final obtained search results are [E2, E4, E1].

[0084] The following uses a specific data case to illustrate the whole process: Suppose the initial search results contain 5 entities: E1, E2, E3, E4, E5. Their association relationships are represented by the following 5x5 entity association matrix: E1 E2 E3 E4 E5; E1 0 1 1 0 1; E2 1 0 1 1 0; E3 1 1 0 0 1; E4 0 1 0 0 1; E5 1 0 1 1 0; First, calculate the set of first-order associated entities for each entity: E1: {E2, E3, E5}; E2: {E1, E3, E4}; E3: {E1, E2, E5}; E4: {E2, E5}; E5: {E1, E3, E4}; Then, count the network centrality of each entity: E1: 3; E2: 3; E3: 3; E4: 2; E5: 3; Re-sort the initial search results according to the network centrality. Since the network centralities of E1, E2, E3, and E5 are the same, their relative order remains unchanged. E4 is ranked last because its network centrality is the smallest. The re-sorted results are: [E1, E2, E3, E5, E4]; Finally, assume that the set screening threshold is 3, then the entity E4 with a network centrality less than 3 will be deleted.

[0085] The final obtained search results are: [E1, E2, E3, E5].

[0086] The advantage of this method is that it not only considers the direct association relationships between entities, but also reflects the importance of entities in the entire network through network centrality. Entities with high network centrality are often associated with more other entities, and thus may contain richer and more relevant information. By reordering and filtering in this way, more important and relevant search results can be preferentially presented to users, while relatively isolated and weakly associated results are filtered out, thereby improving the quality and relevance of search results.

[0087] In practical applications, the entity association matrix may be a very large sparse matrix. Therefore, when implementing, it is necessary to consider using appropriate data structures to store and process this matrix, such as using adjacency lists or the compressed sparse row (CSR) format. At the same time, for large-scale data, a distributed computing framework can be considered to improve processing efficiency.

[0088] In addition, the calculation method of association strength can also be customized according to specific application scenarios. For example, in text search, the association strength between entities can be calculated based on term frequency-inverse document frequency (TF-IDF); in social network analysis, the association strength can be calculated based on user interaction frequency.

[0089] Generally speaking, this method of reordering and filtering search results based on association relationships improves search quality by leveraging the association information between entities, and has strong flexibility and scalability, and can be adjusted and optimized according to different application scenarios.

[0090] The text search system based on vector retrieval and large model optimization according to the embodiments of the present invention includes: A first unit, configured to obtain the text to be retrieved, input the text to be retrieved into a pre-trained large language model, and generate a first semantic vector of the text to be retrieved through the pre-trained large language model, where the large language model includes an encoder layer with a multi-layer transformer structure; A second unit, configured to perform similarity calculation in the vector retrieval database based on the first semantic vector, and obtain a candidate text set whose similarity to the first semantic vector is greater than a preset similarity threshold; A third unit, configured to combine the text to be retrieved with each candidate text in the candidate text set into a text pair, input the text pair into a cross-encoder model, the cross-encoder model calculates a relevance score based on the context information of the text pair, and sorts the candidate text set in descending order according to the relevance score to obtain an initial search result; A fourth unit is configured to input the initial search results into a text optimization model based on a knowledge graph. The text optimization model based on the knowledge graph includes a knowledge entity extraction module and an entity relationship reasoning module. The knowledge entity extraction module is configured to identify key entities from the initial search results, and the entity relationship reasoning module is configured to analyze the association relationships between the key entities based on a preset knowledge graph, and reorder and filter the initial search results according to the association relationships to obtain final search results.

[0091] In a third aspect of the embodiments of the present invention, a kind of electronic device is provided, including: a processor; a memory for storing instructions executable by the processor; wherein, the processor is configured to call the instructions stored in the memory to execute the method described above.

[0092] In a fourth aspect of the embodiments of the present invention, a computer-readable storage medium is provided, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the method described above is implemented.

[0093] The present invention may be a method, an apparatus, a system, and / or a computer program product. The computer program product may include a computer-readable storage medium, on which computer-readable program instructions for executing various aspects of the present invention are uploaded.

[0094] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A text search method based on vector retrieval and large model optimization, characterized in that: include: Acquire a text to be retrieved, and input the text to be retrieved into a pre-trained large language model, generate a semantic vector for the text to be retrieved by using the pre-trained large language model, and obtain a first semantic vector of the text to be retrieved, wherein the large language model includes an encoder layer of a multi-layer transformer structure; Performing similarity calculation in the vector retrieval database based on the first semantic vector, obtaining a set of candidate texts whose similarity to the first semantic vector is greater than a preset similarity threshold; Combining the text to be retrieved with each candidate text in the candidate text set into a text pair, inputting the text pair into a cross encoder model, the cross encoder model calculating a relevance score based on context information of the text pair, and sorting the candidate text set in descending order according to the relevance score to obtain an initial search result; The initial search results are input into a text optimization model based on a knowledge graph, wherein the text optimization model based on a knowledge graph includes a knowledge entity extraction module and an entity relationship reasoning module. The knowledge entity extraction module is used to identify key entities from the initial search results, and the entity relationship reasoning module is used to analyze the association relationship between the key entities based on a preset knowledge graph. The initial search results are reordered and filtered according to the association relationship to obtain a final search result.

2. The method according to claim 1, characterized in that Generating a semantic vector for the text to be retrieved by using the pre-trained large language model to obtain a first semantic vector of the text to be retrieved includes: Inputting the text to be retrieved into an encoder layer of a pre-trained large language model, wherein the encoder layer includes a multi-layer transformer structure, and each layer of the transformer structure includes a self-attention sublayer and a feedforward neural network sublayer; In the encoder layer, the position information of the word unit in the to-be-retrieved text is encoded into a position vector through position encoding, and the position vector is combined with the word embedding vector corresponding to the word unit to obtain an input vector sequence; the self-attention sublayer calculates an attention weight matrix based on the input vector sequence, and performs weighted fusion on the input vector sequence according to the attention weight matrix to obtain a context representation vector; the feedforward neural network sublayer performs a nonlinear transformation on the context representation vector to obtain a feature vector; A pooling layer is set at the output end of the encoder layer, and the pooling layer adopts an attention pooling mechanism to perform weighted averaging on the feature vectors through learned attention weights to obtain a global semantic representation of the text; the global semantic representation is input into a dimensional mapping layer, and the global semantic representation is mapped into a first semantic vector of a fixed dimension through the dimensional mapping layer.

3. The method according to claim 1, characterized in that The text to be retrieved and each candidate text in the candidate text set are combined into a text pair, and the text pair is input into a cross encoder model, and the cross encoder model calculates a relevance score based on context information of the text pair, and the candidate text set is sorted in descending order according to the relevance score, and the initial search results include: The text to be searched is concatenated with each candidate text in the candidate text set according to a preset separator to generate a text pair sequence; Input the text pair sequence into a cross encoder model, encode the text to be retrieved and the candidate text respectively through the bidirectional transformer structure of the cross encoder model, generate a first feature sequence of the text to be retrieved and a second feature sequence of the candidate text; calculate the interactive features between the first feature sequence and the second feature sequence based on a multi-head cross attention mechanism; Extracting local semantic features from the interaction features through a one-dimensional convolutional neural network; calculating long-distance dependencies in the interaction features through a self-attention layer to obtain global semantic features; performing adaptive weighted summation of the local semantic features and the global semantic features to obtain a unified representation vector for the text pair; Inputting the unified representation vector into a fully connected neural network of a cross encoder model, performing a nonlinear transformation on the unified representation vector through the fully connected neural network, and outputting a relevance score of the text pair; The candidate text set is sorted in descending order according to the relevance score to generate a sorted candidate text list, and the sorted candidate text list is output as an initial search result.

4. The method according to claim 1, characterized in that: The text optimization model based on the knowledge graph includes a knowledge entity extraction module and an entity relationship reasoning module. The knowledge entity extraction module is used to identify key entities from the initial search results. The entity relationship reasoning module is used to analyze the association relationship between the key entities based on a preset knowledge graph, including: Perform sentence processing and named entity recognition on each text content in the initial search results to obtain an entity annotation sequence; Perform entity linking on the entity annotation sequence, and match the identified entities with standard entities in the knowledge graph; calculate the frequency of occurrence and position importance score of the entity in the text; calculate the relevance score of the entity and the text topic in combination with the word vector; generate the entity importance score according to the weighted calculation of the entity frequency, position importance score and relevance score; select entities whose entity importance score is greater than a preset scoring threshold as the key entity set; Taking the entities in the key entity set as the starting nodes, a multi-hop relationship path search is performed in the knowledge graph, the relationship paths whose credibility is higher than a preset credibility threshold are screened, the entity relationship triples contained in the relationship paths are extracted, and the relationship strength is calculated based on the occurrence frequencies of the head entity, the tail entity and the relationship type in the entity relationship triples; An entity relationship graph is constructed based on the relationship strength and the entity relationship triples, and node importance propagation is performed in the entity relationship graph to obtain a final importance score of each entity.

5. The method according to claim 4, characterized in that Taking an entity in the key entity set as a starting node, performing a multi-hop relationship path search in the knowledge graph, and screening a relationship path whose credibility is higher than a preset credibility threshold includes: Taking the starting node as the current search node, obtaining the adjacent node set and the corresponding relationship type of the current search node; calculating the credibility of each node in the adjacent node set, wherein the credibility is determined by the product of the node importance score, the relationship type weight and the path attenuation factor, wherein the node importance score is obtained by the weighted sum of the node's in-degree, out-degree and node attribute value; the relationship type weight is determined by the ratio of the number of times the relationship corresponding to the node appears to the maximum relationship frequency; the path attenuation factor is determined based on the exponential relationship between a preset attenuation base and the current number of hops; Selecting nodes whose credibility exceeds a preset credibility threshold as candidate nodes; recording path information from the current search node to the candidate nodes; Recursively perform a path search on each candidate node until a preset maximum number of hops is reached or the search queue is empty, specifically including: The candidate node is added to the node search queue; the node access status is updated and the visited node is marked; the cumulative credibility of the current path information is calculated, and the cumulative credibility is the sum of the credibility of all nodes on the path; when the search depth reaches the preset maximum number of hops, the current path information and the cumulative credibility are stored in the path result set.

6. The method according to claim 1, characterized in that The initial search results are reordered and filtered according to the association relationship, and the final search results include: Establish an entity association matrix according to the association relationship pairs, wherein the rows and columns of the entity association matrix represent entities, and the matrix element values ​​are the association strength values ​​of the corresponding entity pairs; calculate the first-order associated entity set of each entity, wherein the first-order associated entity set includes all entities directly connected to the entity; and count the network centrality of each entity, wherein the network centrality is the size of the first-order associated entity set of the entity; The initial search results are reordered according to the size of the network centrality; and the initial search results whose network centrality is less than a preset screening threshold are deleted to obtain the final search results.

7. A text search system based on vector retrieval and large model optimization, used to implement the method according to any one of claims 1 to 6, characterized in that: include: The first unit is used to obtain a text to be retrieved, and input the text to be retrieved into a pre-trained large language model, and generate a semantic vector for the text to be retrieved by using the pre-trained large language model to obtain a first semantic vector of the text to be retrieved, wherein the large language model includes an encoder layer of a multi-layer transformer structure; A second unit is configured to perform similarity calculation in the vector retrieval database based on the first semantic vector, and obtain a set of candidate texts whose similarity to the first semantic vector is greater than a preset similarity threshold; A third unit is used to combine the text to be retrieved and each candidate text in the candidate text set into a text pair, input the text pair into a cross encoder model, the cross encoder model calculates a relevance score based on context information of the text pair, and sorts the candidate text set in descending order according to the relevance score to obtain an initial search result; The fourth unit is used to input the initial search results into a text optimization model based on a knowledge graph, wherein the text optimization model based on the knowledge graph includes a knowledge entity extraction module and an entity relationship reasoning module. The knowledge entity extraction module is used to identify key entities from the initial search results, and the entity relationship reasoning module is used to analyze the association relationship between the key entities based on a preset knowledge graph. The initial search results are reordered and filtered according to the association relationship to obtain the final search results.

8. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to call the instructions stored in the memory to execute the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Water conservancy literature recommendation method and system based on automatic completion of knowledge graph

    CN113239210A

  • Entity similarity calculation method and device and related equipment

    CN114996411A

  • Knowledge search method and system based on long and short text semantic analysis retrieval

    CN116932729A

  • Data search method and device based on knowledge graph and electronic equipment

    CN117076599A

  • Knowledge graph searching method and system based on local semantics and global communitization

    CN119577098A

Cited By

  • Electric power scientific research information text retrieval optimization method and system

    CN120508607A

  • Intelligent popular science content retrieval interaction system and method combined with knowledge graph

    CN120763341A

  • LLM-Text2SQL-oriented database table relation exploration method

    CN121070988A

  • Wading infrastructure toughness evaluation method and device based on multi-source data driving

    CN121212858A

  • Knowledge question-answering method and device based on large-model multi-sample context learning and storage medium

    CN121478948A